babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * 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;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * 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).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * 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.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * 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.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * 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).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * 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.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * 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.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the midtones Hue value.
  7936. * 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).
  7937. */
  7938. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the midtones Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the midtones Saturation value.
  7956. * 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.
  7957. */
  7958. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the midtones Exposure value.
  7965. * 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.
  7966. */
  7967. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the shadows Hue value.
  7978. * 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).
  7979. */
  7980. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the shadows Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows Saturation value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the shadows Saturation value.
  7998. * 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.
  7999. */
  8000. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the shadows Exposure value.
  8007. * 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.
  8008. */
  8009. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param overrideAspectRatio Override the aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, overrideAspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * 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)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @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.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * 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.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. }
  10912. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * 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
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @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
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @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
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * 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.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * 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.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. 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;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. /**
  12732. * Creates a new raw 2D array texture
  12733. * @param data defines the data used to create the texture
  12734. * @param width defines the width of the texture
  12735. * @param height defines the height of the texture
  12736. * @param depth defines the number of layers of the texture
  12737. * @param format defines the format of the texture
  12738. * @param generateMipMaps defines if the engine must generate mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compressed used (can be null)
  12742. * @param textureType defines the compressed used (can be null)
  12743. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12744. */
  12745. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12746. /**
  12747. * Update a raw 2D array texture
  12748. * @param texture defines the texture to update
  12749. * @param data defines the data to store
  12750. * @param format defines the data format
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw 2D array texture
  12756. * @param texture defines the texture to update
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param invertY defines if data must be stored with Y axis inverted
  12760. * @param compression defines the used compression (can be null)
  12761. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12762. */
  12763. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12764. }
  12765. }
  12766. }
  12767. declare module "babylonjs/Materials/Textures/rawTexture" {
  12768. import { Scene } from "babylonjs/scene";
  12769. import { Texture } from "babylonjs/Materials/Textures/texture";
  12770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12771. /**
  12772. * Raw texture can help creating a texture directly from an array of data.
  12773. * This can be super useful if you either get the data from an uncompressed source or
  12774. * if you wish to create your texture pixel by pixel.
  12775. */
  12776. export class RawTexture extends Texture {
  12777. /**
  12778. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12779. */
  12780. format: number;
  12781. private _engine;
  12782. /**
  12783. * Instantiates a new RawTexture.
  12784. * Raw texture can help creating a texture directly from an array of data.
  12785. * This can be super useful if you either get the data from an uncompressed source or
  12786. * if you wish to create your texture pixel by pixel.
  12787. * @param data define the array of data to use to create the texture
  12788. * @param width define the width of the texture
  12789. * @param height define the height of the texture
  12790. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12791. * @param scene define the scene the texture belongs to
  12792. * @param generateMipMaps define whether mip maps should be generated or not
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12796. */
  12797. constructor(data: ArrayBufferView, width: number, height: number,
  12798. /**
  12799. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12800. */
  12801. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12802. /**
  12803. * Updates the texture underlying data.
  12804. * @param data Define the new data of the texture
  12805. */
  12806. update(data: ArrayBufferView): void;
  12807. /**
  12808. * Creates a luminance texture from some data.
  12809. * @param data Define the texture data
  12810. * @param width Define the width of the texture
  12811. * @param height Define the height of the texture
  12812. * @param scene Define the scene the texture belongs to
  12813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12816. * @returns the luminance texture
  12817. */
  12818. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12819. /**
  12820. * Creates a luminance alpha texture from some data.
  12821. * @param data Define the texture data
  12822. * @param width Define the width of the texture
  12823. * @param height Define the height of the texture
  12824. * @param scene Define the scene the texture belongs to
  12825. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12828. * @returns the luminance alpha texture
  12829. */
  12830. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12831. /**
  12832. * Creates an alpha texture from some data.
  12833. * @param data Define the texture data
  12834. * @param width Define the width of the texture
  12835. * @param height Define the height of the texture
  12836. * @param scene Define the scene the texture belongs to
  12837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12840. * @returns the alpha texture
  12841. */
  12842. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12843. /**
  12844. * Creates a RGB texture from some data.
  12845. * @param data Define the texture data
  12846. * @param width Define the width of the texture
  12847. * @param height Define the height of the texture
  12848. * @param scene Define the scene the texture belongs to
  12849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12853. * @returns the RGB alpha texture
  12854. */
  12855. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12856. /**
  12857. * Creates a RGBA texture from some data.
  12858. * @param data Define the texture data
  12859. * @param width Define the width of the texture
  12860. * @param height Define the height of the texture
  12861. * @param scene Define the scene the texture belongs to
  12862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12865. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12866. * @returns the RGBA texture
  12867. */
  12868. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12869. /**
  12870. * Creates a R texture from some data.
  12871. * @param data Define the texture data
  12872. * @param width Define the width of the texture
  12873. * @param height Define the height of the texture
  12874. * @param scene Define the scene the texture belongs to
  12875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12879. * @returns the R texture
  12880. */
  12881. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12882. }
  12883. }
  12884. declare module "babylonjs/Maths/math.size" {
  12885. /**
  12886. * Interface for the size containing width and height
  12887. */
  12888. export interface ISize {
  12889. /**
  12890. * Width
  12891. */
  12892. width: number;
  12893. /**
  12894. * Heighht
  12895. */
  12896. height: number;
  12897. }
  12898. /**
  12899. * Size containing widht and height
  12900. */
  12901. export class Size implements ISize {
  12902. /**
  12903. * Width
  12904. */
  12905. width: number;
  12906. /**
  12907. * Height
  12908. */
  12909. height: number;
  12910. /**
  12911. * Creates a Size object from the given width and height (floats).
  12912. * @param width width of the new size
  12913. * @param height height of the new size
  12914. */
  12915. constructor(width: number, height: number);
  12916. /**
  12917. * Returns a string with the Size width and height
  12918. * @returns a string with the Size width and height
  12919. */
  12920. toString(): string;
  12921. /**
  12922. * "Size"
  12923. * @returns the string "Size"
  12924. */
  12925. getClassName(): string;
  12926. /**
  12927. * Returns the Size hash code.
  12928. * @returns a hash code for a unique width and height
  12929. */
  12930. getHashCode(): number;
  12931. /**
  12932. * Updates the current size from the given one.
  12933. * @param src the given size
  12934. */
  12935. copyFrom(src: Size): void;
  12936. /**
  12937. * Updates in place the current Size from the given floats.
  12938. * @param width width of the new size
  12939. * @param height height of the new size
  12940. * @returns the updated Size.
  12941. */
  12942. copyFromFloats(width: number, height: number): Size;
  12943. /**
  12944. * Updates in place the current Size from the given floats.
  12945. * @param width width to set
  12946. * @param height height to set
  12947. * @returns the updated Size.
  12948. */
  12949. set(width: number, height: number): Size;
  12950. /**
  12951. * Multiplies the width and height by numbers
  12952. * @param w factor to multiple the width by
  12953. * @param h factor to multiple the height by
  12954. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12955. */
  12956. multiplyByFloats(w: number, h: number): Size;
  12957. /**
  12958. * Clones the size
  12959. * @returns a new Size copied from the given one.
  12960. */
  12961. clone(): Size;
  12962. /**
  12963. * True if the current Size and the given one width and height are strictly equal.
  12964. * @param other the other size to compare against
  12965. * @returns True if the current Size and the given one width and height are strictly equal.
  12966. */
  12967. equals(other: Size): boolean;
  12968. /**
  12969. * The surface of the Size : width * height (float).
  12970. */
  12971. readonly surface: number;
  12972. /**
  12973. * Create a new size of zero
  12974. * @returns a new Size set to (0.0, 0.0)
  12975. */
  12976. static Zero(): Size;
  12977. /**
  12978. * Sums the width and height of two sizes
  12979. * @param otherSize size to add to this size
  12980. * @returns a new Size set as the addition result of the current Size and the given one.
  12981. */
  12982. add(otherSize: Size): Size;
  12983. /**
  12984. * Subtracts the width and height of two
  12985. * @param otherSize size to subtract to this size
  12986. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12987. */
  12988. subtract(otherSize: Size): Size;
  12989. /**
  12990. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12991. * @param start starting size to lerp between
  12992. * @param end end size to lerp between
  12993. * @param amount amount to lerp between the start and end values
  12994. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12995. */
  12996. static Lerp(start: Size, end: Size, amount: number): Size;
  12997. }
  12998. }
  12999. declare module "babylonjs/Animations/runtimeAnimation" {
  13000. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13001. import { Animatable } from "babylonjs/Animations/animatable";
  13002. import { Scene } from "babylonjs/scene";
  13003. /**
  13004. * Defines a runtime animation
  13005. */
  13006. export class RuntimeAnimation {
  13007. private _events;
  13008. /**
  13009. * The current frame of the runtime animation
  13010. */
  13011. private _currentFrame;
  13012. /**
  13013. * The animation used by the runtime animation
  13014. */
  13015. private _animation;
  13016. /**
  13017. * The target of the runtime animation
  13018. */
  13019. private _target;
  13020. /**
  13021. * The initiating animatable
  13022. */
  13023. private _host;
  13024. /**
  13025. * The original value of the runtime animation
  13026. */
  13027. private _originalValue;
  13028. /**
  13029. * The original blend value of the runtime animation
  13030. */
  13031. private _originalBlendValue;
  13032. /**
  13033. * The offsets cache of the runtime animation
  13034. */
  13035. private _offsetsCache;
  13036. /**
  13037. * The high limits cache of the runtime animation
  13038. */
  13039. private _highLimitsCache;
  13040. /**
  13041. * Specifies if the runtime animation has been stopped
  13042. */
  13043. private _stopped;
  13044. /**
  13045. * The blending factor of the runtime animation
  13046. */
  13047. private _blendingFactor;
  13048. /**
  13049. * The BabylonJS scene
  13050. */
  13051. private _scene;
  13052. /**
  13053. * The current value of the runtime animation
  13054. */
  13055. private _currentValue;
  13056. /** @hidden */
  13057. _animationState: _IAnimationState;
  13058. /**
  13059. * The active target of the runtime animation
  13060. */
  13061. private _activeTargets;
  13062. private _currentActiveTarget;
  13063. private _directTarget;
  13064. /**
  13065. * The target path of the runtime animation
  13066. */
  13067. private _targetPath;
  13068. /**
  13069. * The weight of the runtime animation
  13070. */
  13071. private _weight;
  13072. /**
  13073. * The ratio offset of the runtime animation
  13074. */
  13075. private _ratioOffset;
  13076. /**
  13077. * The previous delay of the runtime animation
  13078. */
  13079. private _previousDelay;
  13080. /**
  13081. * The previous ratio of the runtime animation
  13082. */
  13083. private _previousRatio;
  13084. private _enableBlending;
  13085. private _keys;
  13086. private _minFrame;
  13087. private _maxFrame;
  13088. private _minValue;
  13089. private _maxValue;
  13090. private _targetIsArray;
  13091. /**
  13092. * Gets the current frame of the runtime animation
  13093. */
  13094. readonly currentFrame: number;
  13095. /**
  13096. * Gets the weight of the runtime animation
  13097. */
  13098. readonly weight: number;
  13099. /**
  13100. * Gets the current value of the runtime animation
  13101. */
  13102. readonly currentValue: any;
  13103. /**
  13104. * Gets the target path of the runtime animation
  13105. */
  13106. readonly targetPath: string;
  13107. /**
  13108. * Gets the actual target of the runtime animation
  13109. */
  13110. readonly target: any;
  13111. /** @hidden */
  13112. _onLoop: () => void;
  13113. /**
  13114. * Create a new RuntimeAnimation object
  13115. * @param target defines the target of the animation
  13116. * @param animation defines the source animation object
  13117. * @param scene defines the hosting scene
  13118. * @param host defines the initiating Animatable
  13119. */
  13120. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13121. private _preparePath;
  13122. /**
  13123. * Gets the animation from the runtime animation
  13124. */
  13125. readonly animation: Animation;
  13126. /**
  13127. * Resets the runtime animation to the beginning
  13128. * @param restoreOriginal defines whether to restore the target property to the original value
  13129. */
  13130. reset(restoreOriginal?: boolean): void;
  13131. /**
  13132. * Specifies if the runtime animation is stopped
  13133. * @returns Boolean specifying if the runtime animation is stopped
  13134. */
  13135. isStopped(): boolean;
  13136. /**
  13137. * Disposes of the runtime animation
  13138. */
  13139. dispose(): void;
  13140. /**
  13141. * Apply the interpolated value to the target
  13142. * @param currentValue defines the value computed by the animation
  13143. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13144. */
  13145. setValue(currentValue: any, weight: number): void;
  13146. private _getOriginalValues;
  13147. private _setValue;
  13148. /**
  13149. * Gets the loop pmode of the runtime animation
  13150. * @returns Loop Mode
  13151. */
  13152. private _getCorrectLoopMode;
  13153. /**
  13154. * Move the current animation to a given frame
  13155. * @param frame defines the frame to move to
  13156. */
  13157. goToFrame(frame: number): void;
  13158. /**
  13159. * @hidden Internal use only
  13160. */
  13161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13162. /**
  13163. * Execute the current animation
  13164. * @param delay defines the delay to add to the current frame
  13165. * @param from defines the lower bound of the animation range
  13166. * @param to defines the upper bound of the animation range
  13167. * @param loop defines if the current animation must loop
  13168. * @param speedRatio defines the current speed ratio
  13169. * @param weight defines the weight of the animation (default is -1 so no weight)
  13170. * @param onLoop optional callback called when animation loops
  13171. * @returns a boolean indicating if the animation is running
  13172. */
  13173. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13174. }
  13175. }
  13176. declare module "babylonjs/Animations/animatable" {
  13177. import { Animation } from "babylonjs/Animations/animation";
  13178. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13179. import { Nullable } from "babylonjs/types";
  13180. import { Observable } from "babylonjs/Misc/observable";
  13181. import { Scene } from "babylonjs/scene";
  13182. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13183. import { Node } from "babylonjs/node";
  13184. /**
  13185. * Class used to store an actual running animation
  13186. */
  13187. export class Animatable {
  13188. /** defines the target object */
  13189. target: any;
  13190. /** defines the starting frame number (default is 0) */
  13191. fromFrame: number;
  13192. /** defines the ending frame number (default is 100) */
  13193. toFrame: number;
  13194. /** defines if the animation must loop (default is false) */
  13195. loopAnimation: boolean;
  13196. /** defines a callback to call when animation ends if it is not looping */
  13197. onAnimationEnd?: (() => void) | null | undefined;
  13198. /** defines a callback to call when animation loops */
  13199. onAnimationLoop?: (() => void) | null | undefined;
  13200. private _localDelayOffset;
  13201. private _pausedDelay;
  13202. private _runtimeAnimations;
  13203. private _paused;
  13204. private _scene;
  13205. private _speedRatio;
  13206. private _weight;
  13207. private _syncRoot;
  13208. /**
  13209. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13210. * This will only apply for non looping animation (default is true)
  13211. */
  13212. disposeOnEnd: boolean;
  13213. /**
  13214. * Gets a boolean indicating if the animation has started
  13215. */
  13216. animationStarted: boolean;
  13217. /**
  13218. * Observer raised when the animation ends
  13219. */
  13220. onAnimationEndObservable: Observable<Animatable>;
  13221. /**
  13222. * Observer raised when the animation loops
  13223. */
  13224. onAnimationLoopObservable: Observable<Animatable>;
  13225. /**
  13226. * Gets the root Animatable used to synchronize and normalize animations
  13227. */
  13228. readonly syncRoot: Nullable<Animatable>;
  13229. /**
  13230. * Gets the current frame of the first RuntimeAnimation
  13231. * Used to synchronize Animatables
  13232. */
  13233. readonly masterFrame: number;
  13234. /**
  13235. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13236. */
  13237. weight: number;
  13238. /**
  13239. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13240. */
  13241. speedRatio: number;
  13242. /**
  13243. * Creates a new Animatable
  13244. * @param scene defines the hosting scene
  13245. * @param target defines the target object
  13246. * @param fromFrame defines the starting frame number (default is 0)
  13247. * @param toFrame defines the ending frame number (default is 100)
  13248. * @param loopAnimation defines if the animation must loop (default is false)
  13249. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13250. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13251. * @param animations defines a group of animation to add to the new Animatable
  13252. * @param onAnimationLoop defines a callback to call when animation loops
  13253. */
  13254. constructor(scene: Scene,
  13255. /** defines the target object */
  13256. target: any,
  13257. /** defines the starting frame number (default is 0) */
  13258. fromFrame?: number,
  13259. /** defines the ending frame number (default is 100) */
  13260. toFrame?: number,
  13261. /** defines if the animation must loop (default is false) */
  13262. loopAnimation?: boolean, speedRatio?: number,
  13263. /** defines a callback to call when animation ends if it is not looping */
  13264. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13265. /** defines a callback to call when animation loops */
  13266. onAnimationLoop?: (() => void) | null | undefined);
  13267. /**
  13268. * Synchronize and normalize current Animatable with a source Animatable
  13269. * This is useful when using animation weights and when animations are not of the same length
  13270. * @param root defines the root Animatable to synchronize with
  13271. * @returns the current Animatable
  13272. */
  13273. syncWith(root: Animatable): Animatable;
  13274. /**
  13275. * Gets the list of runtime animations
  13276. * @returns an array of RuntimeAnimation
  13277. */
  13278. getAnimations(): RuntimeAnimation[];
  13279. /**
  13280. * Adds more animations to the current animatable
  13281. * @param target defines the target of the animations
  13282. * @param animations defines the new animations to add
  13283. */
  13284. appendAnimations(target: any, animations: Animation[]): void;
  13285. /**
  13286. * Gets the source animation for a specific property
  13287. * @param property defines the propertyu to look for
  13288. * @returns null or the source animation for the given property
  13289. */
  13290. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13291. /**
  13292. * Gets the runtime animation for a specific property
  13293. * @param property defines the propertyu to look for
  13294. * @returns null or the runtime animation for the given property
  13295. */
  13296. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13297. /**
  13298. * Resets the animatable to its original state
  13299. */
  13300. reset(): void;
  13301. /**
  13302. * Allows the animatable to blend with current running animations
  13303. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13304. * @param blendingSpeed defines the blending speed to use
  13305. */
  13306. enableBlending(blendingSpeed: number): void;
  13307. /**
  13308. * Disable animation blending
  13309. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13310. */
  13311. disableBlending(): void;
  13312. /**
  13313. * Jump directly to a given frame
  13314. * @param frame defines the frame to jump to
  13315. */
  13316. goToFrame(frame: number): void;
  13317. /**
  13318. * Pause the animation
  13319. */
  13320. pause(): void;
  13321. /**
  13322. * Restart the animation
  13323. */
  13324. restart(): void;
  13325. private _raiseOnAnimationEnd;
  13326. /**
  13327. * Stop and delete the current animation
  13328. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13329. * @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)
  13330. */
  13331. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13332. /**
  13333. * Wait asynchronously for the animation to end
  13334. * @returns a promise which will be fullfilled when the animation ends
  13335. */
  13336. waitAsync(): Promise<Animatable>;
  13337. /** @hidden */
  13338. _animate(delay: number): boolean;
  13339. }
  13340. module "babylonjs/scene" {
  13341. interface Scene {
  13342. /** @hidden */
  13343. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13344. /** @hidden */
  13345. _processLateAnimationBindingsForMatrices(holder: {
  13346. totalWeight: number;
  13347. animations: RuntimeAnimation[];
  13348. originalValue: Matrix;
  13349. }): any;
  13350. /** @hidden */
  13351. _processLateAnimationBindingsForQuaternions(holder: {
  13352. totalWeight: number;
  13353. animations: RuntimeAnimation[];
  13354. originalValue: Quaternion;
  13355. }, refQuaternion: Quaternion): Quaternion;
  13356. /** @hidden */
  13357. _processLateAnimationBindings(): void;
  13358. /**
  13359. * Will start the animation sequence of a given target
  13360. * @param target defines the target
  13361. * @param from defines from which frame should animation start
  13362. * @param to defines until which frame should animation run.
  13363. * @param weight defines the weight to apply to the animation (1.0 by default)
  13364. * @param loop defines if the animation loops
  13365. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13366. * @param onAnimationEnd defines the function to be executed when the animation ends
  13367. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13368. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13369. * @param onAnimationLoop defines the callback to call when an animation loops
  13370. * @returns the animatable object created for this animation
  13371. */
  13372. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13373. /**
  13374. * Will start the animation sequence of a given target
  13375. * @param target defines the target
  13376. * @param from defines from which frame should animation start
  13377. * @param to defines until which frame should animation run.
  13378. * @param loop defines if the animation loops
  13379. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13380. * @param onAnimationEnd defines the function to be executed when the animation ends
  13381. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13382. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13383. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13384. * @param onAnimationLoop defines the callback to call when an animation loops
  13385. * @returns the animatable object created for this animation
  13386. */
  13387. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13388. /**
  13389. * Will start the animation sequence of a given target and its hierarchy
  13390. * @param target defines the target
  13391. * @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.
  13392. * @param from defines from which frame should animation start
  13393. * @param to defines until which frame should animation run.
  13394. * @param loop defines if the animation loops
  13395. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13396. * @param onAnimationEnd defines the function to be executed when the animation ends
  13397. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13398. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13399. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13400. * @param onAnimationLoop defines the callback to call when an animation loops
  13401. * @returns the list of created animatables
  13402. */
  13403. 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[];
  13404. /**
  13405. * Begin a new animation on a given node
  13406. * @param target defines the target where the animation will take place
  13407. * @param animations defines the list of animations to start
  13408. * @param from defines the initial value
  13409. * @param to defines the final value
  13410. * @param loop defines if you want animation to loop (off by default)
  13411. * @param speedRatio defines the speed ratio to apply to all animations
  13412. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13413. * @param onAnimationLoop defines the callback to call when an animation loops
  13414. * @returns the list of created animatables
  13415. */
  13416. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13417. /**
  13418. * Begin a new animation on a given node and its hierarchy
  13419. * @param target defines the root node where the animation will take place
  13420. * @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.
  13421. * @param animations defines the list of animations to start
  13422. * @param from defines the initial value
  13423. * @param to defines the final value
  13424. * @param loop defines if you want animation to loop (off by default)
  13425. * @param speedRatio defines the speed ratio to apply to all animations
  13426. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13427. * @param onAnimationLoop defines the callback to call when an animation loops
  13428. * @returns the list of animatables created for all nodes
  13429. */
  13430. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13431. /**
  13432. * Gets the animatable associated with a specific target
  13433. * @param target defines the target of the animatable
  13434. * @returns the required animatable if found
  13435. */
  13436. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13437. /**
  13438. * Gets all animatables associated with a given target
  13439. * @param target defines the target to look animatables for
  13440. * @returns an array of Animatables
  13441. */
  13442. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13443. /**
  13444. * Stops and removes all animations that have been applied to the scene
  13445. */
  13446. stopAllAnimations(): void;
  13447. /**
  13448. * Gets the current delta time used by animation engine
  13449. */
  13450. deltaTime: number;
  13451. }
  13452. }
  13453. module "babylonjs/Bones/bone" {
  13454. interface Bone {
  13455. /**
  13456. * Copy an animation range from another bone
  13457. * @param source defines the source bone
  13458. * @param rangeName defines the range name to copy
  13459. * @param frameOffset defines the frame offset
  13460. * @param rescaleAsRequired defines if rescaling must be applied if required
  13461. * @param skelDimensionsRatio defines the scaling ratio
  13462. * @returns true if operation was successful
  13463. */
  13464. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13465. }
  13466. }
  13467. }
  13468. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13469. /**
  13470. * Class used to override all child animations of a given target
  13471. */
  13472. export class AnimationPropertiesOverride {
  13473. /**
  13474. * Gets or sets a value indicating if animation blending must be used
  13475. */
  13476. enableBlending: boolean;
  13477. /**
  13478. * Gets or sets the blending speed to use when enableBlending is true
  13479. */
  13480. blendingSpeed: number;
  13481. /**
  13482. * Gets or sets the default loop mode to use
  13483. */
  13484. loopMode: number;
  13485. }
  13486. }
  13487. declare module "babylonjs/Bones/skeleton" {
  13488. import { Bone } from "babylonjs/Bones/bone";
  13489. import { Observable } from "babylonjs/Misc/observable";
  13490. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13491. import { Scene } from "babylonjs/scene";
  13492. import { Nullable } from "babylonjs/types";
  13493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13494. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13495. import { Animatable } from "babylonjs/Animations/animatable";
  13496. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13497. import { Animation } from "babylonjs/Animations/animation";
  13498. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13500. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13501. /**
  13502. * Class used to handle skinning animations
  13503. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13504. */
  13505. export class Skeleton implements IAnimatable {
  13506. /** defines the skeleton name */
  13507. name: string;
  13508. /** defines the skeleton Id */
  13509. id: string;
  13510. /**
  13511. * Defines the list of child bones
  13512. */
  13513. bones: Bone[];
  13514. /**
  13515. * Defines an estimate of the dimension of the skeleton at rest
  13516. */
  13517. dimensionsAtRest: Vector3;
  13518. /**
  13519. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13520. */
  13521. needInitialSkinMatrix: boolean;
  13522. /**
  13523. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13524. */
  13525. overrideMesh: Nullable<AbstractMesh>;
  13526. /**
  13527. * Gets the list of animations attached to this skeleton
  13528. */
  13529. animations: Array<Animation>;
  13530. private _scene;
  13531. private _isDirty;
  13532. private _transformMatrices;
  13533. private _transformMatrixTexture;
  13534. private _meshesWithPoseMatrix;
  13535. private _animatables;
  13536. private _identity;
  13537. private _synchronizedWithMesh;
  13538. private _ranges;
  13539. private _lastAbsoluteTransformsUpdateId;
  13540. private _canUseTextureForBones;
  13541. private _uniqueId;
  13542. /** @hidden */
  13543. _numBonesWithLinkedTransformNode: number;
  13544. /** @hidden */
  13545. _hasWaitingData: Nullable<boolean>;
  13546. /**
  13547. * Specifies if the skeleton should be serialized
  13548. */
  13549. doNotSerialize: boolean;
  13550. private _useTextureToStoreBoneMatrices;
  13551. /**
  13552. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13553. * Please note that this option is not available if the hardware does not support it
  13554. */
  13555. useTextureToStoreBoneMatrices: boolean;
  13556. private _animationPropertiesOverride;
  13557. /**
  13558. * Gets or sets the animation properties override
  13559. */
  13560. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13561. /**
  13562. * List of inspectable custom properties (used by the Inspector)
  13563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13564. */
  13565. inspectableCustomProperties: IInspectable[];
  13566. /**
  13567. * An observable triggered before computing the skeleton's matrices
  13568. */
  13569. onBeforeComputeObservable: Observable<Skeleton>;
  13570. /**
  13571. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13572. */
  13573. readonly isUsingTextureForMatrices: boolean;
  13574. /**
  13575. * Gets the unique ID of this skeleton
  13576. */
  13577. readonly uniqueId: number;
  13578. /**
  13579. * Creates a new skeleton
  13580. * @param name defines the skeleton name
  13581. * @param id defines the skeleton Id
  13582. * @param scene defines the hosting scene
  13583. */
  13584. constructor(
  13585. /** defines the skeleton name */
  13586. name: string,
  13587. /** defines the skeleton Id */
  13588. id: string, scene: Scene);
  13589. /**
  13590. * Gets the current object class name.
  13591. * @return the class name
  13592. */
  13593. getClassName(): string;
  13594. /**
  13595. * Returns an array containing the root bones
  13596. * @returns an array containing the root bones
  13597. */
  13598. getChildren(): Array<Bone>;
  13599. /**
  13600. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13601. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13602. * @returns a Float32Array containing matrices data
  13603. */
  13604. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13605. /**
  13606. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13607. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13608. * @returns a raw texture containing the data
  13609. */
  13610. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13611. /**
  13612. * Gets the current hosting scene
  13613. * @returns a scene object
  13614. */
  13615. getScene(): Scene;
  13616. /**
  13617. * Gets a string representing the current skeleton data
  13618. * @param fullDetails defines a boolean indicating if we want a verbose version
  13619. * @returns a string representing the current skeleton data
  13620. */
  13621. toString(fullDetails?: boolean): string;
  13622. /**
  13623. * Get bone's index searching by name
  13624. * @param name defines bone's name to search for
  13625. * @return the indice of the bone. Returns -1 if not found
  13626. */
  13627. getBoneIndexByName(name: string): number;
  13628. /**
  13629. * Creater a new animation range
  13630. * @param name defines the name of the range
  13631. * @param from defines the start key
  13632. * @param to defines the end key
  13633. */
  13634. createAnimationRange(name: string, from: number, to: number): void;
  13635. /**
  13636. * Delete a specific animation range
  13637. * @param name defines the name of the range
  13638. * @param deleteFrames defines if frames must be removed as well
  13639. */
  13640. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13641. /**
  13642. * Gets a specific animation range
  13643. * @param name defines the name of the range to look for
  13644. * @returns the requested animation range or null if not found
  13645. */
  13646. getAnimationRange(name: string): Nullable<AnimationRange>;
  13647. /**
  13648. * Gets the list of all animation ranges defined on this skeleton
  13649. * @returns an array
  13650. */
  13651. getAnimationRanges(): Nullable<AnimationRange>[];
  13652. /**
  13653. * Copy animation range from a source skeleton.
  13654. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13655. * @param source defines the source skeleton
  13656. * @param name defines the name of the range to copy
  13657. * @param rescaleAsRequired defines if rescaling must be applied if required
  13658. * @returns true if operation was successful
  13659. */
  13660. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13661. /**
  13662. * Forces the skeleton to go to rest pose
  13663. */
  13664. returnToRest(): void;
  13665. private _getHighestAnimationFrame;
  13666. /**
  13667. * Begin a specific animation range
  13668. * @param name defines the name of the range to start
  13669. * @param loop defines if looping must be turned on (false by default)
  13670. * @param speedRatio defines the speed ratio to apply (1 by default)
  13671. * @param onAnimationEnd defines a callback which will be called when animation will end
  13672. * @returns a new animatable
  13673. */
  13674. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13675. /** @hidden */
  13676. _markAsDirty(): void;
  13677. /** @hidden */
  13678. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13679. /** @hidden */
  13680. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13681. private _computeTransformMatrices;
  13682. /**
  13683. * Build all resources required to render a skeleton
  13684. */
  13685. prepare(): void;
  13686. /**
  13687. * Gets the list of animatables currently running for this skeleton
  13688. * @returns an array of animatables
  13689. */
  13690. getAnimatables(): IAnimatable[];
  13691. /**
  13692. * Clone the current skeleton
  13693. * @param name defines the name of the new skeleton
  13694. * @param id defines the id of the new skeleton
  13695. * @returns the new skeleton
  13696. */
  13697. clone(name: string, id?: string): Skeleton;
  13698. /**
  13699. * Enable animation blending for this skeleton
  13700. * @param blendingSpeed defines the blending speed to apply
  13701. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13702. */
  13703. enableBlending(blendingSpeed?: number): void;
  13704. /**
  13705. * Releases all resources associated with the current skeleton
  13706. */
  13707. dispose(): void;
  13708. /**
  13709. * Serialize the skeleton in a JSON object
  13710. * @returns a JSON object
  13711. */
  13712. serialize(): any;
  13713. /**
  13714. * Creates a new skeleton from serialized data
  13715. * @param parsedSkeleton defines the serialized data
  13716. * @param scene defines the hosting scene
  13717. * @returns a new skeleton
  13718. */
  13719. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13720. /**
  13721. * Compute all node absolute transforms
  13722. * @param forceUpdate defines if computation must be done even if cache is up to date
  13723. */
  13724. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13725. /**
  13726. * Gets the root pose matrix
  13727. * @returns a matrix
  13728. */
  13729. getPoseMatrix(): Nullable<Matrix>;
  13730. /**
  13731. * Sorts bones per internal index
  13732. */
  13733. sortBones(): void;
  13734. private _sortBones;
  13735. }
  13736. }
  13737. declare module "babylonjs/Bones/bone" {
  13738. import { Skeleton } from "babylonjs/Bones/skeleton";
  13739. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Nullable } from "babylonjs/types";
  13741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13743. import { Node } from "babylonjs/node";
  13744. import { Space } from "babylonjs/Maths/math.axis";
  13745. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13746. /**
  13747. * Class used to store bone information
  13748. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13749. */
  13750. export class Bone extends Node {
  13751. /**
  13752. * defines the bone name
  13753. */
  13754. name: string;
  13755. private static _tmpVecs;
  13756. private static _tmpQuat;
  13757. private static _tmpMats;
  13758. /**
  13759. * Gets the list of child bones
  13760. */
  13761. children: Bone[];
  13762. /** Gets the animations associated with this bone */
  13763. animations: import("babylonjs/Animations/animation").Animation[];
  13764. /**
  13765. * Gets or sets bone length
  13766. */
  13767. length: number;
  13768. /**
  13769. * @hidden Internal only
  13770. * Set this value to map this bone to a different index in the transform matrices
  13771. * Set this value to -1 to exclude the bone from the transform matrices
  13772. */
  13773. _index: Nullable<number>;
  13774. private _skeleton;
  13775. private _localMatrix;
  13776. private _restPose;
  13777. private _baseMatrix;
  13778. private _absoluteTransform;
  13779. private _invertedAbsoluteTransform;
  13780. private _parent;
  13781. private _scalingDeterminant;
  13782. private _worldTransform;
  13783. private _localScaling;
  13784. private _localRotation;
  13785. private _localPosition;
  13786. private _needToDecompose;
  13787. private _needToCompose;
  13788. /** @hidden */
  13789. _linkedTransformNode: Nullable<TransformNode>;
  13790. /** @hidden */
  13791. _waitingTransformNodeId: Nullable<string>;
  13792. /** @hidden */
  13793. /** @hidden */
  13794. _matrix: Matrix;
  13795. /**
  13796. * Create a new bone
  13797. * @param name defines the bone name
  13798. * @param skeleton defines the parent skeleton
  13799. * @param parentBone defines the parent (can be null if the bone is the root)
  13800. * @param localMatrix defines the local matrix
  13801. * @param restPose defines the rest pose matrix
  13802. * @param baseMatrix defines the base matrix
  13803. * @param index defines index of the bone in the hiearchy
  13804. */
  13805. constructor(
  13806. /**
  13807. * defines the bone name
  13808. */
  13809. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13810. /**
  13811. * Gets the current object class name.
  13812. * @return the class name
  13813. */
  13814. getClassName(): string;
  13815. /**
  13816. * Gets the parent skeleton
  13817. * @returns a skeleton
  13818. */
  13819. getSkeleton(): Skeleton;
  13820. /**
  13821. * Gets parent bone
  13822. * @returns a bone or null if the bone is the root of the bone hierarchy
  13823. */
  13824. getParent(): Nullable<Bone>;
  13825. /**
  13826. * Returns an array containing the root bones
  13827. * @returns an array containing the root bones
  13828. */
  13829. getChildren(): Array<Bone>;
  13830. /**
  13831. * Gets the node index in matrix array generated for rendering
  13832. * @returns the node index
  13833. */
  13834. getIndex(): number;
  13835. /**
  13836. * Sets the parent bone
  13837. * @param parent defines the parent (can be null if the bone is the root)
  13838. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13839. */
  13840. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13841. /**
  13842. * Gets the local matrix
  13843. * @returns a matrix
  13844. */
  13845. getLocalMatrix(): Matrix;
  13846. /**
  13847. * Gets the base matrix (initial matrix which remains unchanged)
  13848. * @returns a matrix
  13849. */
  13850. getBaseMatrix(): Matrix;
  13851. /**
  13852. * Gets the rest pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getRestPose(): Matrix;
  13856. /**
  13857. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13858. */
  13859. getWorldMatrix(): Matrix;
  13860. /**
  13861. * Sets the local matrix to rest pose matrix
  13862. */
  13863. returnToRest(): void;
  13864. /**
  13865. * Gets the inverse of the absolute transform matrix.
  13866. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13867. * @returns a matrix
  13868. */
  13869. getInvertedAbsoluteTransform(): Matrix;
  13870. /**
  13871. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13872. * @returns a matrix
  13873. */
  13874. getAbsoluteTransform(): Matrix;
  13875. /**
  13876. * Links with the given transform node.
  13877. * The local matrix of this bone is copied from the transform node every frame.
  13878. * @param transformNode defines the transform node to link to
  13879. */
  13880. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13881. /**
  13882. * Gets the node used to drive the bone's transformation
  13883. * @returns a transform node or null
  13884. */
  13885. getTransformNode(): Nullable<TransformNode>;
  13886. /** Gets or sets current position (in local space) */
  13887. position: Vector3;
  13888. /** Gets or sets current rotation (in local space) */
  13889. rotation: Vector3;
  13890. /** Gets or sets current rotation quaternion (in local space) */
  13891. rotationQuaternion: Quaternion;
  13892. /** Gets or sets current scaling (in local space) */
  13893. scaling: Vector3;
  13894. /**
  13895. * Gets the animation properties override
  13896. */
  13897. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13898. private _decompose;
  13899. private _compose;
  13900. /**
  13901. * Update the base and local matrices
  13902. * @param matrix defines the new base or local matrix
  13903. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13904. * @param updateLocalMatrix defines if the local matrix should be updated
  13905. */
  13906. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13907. /** @hidden */
  13908. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13909. /**
  13910. * Flag the bone as dirty (Forcing it to update everything)
  13911. */
  13912. markAsDirty(): void;
  13913. /** @hidden */
  13914. _markAsDirtyAndCompose(): void;
  13915. private _markAsDirtyAndDecompose;
  13916. /**
  13917. * Translate the bone in local or world space
  13918. * @param vec The amount to translate the bone
  13919. * @param space The space that the translation is in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. */
  13922. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Set the postion of the bone in local or world space
  13925. * @param position The position to set the bone
  13926. * @param space The space that the position is in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Set the absolute position of the bone (world space)
  13932. * @param position The position to set the bone
  13933. * @param mesh The mesh that this bone is attached to
  13934. */
  13935. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13936. /**
  13937. * Scale the bone on the x, y and z axes (in local space)
  13938. * @param x The amount to scale the bone on the x axis
  13939. * @param y The amount to scale the bone on the y axis
  13940. * @param z The amount to scale the bone on the z axis
  13941. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13942. */
  13943. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13944. /**
  13945. * Set the bone scaling in local space
  13946. * @param scale defines the scaling vector
  13947. */
  13948. setScale(scale: Vector3): void;
  13949. /**
  13950. * Gets the current scaling in local space
  13951. * @returns the current scaling vector
  13952. */
  13953. getScale(): Vector3;
  13954. /**
  13955. * Gets the current scaling in local space and stores it in a target vector
  13956. * @param result defines the target vector
  13957. */
  13958. getScaleToRef(result: Vector3): void;
  13959. /**
  13960. * Set the yaw, pitch, and roll of the bone in local or world space
  13961. * @param yaw The rotation of the bone on the y axis
  13962. * @param pitch The rotation of the bone on the x axis
  13963. * @param roll The rotation of the bone on the z axis
  13964. * @param space The space that the axes of rotation are in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. */
  13967. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13968. /**
  13969. * Add a rotation to the bone on an axis in local or world space
  13970. * @param axis The axis to rotate the bone on
  13971. * @param amount The amount to rotate the bone
  13972. * @param space The space that the axis is in
  13973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13974. */
  13975. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13976. /**
  13977. * Set the rotation of the bone to a particular axis angle in local or world space
  13978. * @param axis The axis to rotate the bone on
  13979. * @param angle The angle that the bone should be rotated to
  13980. * @param space The space that the axis is in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. */
  13983. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13984. /**
  13985. * Set the euler rotation of the bone in local of world space
  13986. * @param rotation The euler rotation that the bone should be set to
  13987. * @param space The space that the rotation is in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. */
  13990. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13991. /**
  13992. * Set the quaternion rotation of the bone in local of world space
  13993. * @param quat The quaternion rotation that the bone should be set to
  13994. * @param space The space that the rotation is in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. */
  13997. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13998. /**
  13999. * Set the rotation matrix of the bone in local of world space
  14000. * @param rotMat The rotation matrix that the bone should be set to
  14001. * @param space The space that the rotation is in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. */
  14004. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14005. private _rotateWithMatrix;
  14006. private _getNegativeRotationToRef;
  14007. /**
  14008. * Get the position of the bone in local or world space
  14009. * @param space The space that the returned position is in
  14010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14011. * @returns The position of the bone
  14012. */
  14013. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14014. /**
  14015. * Copy the position of the bone to a vector3 in local or world space
  14016. * @param space The space that the returned position is in
  14017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14018. * @param result The vector3 to copy the position to
  14019. */
  14020. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14021. /**
  14022. * Get the absolute position of the bone (world space)
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The absolute position of the bone
  14025. */
  14026. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Copy the absolute position of the bone (world space) to the result param
  14029. * @param mesh The mesh that this bone is attached to
  14030. * @param result The vector3 to copy the absolute position to
  14031. */
  14032. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14033. /**
  14034. * Compute the absolute transforms of this bone and its children
  14035. */
  14036. computeAbsoluteTransforms(): void;
  14037. /**
  14038. * Get the world direction from an axis that is in the local space of the bone
  14039. * @param localAxis The local direction that is used to compute the world direction
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The world direction
  14042. */
  14043. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14046. * @param localAxis The local direction that is used to compute the world direction
  14047. * @param mesh The mesh that this bone is attached to
  14048. * @param result The vector3 that the world direction will be copied to
  14049. */
  14050. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14051. /**
  14052. * Get the euler rotation of the bone in local or world space
  14053. * @param space The space that the rotation should be in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. * @returns The euler rotation
  14056. */
  14057. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14058. /**
  14059. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14060. * @param space The space that the rotation should be in
  14061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14062. * @param result The vector3 that the rotation should be copied to
  14063. */
  14064. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14065. /**
  14066. * Get the quaternion rotation of the bone in either local or world space
  14067. * @param space The space that the rotation should be in
  14068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14069. * @returns The quaternion rotation
  14070. */
  14071. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14072. /**
  14073. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14074. * @param space The space that the rotation should be in
  14075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14076. * @param result The quaternion that the rotation should be copied to
  14077. */
  14078. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14079. /**
  14080. * Get the rotation matrix of the bone in local or world space
  14081. * @param space The space that the rotation should be in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. * @returns The rotation matrix
  14084. */
  14085. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14086. /**
  14087. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14088. * @param space The space that the rotation should be in
  14089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14090. * @param result The quaternion that the rotation should be copied to
  14091. */
  14092. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14093. /**
  14094. * Get the world position of a point that is in the local space of the bone
  14095. * @param position The local position
  14096. * @param mesh The mesh that this bone is attached to
  14097. * @returns The world position
  14098. */
  14099. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14100. /**
  14101. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14102. * @param position The local position
  14103. * @param mesh The mesh that this bone is attached to
  14104. * @param result The vector3 that the world position should be copied to
  14105. */
  14106. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14107. /**
  14108. * Get the local position of a point that is in world space
  14109. * @param position The world position
  14110. * @param mesh The mesh that this bone is attached to
  14111. * @returns The local position
  14112. */
  14113. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14114. /**
  14115. * Get the local position of a point that is in world space and copy it to the result param
  14116. * @param position The world position
  14117. * @param mesh The mesh that this bone is attached to
  14118. * @param result The vector3 that the local position should be copied to
  14119. */
  14120. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14121. }
  14122. }
  14123. declare module "babylonjs/Meshes/transformNode" {
  14124. import { DeepImmutable } from "babylonjs/types";
  14125. import { Observable } from "babylonjs/Misc/observable";
  14126. import { Nullable } from "babylonjs/types";
  14127. import { Camera } from "babylonjs/Cameras/camera";
  14128. import { Scene } from "babylonjs/scene";
  14129. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14130. import { Node } from "babylonjs/node";
  14131. import { Bone } from "babylonjs/Bones/bone";
  14132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14133. import { Space } from "babylonjs/Maths/math.axis";
  14134. /**
  14135. * 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.
  14136. * @see https://doc.babylonjs.com/how_to/transformnode
  14137. */
  14138. export class TransformNode extends Node {
  14139. /**
  14140. * Object will not rotate to face the camera
  14141. */
  14142. static BILLBOARDMODE_NONE: number;
  14143. /**
  14144. * Object will rotate to face the camera but only on the x axis
  14145. */
  14146. static BILLBOARDMODE_X: number;
  14147. /**
  14148. * Object will rotate to face the camera but only on the y axis
  14149. */
  14150. static BILLBOARDMODE_Y: number;
  14151. /**
  14152. * Object will rotate to face the camera but only on the z axis
  14153. */
  14154. static BILLBOARDMODE_Z: number;
  14155. /**
  14156. * Object will rotate to face the camera
  14157. */
  14158. static BILLBOARDMODE_ALL: number;
  14159. /**
  14160. * Object will rotate to face the camera's position instead of orientation
  14161. */
  14162. static BILLBOARDMODE_USE_POSITION: number;
  14163. private _forward;
  14164. private _forwardInverted;
  14165. private _up;
  14166. private _right;
  14167. private _rightInverted;
  14168. private _position;
  14169. private _rotation;
  14170. private _rotationQuaternion;
  14171. protected _scaling: Vector3;
  14172. protected _isDirty: boolean;
  14173. private _transformToBoneReferal;
  14174. private _isAbsoluteSynced;
  14175. private _billboardMode;
  14176. /**
  14177. * Gets or sets the billboard mode. Default is 0.
  14178. *
  14179. * | Value | Type | Description |
  14180. * | --- | --- | --- |
  14181. * | 0 | BILLBOARDMODE_NONE | |
  14182. * | 1 | BILLBOARDMODE_X | |
  14183. * | 2 | BILLBOARDMODE_Y | |
  14184. * | 4 | BILLBOARDMODE_Z | |
  14185. * | 7 | BILLBOARDMODE_ALL | |
  14186. *
  14187. */
  14188. billboardMode: number;
  14189. private _preserveParentRotationForBillboard;
  14190. /**
  14191. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14192. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14193. */
  14194. preserveParentRotationForBillboard: boolean;
  14195. /**
  14196. * 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
  14197. */
  14198. scalingDeterminant: number;
  14199. private _infiniteDistance;
  14200. /**
  14201. * Gets or sets the distance of the object to max, often used by skybox
  14202. */
  14203. infiniteDistance: boolean;
  14204. /**
  14205. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14206. * By default the system will update normals to compensate
  14207. */
  14208. ignoreNonUniformScaling: boolean;
  14209. /**
  14210. * 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
  14211. */
  14212. reIntegrateRotationIntoRotationQuaternion: boolean;
  14213. /** @hidden */
  14214. _poseMatrix: Nullable<Matrix>;
  14215. /** @hidden */
  14216. _localMatrix: Matrix;
  14217. private _usePivotMatrix;
  14218. private _absolutePosition;
  14219. private _absoluteScaling;
  14220. private _absoluteRotationQuaternion;
  14221. private _pivotMatrix;
  14222. private _pivotMatrixInverse;
  14223. protected _postMultiplyPivotMatrix: boolean;
  14224. protected _isWorldMatrixFrozen: boolean;
  14225. /** @hidden */
  14226. _indexInSceneTransformNodesArray: number;
  14227. /**
  14228. * An event triggered after the world matrix is updated
  14229. */
  14230. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14231. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14232. /**
  14233. * Gets a string identifying the name of the class
  14234. * @returns "TransformNode" string
  14235. */
  14236. getClassName(): string;
  14237. /**
  14238. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14239. */
  14240. position: Vector3;
  14241. /**
  14242. * 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)).
  14243. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14244. */
  14245. rotation: Vector3;
  14246. /**
  14247. * 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)).
  14248. */
  14249. scaling: Vector3;
  14250. /**
  14251. * 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).
  14252. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14253. */
  14254. rotationQuaternion: Nullable<Quaternion>;
  14255. /**
  14256. * The forward direction of that transform in world space.
  14257. */
  14258. readonly forward: Vector3;
  14259. /**
  14260. * The up direction of that transform in world space.
  14261. */
  14262. readonly up: Vector3;
  14263. /**
  14264. * The right direction of that transform in world space.
  14265. */
  14266. readonly right: Vector3;
  14267. /**
  14268. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14269. * @param matrix the matrix to copy the pose from
  14270. * @returns this TransformNode.
  14271. */
  14272. updatePoseMatrix(matrix: Matrix): TransformNode;
  14273. /**
  14274. * Returns the mesh Pose matrix.
  14275. * @returns the pose matrix
  14276. */
  14277. getPoseMatrix(): Matrix;
  14278. /** @hidden */
  14279. _isSynchronized(): boolean;
  14280. /** @hidden */
  14281. _initCache(): void;
  14282. /**
  14283. * Flag the transform node as dirty (Forcing it to update everything)
  14284. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14285. * @returns this transform node
  14286. */
  14287. markAsDirty(property: string): TransformNode;
  14288. /**
  14289. * Returns the current mesh absolute position.
  14290. * Returns a Vector3.
  14291. */
  14292. readonly absolutePosition: Vector3;
  14293. /**
  14294. * Returns the current mesh absolute scaling.
  14295. * Returns a Vector3.
  14296. */
  14297. readonly absoluteScaling: Vector3;
  14298. /**
  14299. * Returns the current mesh absolute rotation.
  14300. * Returns a Quaternion.
  14301. */
  14302. readonly absoluteRotationQuaternion: Quaternion;
  14303. /**
  14304. * Sets a new matrix to apply before all other transformation
  14305. * @param matrix defines the transform matrix
  14306. * @returns the current TransformNode
  14307. */
  14308. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14309. /**
  14310. * Sets a new pivot matrix to the current node
  14311. * @param matrix defines the new pivot matrix to use
  14312. * @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
  14313. * @returns the current TransformNode
  14314. */
  14315. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14316. /**
  14317. * Returns the mesh pivot matrix.
  14318. * Default : Identity.
  14319. * @returns the matrix
  14320. */
  14321. getPivotMatrix(): Matrix;
  14322. /**
  14323. * Instantiate (when possible) or clone that node with its hierarchy
  14324. * @param newParent defines the new parent to use for the instance (or clone)
  14325. * @param options defines options to configure how copy is done
  14326. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14327. * @returns an instance (or a clone) of the current node with its hiearchy
  14328. */
  14329. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14330. doNotInstantiate: boolean;
  14331. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14332. /**
  14333. * Prevents the World matrix to be computed any longer
  14334. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14335. * @returns the TransformNode.
  14336. */
  14337. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14338. /**
  14339. * Allows back the World matrix computation.
  14340. * @returns the TransformNode.
  14341. */
  14342. unfreezeWorldMatrix(): this;
  14343. /**
  14344. * True if the World matrix has been frozen.
  14345. */
  14346. readonly isWorldMatrixFrozen: boolean;
  14347. /**
  14348. * Retuns the mesh absolute position in the World.
  14349. * @returns a Vector3.
  14350. */
  14351. getAbsolutePosition(): Vector3;
  14352. /**
  14353. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14354. * @param absolutePosition the absolute position to set
  14355. * @returns the TransformNode.
  14356. */
  14357. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14358. /**
  14359. * Sets the mesh position in its local space.
  14360. * @param vector3 the position to set in localspace
  14361. * @returns the TransformNode.
  14362. */
  14363. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14364. /**
  14365. * Returns the mesh position in the local space from the current World matrix values.
  14366. * @returns a new Vector3.
  14367. */
  14368. getPositionExpressedInLocalSpace(): Vector3;
  14369. /**
  14370. * Translates the mesh along the passed Vector3 in its local space.
  14371. * @param vector3 the distance to translate in localspace
  14372. * @returns the TransformNode.
  14373. */
  14374. locallyTranslate(vector3: Vector3): TransformNode;
  14375. private static _lookAtVectorCache;
  14376. /**
  14377. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14378. * @param targetPoint the position (must be in same space as current mesh) to look at
  14379. * @param yawCor optional yaw (y-axis) correction in radians
  14380. * @param pitchCor optional pitch (x-axis) correction in radians
  14381. * @param rollCor optional roll (z-axis) correction in radians
  14382. * @param space the choosen space of the target
  14383. * @returns the TransformNode.
  14384. */
  14385. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14386. /**
  14387. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14388. * This Vector3 is expressed in the World space.
  14389. * @param localAxis axis to rotate
  14390. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14391. */
  14392. getDirection(localAxis: Vector3): Vector3;
  14393. /**
  14394. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14395. * localAxis is expressed in the mesh local space.
  14396. * result is computed in the Wordl space from the mesh World matrix.
  14397. * @param localAxis axis to rotate
  14398. * @param result the resulting transformnode
  14399. * @returns this TransformNode.
  14400. */
  14401. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14402. /**
  14403. * Sets this transform node rotation to the given local axis.
  14404. * @param localAxis the axis in local space
  14405. * @param yawCor optional yaw (y-axis) correction in radians
  14406. * @param pitchCor optional pitch (x-axis) correction in radians
  14407. * @param rollCor optional roll (z-axis) correction in radians
  14408. * @returns this TransformNode
  14409. */
  14410. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14411. /**
  14412. * Sets a new pivot point to the current node
  14413. * @param point defines the new pivot point to use
  14414. * @param space defines if the point is in world or local space (local by default)
  14415. * @returns the current TransformNode
  14416. */
  14417. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14418. /**
  14419. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14420. * @returns the pivot point
  14421. */
  14422. getPivotPoint(): Vector3;
  14423. /**
  14424. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14425. * @param result the vector3 to store the result
  14426. * @returns this TransformNode.
  14427. */
  14428. getPivotPointToRef(result: Vector3): TransformNode;
  14429. /**
  14430. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14431. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14432. */
  14433. getAbsolutePivotPoint(): Vector3;
  14434. /**
  14435. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14436. * @param result vector3 to store the result
  14437. * @returns this TransformNode.
  14438. */
  14439. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14440. /**
  14441. * Defines the passed node as the parent of the current node.
  14442. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14443. * @see https://doc.babylonjs.com/how_to/parenting
  14444. * @param node the node ot set as the parent
  14445. * @returns this TransformNode.
  14446. */
  14447. setParent(node: Nullable<Node>): TransformNode;
  14448. private _nonUniformScaling;
  14449. /**
  14450. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14451. */
  14452. readonly nonUniformScaling: boolean;
  14453. /** @hidden */
  14454. _updateNonUniformScalingState(value: boolean): boolean;
  14455. /**
  14456. * Attach the current TransformNode to another TransformNode associated with a bone
  14457. * @param bone Bone affecting the TransformNode
  14458. * @param affectedTransformNode TransformNode associated with the bone
  14459. * @returns this object
  14460. */
  14461. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14462. /**
  14463. * Detach the transform node if its associated with a bone
  14464. * @returns this object
  14465. */
  14466. detachFromBone(): TransformNode;
  14467. private static _rotationAxisCache;
  14468. /**
  14469. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14470. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14471. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14472. * The passed axis is also normalized.
  14473. * @param axis the axis to rotate around
  14474. * @param amount the amount to rotate in radians
  14475. * @param space Space to rotate in (Default: local)
  14476. * @returns the TransformNode.
  14477. */
  14478. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14479. /**
  14480. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14481. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14482. * The passed axis is also normalized. .
  14483. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14484. * @param point the point to rotate around
  14485. * @param axis the axis to rotate around
  14486. * @param amount the amount to rotate in radians
  14487. * @returns the TransformNode
  14488. */
  14489. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14490. /**
  14491. * Translates the mesh along the axis vector for the passed distance in the given space.
  14492. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14493. * @param axis the axis to translate in
  14494. * @param distance the distance to translate
  14495. * @param space Space to rotate in (Default: local)
  14496. * @returns the TransformNode.
  14497. */
  14498. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14499. /**
  14500. * Adds a rotation step to the mesh current rotation.
  14501. * x, y, z are Euler angles expressed in radians.
  14502. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14503. * This means this rotation is made in the mesh local space only.
  14504. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14505. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14506. * ```javascript
  14507. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14508. * ```
  14509. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14510. * 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.
  14511. * @param x Rotation to add
  14512. * @param y Rotation to add
  14513. * @param z Rotation to add
  14514. * @returns the TransformNode.
  14515. */
  14516. addRotation(x: number, y: number, z: number): TransformNode;
  14517. /**
  14518. * @hidden
  14519. */
  14520. protected _getEffectiveParent(): Nullable<Node>;
  14521. /**
  14522. * Computes the world matrix of the node
  14523. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14524. * @returns the world matrix
  14525. */
  14526. computeWorldMatrix(force?: boolean): Matrix;
  14527. protected _afterComputeWorldMatrix(): void;
  14528. /**
  14529. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14530. * @param func callback function to add
  14531. *
  14532. * @returns the TransformNode.
  14533. */
  14534. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14535. /**
  14536. * Removes a registered callback function.
  14537. * @param func callback function to remove
  14538. * @returns the TransformNode.
  14539. */
  14540. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14541. /**
  14542. * Gets the position of the current mesh in camera space
  14543. * @param camera defines the camera to use
  14544. * @returns a position
  14545. */
  14546. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14547. /**
  14548. * Returns the distance from the mesh to the active camera
  14549. * @param camera defines the camera to use
  14550. * @returns the distance
  14551. */
  14552. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14553. /**
  14554. * Clone the current transform node
  14555. * @param name Name of the new clone
  14556. * @param newParent New parent for the clone
  14557. * @param doNotCloneChildren Do not clone children hierarchy
  14558. * @returns the new transform node
  14559. */
  14560. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14561. /**
  14562. * Serializes the objects information.
  14563. * @param currentSerializationObject defines the object to serialize in
  14564. * @returns the serialized object
  14565. */
  14566. serialize(currentSerializationObject?: any): any;
  14567. /**
  14568. * Returns a new TransformNode object parsed from the source provided.
  14569. * @param parsedTransformNode is the source.
  14570. * @param scene the scne the object belongs to
  14571. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14572. * @returns a new TransformNode object parsed from the source provided.
  14573. */
  14574. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14575. /**
  14576. * Get all child-transformNodes of this node
  14577. * @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
  14578. * @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
  14579. * @returns an array of TransformNode
  14580. */
  14581. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14582. /**
  14583. * Releases resources associated with this transform node.
  14584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14586. */
  14587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14588. /**
  14589. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14590. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14591. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14592. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14593. * @returns the current mesh
  14594. */
  14595. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14596. private _syncAbsoluteScalingAndRotation;
  14597. }
  14598. }
  14599. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14600. import { Observable } from "babylonjs/Misc/observable";
  14601. import { Nullable } from "babylonjs/types";
  14602. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14605. import { Ray } from "babylonjs/Culling/ray";
  14606. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14607. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14608. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14609. /**
  14610. * Defines the types of pose enabled controllers that are supported
  14611. */
  14612. export enum PoseEnabledControllerType {
  14613. /**
  14614. * HTC Vive
  14615. */
  14616. VIVE = 0,
  14617. /**
  14618. * Oculus Rift
  14619. */
  14620. OCULUS = 1,
  14621. /**
  14622. * Windows mixed reality
  14623. */
  14624. WINDOWS = 2,
  14625. /**
  14626. * Samsung gear VR
  14627. */
  14628. GEAR_VR = 3,
  14629. /**
  14630. * Google Daydream
  14631. */
  14632. DAYDREAM = 4,
  14633. /**
  14634. * Generic
  14635. */
  14636. GENERIC = 5
  14637. }
  14638. /**
  14639. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14640. */
  14641. export interface MutableGamepadButton {
  14642. /**
  14643. * Value of the button/trigger
  14644. */
  14645. value: number;
  14646. /**
  14647. * If the button/trigger is currently touched
  14648. */
  14649. touched: boolean;
  14650. /**
  14651. * If the button/trigger is currently pressed
  14652. */
  14653. pressed: boolean;
  14654. }
  14655. /**
  14656. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14657. * @hidden
  14658. */
  14659. export interface ExtendedGamepadButton extends GamepadButton {
  14660. /**
  14661. * If the button/trigger is currently pressed
  14662. */
  14663. readonly pressed: boolean;
  14664. /**
  14665. * If the button/trigger is currently touched
  14666. */
  14667. readonly touched: boolean;
  14668. /**
  14669. * Value of the button/trigger
  14670. */
  14671. readonly value: number;
  14672. }
  14673. /** @hidden */
  14674. export interface _GamePadFactory {
  14675. /**
  14676. * Returns wether or not the current gamepad can be created for this type of controller.
  14677. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14678. * @returns true if it can be created, otherwise false
  14679. */
  14680. canCreate(gamepadInfo: any): boolean;
  14681. /**
  14682. * Creates a new instance of the Gamepad.
  14683. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14684. * @returns the new gamepad instance
  14685. */
  14686. create(gamepadInfo: any): Gamepad;
  14687. }
  14688. /**
  14689. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14690. */
  14691. export class PoseEnabledControllerHelper {
  14692. /** @hidden */
  14693. static _ControllerFactories: _GamePadFactory[];
  14694. /** @hidden */
  14695. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14696. /**
  14697. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14698. * @param vrGamepad the gamepad to initialized
  14699. * @returns a vr controller of the type the gamepad identified as
  14700. */
  14701. static InitiateController(vrGamepad: any): Gamepad;
  14702. }
  14703. /**
  14704. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14705. */
  14706. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14707. /**
  14708. * If the controller is used in a webXR session
  14709. */
  14710. isXR: boolean;
  14711. private _deviceRoomPosition;
  14712. private _deviceRoomRotationQuaternion;
  14713. /**
  14714. * The device position in babylon space
  14715. */
  14716. devicePosition: Vector3;
  14717. /**
  14718. * The device rotation in babylon space
  14719. */
  14720. deviceRotationQuaternion: Quaternion;
  14721. /**
  14722. * The scale factor of the device in babylon space
  14723. */
  14724. deviceScaleFactor: number;
  14725. /**
  14726. * (Likely devicePosition should be used instead) The device position in its room space
  14727. */
  14728. position: Vector3;
  14729. /**
  14730. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14731. */
  14732. rotationQuaternion: Quaternion;
  14733. /**
  14734. * The type of controller (Eg. Windows mixed reality)
  14735. */
  14736. controllerType: PoseEnabledControllerType;
  14737. protected _calculatedPosition: Vector3;
  14738. private _calculatedRotation;
  14739. /**
  14740. * The raw pose from the device
  14741. */
  14742. rawPose: DevicePose;
  14743. private _trackPosition;
  14744. private _maxRotationDistFromHeadset;
  14745. private _draggedRoomRotation;
  14746. /**
  14747. * @hidden
  14748. */
  14749. _disableTrackPosition(fixedPosition: Vector3): void;
  14750. /**
  14751. * Internal, the mesh attached to the controller
  14752. * @hidden
  14753. */
  14754. _mesh: Nullable<AbstractMesh>;
  14755. private _poseControlledCamera;
  14756. private _leftHandSystemQuaternion;
  14757. /**
  14758. * Internal, matrix used to convert room space to babylon space
  14759. * @hidden
  14760. */
  14761. _deviceToWorld: Matrix;
  14762. /**
  14763. * Node to be used when casting a ray from the controller
  14764. * @hidden
  14765. */
  14766. _pointingPoseNode: Nullable<TransformNode>;
  14767. /**
  14768. * Name of the child mesh that can be used to cast a ray from the controller
  14769. */
  14770. static readonly POINTING_POSE: string;
  14771. /**
  14772. * Creates a new PoseEnabledController from a gamepad
  14773. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14774. */
  14775. constructor(browserGamepad: any);
  14776. private _workingMatrix;
  14777. /**
  14778. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14779. */
  14780. update(): void;
  14781. /**
  14782. * Updates only the pose device and mesh without doing any button event checking
  14783. */
  14784. protected _updatePoseAndMesh(): void;
  14785. /**
  14786. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14787. * @param poseData raw pose fromthe device
  14788. */
  14789. updateFromDevice(poseData: DevicePose): void;
  14790. /**
  14791. * @hidden
  14792. */
  14793. _meshAttachedObservable: Observable<AbstractMesh>;
  14794. /**
  14795. * Attaches a mesh to the controller
  14796. * @param mesh the mesh to be attached
  14797. */
  14798. attachToMesh(mesh: AbstractMesh): void;
  14799. /**
  14800. * Attaches the controllers mesh to a camera
  14801. * @param camera the camera the mesh should be attached to
  14802. */
  14803. attachToPoseControlledCamera(camera: TargetCamera): void;
  14804. /**
  14805. * Disposes of the controller
  14806. */
  14807. dispose(): void;
  14808. /**
  14809. * The mesh that is attached to the controller
  14810. */
  14811. readonly mesh: Nullable<AbstractMesh>;
  14812. /**
  14813. * Gets the ray of the controller in the direction the controller is pointing
  14814. * @param length the length the resulting ray should be
  14815. * @returns a ray in the direction the controller is pointing
  14816. */
  14817. getForwardRay(length?: number): Ray;
  14818. }
  14819. }
  14820. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14821. import { Observable } from "babylonjs/Misc/observable";
  14822. import { Scene } from "babylonjs/scene";
  14823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14824. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14825. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14826. import { Nullable } from "babylonjs/types";
  14827. /**
  14828. * Defines the WebVRController object that represents controllers tracked in 3D space
  14829. */
  14830. export abstract class WebVRController extends PoseEnabledController {
  14831. /**
  14832. * Internal, the default controller model for the controller
  14833. */
  14834. protected _defaultModel: Nullable<AbstractMesh>;
  14835. /**
  14836. * Fired when the trigger state has changed
  14837. */
  14838. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14839. /**
  14840. * Fired when the main button state has changed
  14841. */
  14842. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14843. /**
  14844. * Fired when the secondary button state has changed
  14845. */
  14846. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14847. /**
  14848. * Fired when the pad state has changed
  14849. */
  14850. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14851. /**
  14852. * Fired when controllers stick values have changed
  14853. */
  14854. onPadValuesChangedObservable: Observable<StickValues>;
  14855. /**
  14856. * Array of button availible on the controller
  14857. */
  14858. protected _buttons: Array<MutableGamepadButton>;
  14859. private _onButtonStateChange;
  14860. /**
  14861. * Fired when a controller button's state has changed
  14862. * @param callback the callback containing the button that was modified
  14863. */
  14864. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14865. /**
  14866. * X and Y axis corresponding to the controllers joystick
  14867. */
  14868. pad: StickValues;
  14869. /**
  14870. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14871. */
  14872. hand: string;
  14873. /**
  14874. * The default controller model for the controller
  14875. */
  14876. readonly defaultModel: Nullable<AbstractMesh>;
  14877. /**
  14878. * Creates a new WebVRController from a gamepad
  14879. * @param vrGamepad the gamepad that the WebVRController should be created from
  14880. */
  14881. constructor(vrGamepad: any);
  14882. /**
  14883. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14884. */
  14885. update(): void;
  14886. /**
  14887. * Function to be called when a button is modified
  14888. */
  14889. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14890. /**
  14891. * Loads a mesh and attaches it to the controller
  14892. * @param scene the scene the mesh should be added to
  14893. * @param meshLoaded callback for when the mesh has been loaded
  14894. */
  14895. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14896. private _setButtonValue;
  14897. private _changes;
  14898. private _checkChanges;
  14899. /**
  14900. * Disposes of th webVRCOntroller
  14901. */
  14902. dispose(): void;
  14903. }
  14904. }
  14905. declare module "babylonjs/Lights/hemisphericLight" {
  14906. import { Nullable } from "babylonjs/types";
  14907. import { Scene } from "babylonjs/scene";
  14908. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14909. import { Color3 } from "babylonjs/Maths/math.color";
  14910. import { Effect } from "babylonjs/Materials/effect";
  14911. import { Light } from "babylonjs/Lights/light";
  14912. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14913. /**
  14914. * The HemisphericLight simulates the ambient environment light,
  14915. * so the passed direction is the light reflection direction, not the incoming direction.
  14916. */
  14917. export class HemisphericLight extends Light {
  14918. /**
  14919. * The groundColor is the light in the opposite direction to the one specified during creation.
  14920. * 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.
  14921. */
  14922. groundColor: Color3;
  14923. /**
  14924. * The light reflection direction, not the incoming direction.
  14925. */
  14926. direction: Vector3;
  14927. /**
  14928. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14929. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14930. * The HemisphericLight can't cast shadows.
  14931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14932. * @param name The friendly name of the light
  14933. * @param direction The direction of the light reflection
  14934. * @param scene The scene the light belongs to
  14935. */
  14936. constructor(name: string, direction: Vector3, scene: Scene);
  14937. protected _buildUniformLayout(): void;
  14938. /**
  14939. * Returns the string "HemisphericLight".
  14940. * @return The class name
  14941. */
  14942. getClassName(): string;
  14943. /**
  14944. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14945. * Returns the updated direction.
  14946. * @param target The target the direction should point to
  14947. * @return The computed direction
  14948. */
  14949. setDirectionToTarget(target: Vector3): Vector3;
  14950. /**
  14951. * Returns the shadow generator associated to the light.
  14952. * @returns Always null for hemispheric lights because it does not support shadows.
  14953. */
  14954. getShadowGenerator(): Nullable<IShadowGenerator>;
  14955. /**
  14956. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14957. * @param effect The effect to update
  14958. * @param lightIndex The index of the light in the effect to update
  14959. * @returns The hemispheric light
  14960. */
  14961. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14962. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14963. /**
  14964. * Computes the world matrix of the node
  14965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14966. * @param useWasUpdatedFlag defines a reserved property
  14967. * @returns the world matrix
  14968. */
  14969. computeWorldMatrix(): Matrix;
  14970. /**
  14971. * Returns the integer 3.
  14972. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14973. */
  14974. getTypeID(): number;
  14975. /**
  14976. * Prepares the list of defines specific to the light type.
  14977. * @param defines the list of defines
  14978. * @param lightIndex defines the index of the light for the effect
  14979. */
  14980. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14981. }
  14982. }
  14983. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14984. /** @hidden */
  14985. export var vrMultiviewToSingleviewPixelShader: {
  14986. name: string;
  14987. shader: string;
  14988. };
  14989. }
  14990. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14992. import { Scene } from "babylonjs/scene";
  14993. /**
  14994. * Renders to multiple views with a single draw call
  14995. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14996. */
  14997. export class MultiviewRenderTarget extends RenderTargetTexture {
  14998. /**
  14999. * Creates a multiview render target
  15000. * @param scene scene used with the render target
  15001. * @param size the size of the render target (used for each view)
  15002. */
  15003. constructor(scene: Scene, size?: number | {
  15004. width: number;
  15005. height: number;
  15006. } | {
  15007. ratio: number;
  15008. });
  15009. /**
  15010. * @hidden
  15011. * @param faceIndex the face index, if its a cube texture
  15012. */
  15013. _bindFrameBuffer(faceIndex?: number): void;
  15014. /**
  15015. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15016. * @returns the view count
  15017. */
  15018. getViewCount(): number;
  15019. }
  15020. }
  15021. declare module "babylonjs/Maths/math.frustum" {
  15022. import { Matrix } from "babylonjs/Maths/math.vector";
  15023. import { DeepImmutable } from "babylonjs/types";
  15024. import { Plane } from "babylonjs/Maths/math.plane";
  15025. /**
  15026. * Represents a camera frustum
  15027. */
  15028. export class Frustum {
  15029. /**
  15030. * Gets the planes representing the frustum
  15031. * @param transform matrix to be applied to the returned planes
  15032. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15033. */
  15034. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15035. /**
  15036. * Gets the near frustum plane transformed by the transform matrix
  15037. * @param transform transformation matrix to be applied to the resulting frustum plane
  15038. * @param frustumPlane the resuling frustum plane
  15039. */
  15040. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15041. /**
  15042. * Gets the far frustum plane transformed by the transform matrix
  15043. * @param transform transformation matrix to be applied to the resulting frustum plane
  15044. * @param frustumPlane the resuling frustum plane
  15045. */
  15046. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15047. /**
  15048. * Gets the left frustum plane transformed by the transform matrix
  15049. * @param transform transformation matrix to be applied to the resulting frustum plane
  15050. * @param frustumPlane the resuling frustum plane
  15051. */
  15052. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15053. /**
  15054. * Gets the right frustum plane transformed by the transform matrix
  15055. * @param transform transformation matrix to be applied to the resulting frustum plane
  15056. * @param frustumPlane the resuling frustum plane
  15057. */
  15058. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15059. /**
  15060. * Gets the top frustum plane transformed by the transform matrix
  15061. * @param transform transformation matrix to be applied to the resulting frustum plane
  15062. * @param frustumPlane the resuling frustum plane
  15063. */
  15064. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15065. /**
  15066. * Gets the bottom frustum plane transformed by the transform matrix
  15067. * @param transform transformation matrix to be applied to the resulting frustum plane
  15068. * @param frustumPlane the resuling frustum plane
  15069. */
  15070. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15071. /**
  15072. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15073. * @param transform transformation matrix to be applied to the resulting frustum planes
  15074. * @param frustumPlanes the resuling frustum planes
  15075. */
  15076. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15077. }
  15078. }
  15079. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15080. import { Camera } from "babylonjs/Cameras/camera";
  15081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15082. import { Nullable } from "babylonjs/types";
  15083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15084. import { Matrix } from "babylonjs/Maths/math.vector";
  15085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15086. module "babylonjs/Engines/engine" {
  15087. interface Engine {
  15088. /**
  15089. * Creates a new multiview render target
  15090. * @param width defines the width of the texture
  15091. * @param height defines the height of the texture
  15092. * @returns the created multiview texture
  15093. */
  15094. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15095. /**
  15096. * Binds a multiview framebuffer to be drawn to
  15097. * @param multiviewTexture texture to bind
  15098. */
  15099. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15100. }
  15101. }
  15102. module "babylonjs/Cameras/camera" {
  15103. interface Camera {
  15104. /**
  15105. * @hidden
  15106. * 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)
  15107. */
  15108. _useMultiviewToSingleView: boolean;
  15109. /**
  15110. * @hidden
  15111. * 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)
  15112. */
  15113. _multiviewTexture: Nullable<RenderTargetTexture>;
  15114. /**
  15115. * @hidden
  15116. * ensures the multiview texture of the camera exists and has the specified width/height
  15117. * @param width height to set on the multiview texture
  15118. * @param height width to set on the multiview texture
  15119. */
  15120. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15121. }
  15122. }
  15123. module "babylonjs/scene" {
  15124. interface Scene {
  15125. /** @hidden */
  15126. _transformMatrixR: Matrix;
  15127. /** @hidden */
  15128. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15129. /** @hidden */
  15130. _createMultiviewUbo(): void;
  15131. /** @hidden */
  15132. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15133. /** @hidden */
  15134. _renderMultiviewToSingleView(camera: Camera): void;
  15135. }
  15136. }
  15137. }
  15138. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15139. import { Camera } from "babylonjs/Cameras/camera";
  15140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15141. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15142. import "babylonjs/Engines/Extensions/engine.multiview";
  15143. /**
  15144. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15145. * This will not be used for webXR as it supports displaying texture arrays directly
  15146. */
  15147. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15148. /**
  15149. * Initializes a VRMultiviewToSingleview
  15150. * @param name name of the post process
  15151. * @param camera camera to be applied to
  15152. * @param scaleFactor scaling factor to the size of the output texture
  15153. */
  15154. constructor(name: string, camera: Camera, scaleFactor: number);
  15155. }
  15156. }
  15157. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15158. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15159. import { Nullable } from "babylonjs/types";
  15160. import { Size } from "babylonjs/Maths/math.size";
  15161. import { Observable } from "babylonjs/Misc/observable";
  15162. /**
  15163. * Interface used to define additional presentation attributes
  15164. */
  15165. export interface IVRPresentationAttributes {
  15166. /**
  15167. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15168. */
  15169. highRefreshRate: boolean;
  15170. /**
  15171. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15172. */
  15173. foveationLevel: number;
  15174. }
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /** @hidden */
  15178. _vrDisplay: any;
  15179. /** @hidden */
  15180. _vrSupported: boolean;
  15181. /** @hidden */
  15182. _oldSize: Size;
  15183. /** @hidden */
  15184. _oldHardwareScaleFactor: number;
  15185. /** @hidden */
  15186. _vrExclusivePointerMode: boolean;
  15187. /** @hidden */
  15188. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15189. /** @hidden */
  15190. _onVRDisplayPointerRestricted: () => void;
  15191. /** @hidden */
  15192. _onVRDisplayPointerUnrestricted: () => void;
  15193. /** @hidden */
  15194. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15195. /** @hidden */
  15196. _onVrDisplayDisconnect: Nullable<() => void>;
  15197. /** @hidden */
  15198. _onVrDisplayPresentChange: Nullable<() => void>;
  15199. /**
  15200. * Observable signaled when VR display mode changes
  15201. */
  15202. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15203. /**
  15204. * Observable signaled when VR request present is complete
  15205. */
  15206. onVRRequestPresentComplete: Observable<boolean>;
  15207. /**
  15208. * Observable signaled when VR request present starts
  15209. */
  15210. onVRRequestPresentStart: Observable<Engine>;
  15211. /**
  15212. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15213. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15214. */
  15215. isInVRExclusivePointerMode: boolean;
  15216. /**
  15217. * Gets a boolean indicating if a webVR device was detected
  15218. * @returns true if a webVR device was detected
  15219. */
  15220. isVRDevicePresent(): boolean;
  15221. /**
  15222. * Gets the current webVR device
  15223. * @returns the current webVR device (or null)
  15224. */
  15225. getVRDevice(): any;
  15226. /**
  15227. * Initializes a webVR display and starts listening to display change events
  15228. * The onVRDisplayChangedObservable will be notified upon these changes
  15229. * @returns A promise containing a VRDisplay and if vr is supported
  15230. */
  15231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15232. /** @hidden */
  15233. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /**
  15235. * Gets or sets the presentation attributes used to configure VR rendering
  15236. */
  15237. vrPresentationAttributes?: IVRPresentationAttributes;
  15238. /**
  15239. * Call this function to switch to webVR mode
  15240. * Will do nothing if webVR is not supported or if there is no webVR device
  15241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. enableVR(): void;
  15244. /** @hidden */
  15245. _onVRFullScreenTriggered(): void;
  15246. }
  15247. }
  15248. }
  15249. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15250. import { Nullable } from "babylonjs/types";
  15251. import { Observable } from "babylonjs/Misc/observable";
  15252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15253. import { Scene } from "babylonjs/scene";
  15254. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15255. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15256. import { Node } from "babylonjs/node";
  15257. import { Ray } from "babylonjs/Culling/ray";
  15258. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15259. import "babylonjs/Engines/Extensions/engine.webVR";
  15260. /**
  15261. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15262. * IMPORTANT!! The data is right-hand data.
  15263. * @export
  15264. * @interface DevicePose
  15265. */
  15266. export interface DevicePose {
  15267. /**
  15268. * The position of the device, values in array are [x,y,z].
  15269. */
  15270. readonly position: Nullable<Float32Array>;
  15271. /**
  15272. * The linearVelocity of the device, values in array are [x,y,z].
  15273. */
  15274. readonly linearVelocity: Nullable<Float32Array>;
  15275. /**
  15276. * The linearAcceleration of the device, values in array are [x,y,z].
  15277. */
  15278. readonly linearAcceleration: Nullable<Float32Array>;
  15279. /**
  15280. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15281. */
  15282. readonly orientation: Nullable<Float32Array>;
  15283. /**
  15284. * The angularVelocity of the device, values in array are [x,y,z].
  15285. */
  15286. readonly angularVelocity: Nullable<Float32Array>;
  15287. /**
  15288. * The angularAcceleration of the device, values in array are [x,y,z].
  15289. */
  15290. readonly angularAcceleration: Nullable<Float32Array>;
  15291. }
  15292. /**
  15293. * Interface representing a pose controlled object in Babylon.
  15294. * A pose controlled object has both regular pose values as well as pose values
  15295. * from an external device such as a VR head mounted display
  15296. */
  15297. export interface PoseControlled {
  15298. /**
  15299. * The position of the object in babylon space.
  15300. */
  15301. position: Vector3;
  15302. /**
  15303. * The rotation quaternion of the object in babylon space.
  15304. */
  15305. rotationQuaternion: Quaternion;
  15306. /**
  15307. * The position of the device in babylon space.
  15308. */
  15309. devicePosition?: Vector3;
  15310. /**
  15311. * The rotation quaternion of the device in babylon space.
  15312. */
  15313. deviceRotationQuaternion: Quaternion;
  15314. /**
  15315. * The raw pose coming from the device.
  15316. */
  15317. rawPose: Nullable<DevicePose>;
  15318. /**
  15319. * The scale of the device to be used when translating from device space to babylon space.
  15320. */
  15321. deviceScaleFactor: number;
  15322. /**
  15323. * Updates the poseControlled values based on the input device pose.
  15324. * @param poseData the pose data to update the object with
  15325. */
  15326. updateFromDevice(poseData: DevicePose): void;
  15327. }
  15328. /**
  15329. * Set of options to customize the webVRCamera
  15330. */
  15331. export interface WebVROptions {
  15332. /**
  15333. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15334. */
  15335. trackPosition?: boolean;
  15336. /**
  15337. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15338. */
  15339. positionScale?: number;
  15340. /**
  15341. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15342. */
  15343. displayName?: string;
  15344. /**
  15345. * Should the native controller meshes be initialized. (default: true)
  15346. */
  15347. controllerMeshes?: boolean;
  15348. /**
  15349. * Creating a default HemiLight only on controllers. (default: true)
  15350. */
  15351. defaultLightingOnControllers?: boolean;
  15352. /**
  15353. * If you don't want to use the default VR button of the helper. (default: false)
  15354. */
  15355. useCustomVRButton?: boolean;
  15356. /**
  15357. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15358. */
  15359. customVRButton?: HTMLButtonElement;
  15360. /**
  15361. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15362. */
  15363. rayLength?: number;
  15364. /**
  15365. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15366. */
  15367. defaultHeight?: number;
  15368. /**
  15369. * If multiview should be used if availible (default: false)
  15370. */
  15371. useMultiview?: boolean;
  15372. }
  15373. /**
  15374. * This represents a WebVR camera.
  15375. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15376. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15377. */
  15378. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15379. private webVROptions;
  15380. /**
  15381. * @hidden
  15382. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15383. */
  15384. _vrDevice: any;
  15385. /**
  15386. * The rawPose of the vrDevice.
  15387. */
  15388. rawPose: Nullable<DevicePose>;
  15389. private _onVREnabled;
  15390. private _specsVersion;
  15391. private _attached;
  15392. private _frameData;
  15393. protected _descendants: Array<Node>;
  15394. private _deviceRoomPosition;
  15395. /** @hidden */
  15396. _deviceRoomRotationQuaternion: Quaternion;
  15397. private _standingMatrix;
  15398. /**
  15399. * Represents device position in babylon space.
  15400. */
  15401. devicePosition: Vector3;
  15402. /**
  15403. * Represents device rotation in babylon space.
  15404. */
  15405. deviceRotationQuaternion: Quaternion;
  15406. /**
  15407. * The scale of the device to be used when translating from device space to babylon space.
  15408. */
  15409. deviceScaleFactor: number;
  15410. private _deviceToWorld;
  15411. private _worldToDevice;
  15412. /**
  15413. * References to the webVR controllers for the vrDevice.
  15414. */
  15415. controllers: Array<WebVRController>;
  15416. /**
  15417. * Emits an event when a controller is attached.
  15418. */
  15419. onControllersAttachedObservable: Observable<WebVRController[]>;
  15420. /**
  15421. * Emits an event when a controller's mesh has been loaded;
  15422. */
  15423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15424. /**
  15425. * Emits an event when the HMD's pose has been updated.
  15426. */
  15427. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15428. private _poseSet;
  15429. /**
  15430. * If the rig cameras be used as parent instead of this camera.
  15431. */
  15432. rigParenting: boolean;
  15433. private _lightOnControllers;
  15434. private _defaultHeight?;
  15435. /**
  15436. * Instantiates a WebVRFreeCamera.
  15437. * @param name The name of the WebVRFreeCamera
  15438. * @param position The starting anchor position for the camera
  15439. * @param scene The scene the camera belongs to
  15440. * @param webVROptions a set of customizable options for the webVRCamera
  15441. */
  15442. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15443. /**
  15444. * Gets the device distance from the ground in meters.
  15445. * @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.
  15446. */
  15447. deviceDistanceToRoomGround(): number;
  15448. /**
  15449. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15450. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15451. */
  15452. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15453. /**
  15454. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15455. * @returns A promise with a boolean set to if the standing matrix is supported.
  15456. */
  15457. useStandingMatrixAsync(): Promise<boolean>;
  15458. /**
  15459. * Disposes the camera
  15460. */
  15461. dispose(): void;
  15462. /**
  15463. * Gets a vrController by name.
  15464. * @param name The name of the controller to retreive
  15465. * @returns the controller matching the name specified or null if not found
  15466. */
  15467. getControllerByName(name: string): Nullable<WebVRController>;
  15468. private _leftController;
  15469. /**
  15470. * The controller corresponding to the users left hand.
  15471. */
  15472. readonly leftController: Nullable<WebVRController>;
  15473. private _rightController;
  15474. /**
  15475. * The controller corresponding to the users right hand.
  15476. */
  15477. readonly rightController: Nullable<WebVRController>;
  15478. /**
  15479. * Casts a ray forward from the vrCamera's gaze.
  15480. * @param length Length of the ray (default: 100)
  15481. * @returns the ray corresponding to the gaze
  15482. */
  15483. getForwardRay(length?: number): Ray;
  15484. /**
  15485. * @hidden
  15486. * Updates the camera based on device's frame data
  15487. */
  15488. _checkInputs(): void;
  15489. /**
  15490. * Updates the poseControlled values based on the input device pose.
  15491. * @param poseData Pose coming from the device
  15492. */
  15493. updateFromDevice(poseData: DevicePose): void;
  15494. private _htmlElementAttached;
  15495. private _detachIfAttached;
  15496. /**
  15497. * WebVR's attach control will start broadcasting frames to the device.
  15498. * Note that in certain browsers (chrome for example) this function must be called
  15499. * within a user-interaction callback. Example:
  15500. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15501. *
  15502. * @param element html element to attach the vrDevice to
  15503. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15504. */
  15505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15506. /**
  15507. * Detaches the camera from the html element and disables VR
  15508. *
  15509. * @param element html element to detach from
  15510. */
  15511. detachControl(element: HTMLElement): void;
  15512. /**
  15513. * @returns the name of this class
  15514. */
  15515. getClassName(): string;
  15516. /**
  15517. * Calls resetPose on the vrDisplay
  15518. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15519. */
  15520. resetToCurrentRotation(): void;
  15521. /**
  15522. * @hidden
  15523. * Updates the rig cameras (left and right eye)
  15524. */
  15525. _updateRigCameras(): void;
  15526. private _workingVector;
  15527. private _oneVector;
  15528. private _workingMatrix;
  15529. private updateCacheCalled;
  15530. private _correctPositionIfNotTrackPosition;
  15531. /**
  15532. * @hidden
  15533. * Updates the cached values of the camera
  15534. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15535. */
  15536. _updateCache(ignoreParentClass?: boolean): void;
  15537. /**
  15538. * @hidden
  15539. * Get current device position in babylon world
  15540. */
  15541. _computeDevicePosition(): void;
  15542. /**
  15543. * Updates the current device position and rotation in the babylon world
  15544. */
  15545. update(): void;
  15546. /**
  15547. * @hidden
  15548. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15549. * @returns an identity matrix
  15550. */
  15551. _getViewMatrix(): Matrix;
  15552. private _tmpMatrix;
  15553. /**
  15554. * This function is called by the two RIG cameras.
  15555. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15556. * @hidden
  15557. */
  15558. _getWebVRViewMatrix(): Matrix;
  15559. /** @hidden */
  15560. _getWebVRProjectionMatrix(): Matrix;
  15561. private _onGamepadConnectedObserver;
  15562. private _onGamepadDisconnectedObserver;
  15563. private _updateCacheWhenTrackingDisabledObserver;
  15564. /**
  15565. * Initializes the controllers and their meshes
  15566. */
  15567. initControllers(): void;
  15568. }
  15569. }
  15570. declare module "babylonjs/PostProcesses/postProcess" {
  15571. import { Nullable } from "babylonjs/types";
  15572. import { SmartArray } from "babylonjs/Misc/smartArray";
  15573. import { Observable } from "babylonjs/Misc/observable";
  15574. import { Vector2 } from "babylonjs/Maths/math.vector";
  15575. import { Camera } from "babylonjs/Cameras/camera";
  15576. import { Effect } from "babylonjs/Materials/effect";
  15577. import "babylonjs/Shaders/postprocess.vertex";
  15578. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15579. import { Engine } from "babylonjs/Engines/engine";
  15580. import { Color4 } from "babylonjs/Maths/math.color";
  15581. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15583. /**
  15584. * Size options for a post process
  15585. */
  15586. export type PostProcessOptions = {
  15587. width: number;
  15588. height: number;
  15589. };
  15590. /**
  15591. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15592. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15593. */
  15594. export class PostProcess {
  15595. /** Name of the PostProcess. */
  15596. name: string;
  15597. /**
  15598. * Gets or sets the unique id of the post process
  15599. */
  15600. uniqueId: number;
  15601. /**
  15602. * Width of the texture to apply the post process on
  15603. */
  15604. width: number;
  15605. /**
  15606. * Height of the texture to apply the post process on
  15607. */
  15608. height: number;
  15609. /**
  15610. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15611. * @hidden
  15612. */
  15613. _outputTexture: Nullable<InternalTexture>;
  15614. /**
  15615. * Sampling mode used by the shader
  15616. * See https://doc.babylonjs.com/classes/3.1/texture
  15617. */
  15618. renderTargetSamplingMode: number;
  15619. /**
  15620. * Clear color to use when screen clearing
  15621. */
  15622. clearColor: Color4;
  15623. /**
  15624. * If the buffer needs to be cleared before applying the post process. (default: true)
  15625. * Should be set to false if shader will overwrite all previous pixels.
  15626. */
  15627. autoClear: boolean;
  15628. /**
  15629. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15630. */
  15631. alphaMode: number;
  15632. /**
  15633. * Sets the setAlphaBlendConstants of the babylon engine
  15634. */
  15635. alphaConstants: Color4;
  15636. /**
  15637. * Animations to be used for the post processing
  15638. */
  15639. animations: import("babylonjs/Animations/animation").Animation[];
  15640. /**
  15641. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15642. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15643. */
  15644. enablePixelPerfectMode: boolean;
  15645. /**
  15646. * Force the postprocess to be applied without taking in account viewport
  15647. */
  15648. forceFullscreenViewport: boolean;
  15649. /**
  15650. * List of inspectable custom properties (used by the Inspector)
  15651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15652. */
  15653. inspectableCustomProperties: IInspectable[];
  15654. /**
  15655. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15656. *
  15657. * | Value | Type | Description |
  15658. * | ----- | ----------------------------------- | ----------- |
  15659. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15660. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15661. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15662. *
  15663. */
  15664. scaleMode: number;
  15665. /**
  15666. * Force textures to be a power of two (default: false)
  15667. */
  15668. alwaysForcePOT: boolean;
  15669. private _samples;
  15670. /**
  15671. * Number of sample textures (default: 1)
  15672. */
  15673. samples: number;
  15674. /**
  15675. * Modify the scale of the post process to be the same as the viewport (default: false)
  15676. */
  15677. adaptScaleToCurrentViewport: boolean;
  15678. private _camera;
  15679. private _scene;
  15680. private _engine;
  15681. private _options;
  15682. private _reusable;
  15683. private _textureType;
  15684. /**
  15685. * Smart array of input and output textures for the post process.
  15686. * @hidden
  15687. */
  15688. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15689. /**
  15690. * The index in _textures that corresponds to the output texture.
  15691. * @hidden
  15692. */
  15693. _currentRenderTextureInd: number;
  15694. private _effect;
  15695. private _samplers;
  15696. private _fragmentUrl;
  15697. private _vertexUrl;
  15698. private _parameters;
  15699. private _scaleRatio;
  15700. protected _indexParameters: any;
  15701. private _shareOutputWithPostProcess;
  15702. private _texelSize;
  15703. private _forcedOutputTexture;
  15704. /**
  15705. * Returns the fragment url or shader name used in the post process.
  15706. * @returns the fragment url or name in the shader store.
  15707. */
  15708. getEffectName(): string;
  15709. /**
  15710. * An event triggered when the postprocess is activated.
  15711. */
  15712. onActivateObservable: Observable<Camera>;
  15713. private _onActivateObserver;
  15714. /**
  15715. * A function that is added to the onActivateObservable
  15716. */
  15717. onActivate: Nullable<(camera: Camera) => void>;
  15718. /**
  15719. * An event triggered when the postprocess changes its size.
  15720. */
  15721. onSizeChangedObservable: Observable<PostProcess>;
  15722. private _onSizeChangedObserver;
  15723. /**
  15724. * A function that is added to the onSizeChangedObservable
  15725. */
  15726. onSizeChanged: (postProcess: PostProcess) => void;
  15727. /**
  15728. * An event triggered when the postprocess applies its effect.
  15729. */
  15730. onApplyObservable: Observable<Effect>;
  15731. private _onApplyObserver;
  15732. /**
  15733. * A function that is added to the onApplyObservable
  15734. */
  15735. onApply: (effect: Effect) => void;
  15736. /**
  15737. * An event triggered before rendering the postprocess
  15738. */
  15739. onBeforeRenderObservable: Observable<Effect>;
  15740. private _onBeforeRenderObserver;
  15741. /**
  15742. * A function that is added to the onBeforeRenderObservable
  15743. */
  15744. onBeforeRender: (effect: Effect) => void;
  15745. /**
  15746. * An event triggered after rendering the postprocess
  15747. */
  15748. onAfterRenderObservable: Observable<Effect>;
  15749. private _onAfterRenderObserver;
  15750. /**
  15751. * A function that is added to the onAfterRenderObservable
  15752. */
  15753. onAfterRender: (efect: Effect) => void;
  15754. /**
  15755. * 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
  15756. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15757. */
  15758. inputTexture: InternalTexture;
  15759. /**
  15760. * Gets the camera which post process is applied to.
  15761. * @returns The camera the post process is applied to.
  15762. */
  15763. getCamera(): Camera;
  15764. /**
  15765. * Gets the texel size of the postprocess.
  15766. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15767. */
  15768. readonly texelSize: Vector2;
  15769. /**
  15770. * Creates a new instance PostProcess
  15771. * @param name The name of the PostProcess.
  15772. * @param fragmentUrl The url of the fragment shader to be used.
  15773. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15774. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15775. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15776. * @param camera The camera to apply the render pass to.
  15777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15778. * @param engine The engine which the post process will be applied. (default: current engine)
  15779. * @param reusable If the post process can be reused on the same frame. (default: false)
  15780. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15783. * @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
  15784. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15785. */
  15786. constructor(
  15787. /** Name of the PostProcess. */
  15788. 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);
  15789. /**
  15790. * Gets a string idenfifying the name of the class
  15791. * @returns "PostProcess" string
  15792. */
  15793. getClassName(): string;
  15794. /**
  15795. * Gets the engine which this post process belongs to.
  15796. * @returns The engine the post process was enabled with.
  15797. */
  15798. getEngine(): Engine;
  15799. /**
  15800. * The effect that is created when initializing the post process.
  15801. * @returns The created effect corresponding the the postprocess.
  15802. */
  15803. getEffect(): Effect;
  15804. /**
  15805. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15806. * @param postProcess The post process to share the output with.
  15807. * @returns This post process.
  15808. */
  15809. shareOutputWith(postProcess: PostProcess): PostProcess;
  15810. /**
  15811. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15812. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15813. */
  15814. useOwnOutput(): void;
  15815. /**
  15816. * Updates the effect with the current post process compile time values and recompiles the shader.
  15817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15820. * @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
  15821. * @param onCompiled Called when the shader has been compiled.
  15822. * @param onError Called if there is an error when compiling a shader.
  15823. */
  15824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15825. /**
  15826. * The post process is reusable if it can be used multiple times within one frame.
  15827. * @returns If the post process is reusable
  15828. */
  15829. isReusable(): boolean;
  15830. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15831. markTextureDirty(): void;
  15832. /**
  15833. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15834. * 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.
  15835. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15836. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15837. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15838. * @returns The target texture that was bound to be written to.
  15839. */
  15840. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15841. /**
  15842. * If the post process is supported.
  15843. */
  15844. readonly isSupported: boolean;
  15845. /**
  15846. * The aspect ratio of the output texture.
  15847. */
  15848. readonly aspectRatio: number;
  15849. /**
  15850. * Get a value indicating if the post-process is ready to be used
  15851. * @returns true if the post-process is ready (shader is compiled)
  15852. */
  15853. isReady(): boolean;
  15854. /**
  15855. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15856. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15857. */
  15858. apply(): Nullable<Effect>;
  15859. private _disposeTextures;
  15860. /**
  15861. * Disposes the post process.
  15862. * @param camera The camera to dispose the post process on.
  15863. */
  15864. dispose(camera?: Camera): void;
  15865. }
  15866. }
  15867. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15868. /** @hidden */
  15869. export var kernelBlurVaryingDeclaration: {
  15870. name: string;
  15871. shader: string;
  15872. };
  15873. }
  15874. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15875. /** @hidden */
  15876. export var kernelBlurFragment: {
  15877. name: string;
  15878. shader: string;
  15879. };
  15880. }
  15881. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15882. /** @hidden */
  15883. export var kernelBlurFragment2: {
  15884. name: string;
  15885. shader: string;
  15886. };
  15887. }
  15888. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15889. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15890. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15891. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15892. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15893. /** @hidden */
  15894. export var kernelBlurPixelShader: {
  15895. name: string;
  15896. shader: string;
  15897. };
  15898. }
  15899. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15900. /** @hidden */
  15901. export var kernelBlurVertex: {
  15902. name: string;
  15903. shader: string;
  15904. };
  15905. }
  15906. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15907. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15908. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15909. /** @hidden */
  15910. export var kernelBlurVertexShader: {
  15911. name: string;
  15912. shader: string;
  15913. };
  15914. }
  15915. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15916. import { Vector2 } from "babylonjs/Maths/math.vector";
  15917. import { Nullable } from "babylonjs/types";
  15918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15919. import { Camera } from "babylonjs/Cameras/camera";
  15920. import { Effect } from "babylonjs/Materials/effect";
  15921. import { Engine } from "babylonjs/Engines/engine";
  15922. import "babylonjs/Shaders/kernelBlur.fragment";
  15923. import "babylonjs/Shaders/kernelBlur.vertex";
  15924. /**
  15925. * The Blur Post Process which blurs an image based on a kernel and direction.
  15926. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15927. */
  15928. export class BlurPostProcess extends PostProcess {
  15929. /** The direction in which to blur the image. */
  15930. direction: Vector2;
  15931. private blockCompilation;
  15932. protected _kernel: number;
  15933. protected _idealKernel: number;
  15934. protected _packedFloat: boolean;
  15935. private _staticDefines;
  15936. /**
  15937. * Sets the length in pixels of the blur sample region
  15938. */
  15939. /**
  15940. * Gets the length in pixels of the blur sample region
  15941. */
  15942. kernel: number;
  15943. /**
  15944. * Sets wether or not the blur needs to unpack/repack floats
  15945. */
  15946. /**
  15947. * Gets wether or not the blur is unpacking/repacking floats
  15948. */
  15949. packedFloat: boolean;
  15950. /**
  15951. * Creates a new instance BlurPostProcess
  15952. * @param name The name of the effect.
  15953. * @param direction The direction in which to blur the image.
  15954. * @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.
  15955. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15956. * @param camera The camera to apply the render pass to.
  15957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15958. * @param engine The engine which the post process will be applied. (default: current engine)
  15959. * @param reusable If the post process can be reused on the same frame. (default: false)
  15960. * @param textureType Type of textures used when performing the post process. (default: 0)
  15961. * @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)
  15962. */
  15963. constructor(name: string,
  15964. /** The direction in which to blur the image. */
  15965. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15966. /**
  15967. * Updates the effect with the current post process compile time values and recompiles the shader.
  15968. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15969. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15970. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15971. * @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
  15972. * @param onCompiled Called when the shader has been compiled.
  15973. * @param onError Called if there is an error when compiling a shader.
  15974. */
  15975. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15976. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15977. /**
  15978. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15979. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15980. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15981. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15982. * The gaps between physical kernels are compensated for in the weighting of the samples
  15983. * @param idealKernel Ideal blur kernel.
  15984. * @return Nearest best kernel.
  15985. */
  15986. protected _nearestBestKernel(idealKernel: number): number;
  15987. /**
  15988. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15989. * @param x The point on the Gaussian distribution to sample.
  15990. * @return the value of the Gaussian function at x.
  15991. */
  15992. protected _gaussianWeight(x: number): number;
  15993. /**
  15994. * Generates a string that can be used as a floating point number in GLSL.
  15995. * @param x Value to print.
  15996. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15997. * @return GLSL float string.
  15998. */
  15999. protected _glslFloat(x: number, decimalFigures?: number): string;
  16000. }
  16001. }
  16002. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16003. import { Scene } from "babylonjs/scene";
  16004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16005. import { Plane } from "babylonjs/Maths/math.plane";
  16006. /**
  16007. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16008. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16009. * You can then easily use it as a reflectionTexture on a flat surface.
  16010. * In case the surface is not a plane, please consider relying on reflection probes.
  16011. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16012. */
  16013. export class MirrorTexture extends RenderTargetTexture {
  16014. private scene;
  16015. /**
  16016. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16017. * 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.
  16018. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16019. */
  16020. mirrorPlane: Plane;
  16021. /**
  16022. * Define the blur ratio used to blur the reflection if needed.
  16023. */
  16024. blurRatio: number;
  16025. /**
  16026. * Define the adaptive blur kernel used to blur the reflection if needed.
  16027. * This will autocompute the closest best match for the `blurKernel`
  16028. */
  16029. adaptiveBlurKernel: number;
  16030. /**
  16031. * Define the blur kernel used to blur the reflection if needed.
  16032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16033. */
  16034. blurKernel: number;
  16035. /**
  16036. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16038. */
  16039. blurKernelX: number;
  16040. /**
  16041. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16042. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16043. */
  16044. blurKernelY: number;
  16045. private _autoComputeBlurKernel;
  16046. protected _onRatioRescale(): void;
  16047. private _updateGammaSpace;
  16048. private _imageProcessingConfigChangeObserver;
  16049. private _transformMatrix;
  16050. private _mirrorMatrix;
  16051. private _savedViewMatrix;
  16052. private _blurX;
  16053. private _blurY;
  16054. private _adaptiveBlurKernel;
  16055. private _blurKernelX;
  16056. private _blurKernelY;
  16057. private _blurRatio;
  16058. /**
  16059. * Instantiates a Mirror Texture.
  16060. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16061. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16062. * You can then easily use it as a reflectionTexture on a flat surface.
  16063. * In case the surface is not a plane, please consider relying on reflection probes.
  16064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16065. * @param name
  16066. * @param size
  16067. * @param scene
  16068. * @param generateMipMaps
  16069. * @param type
  16070. * @param samplingMode
  16071. * @param generateDepthBuffer
  16072. */
  16073. constructor(name: string, size: number | {
  16074. width: number;
  16075. height: number;
  16076. } | {
  16077. ratio: number;
  16078. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16079. private _preparePostProcesses;
  16080. /**
  16081. * Clone the mirror texture.
  16082. * @returns the cloned texture
  16083. */
  16084. clone(): MirrorTexture;
  16085. /**
  16086. * Serialize the texture to a JSON representation you could use in Parse later on
  16087. * @returns the serialized JSON representation
  16088. */
  16089. serialize(): any;
  16090. /**
  16091. * Dispose the texture and release its associated resources.
  16092. */
  16093. dispose(): void;
  16094. }
  16095. }
  16096. declare module "babylonjs/Materials/Textures/texture" {
  16097. import { Observable } from "babylonjs/Misc/observable";
  16098. import { Nullable } from "babylonjs/types";
  16099. import { Matrix } from "babylonjs/Maths/math.vector";
  16100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16101. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16102. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16103. import { Scene } from "babylonjs/scene";
  16104. /**
  16105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16107. */
  16108. export class Texture extends BaseTexture {
  16109. /**
  16110. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16111. */
  16112. static SerializeBuffers: boolean;
  16113. /** @hidden */
  16114. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16115. /** @hidden */
  16116. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16117. /** @hidden */
  16118. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16119. /** nearest is mag = nearest and min = nearest and mip = linear */
  16120. static readonly NEAREST_SAMPLINGMODE: number;
  16121. /** nearest is mag = nearest and min = nearest and mip = linear */
  16122. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16123. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16124. static readonly BILINEAR_SAMPLINGMODE: number;
  16125. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16126. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16127. /** Trilinear is mag = linear and min = linear and mip = linear */
  16128. static readonly TRILINEAR_SAMPLINGMODE: number;
  16129. /** Trilinear is mag = linear and min = linear and mip = linear */
  16130. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16131. /** mag = nearest and min = nearest and mip = nearest */
  16132. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16133. /** mag = nearest and min = linear and mip = nearest */
  16134. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16135. /** mag = nearest and min = linear and mip = linear */
  16136. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16137. /** mag = nearest and min = linear and mip = none */
  16138. static readonly NEAREST_LINEAR: number;
  16139. /** mag = nearest and min = nearest and mip = none */
  16140. static readonly NEAREST_NEAREST: number;
  16141. /** mag = linear and min = nearest and mip = nearest */
  16142. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16143. /** mag = linear and min = nearest and mip = linear */
  16144. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16145. /** mag = linear and min = linear and mip = none */
  16146. static readonly LINEAR_LINEAR: number;
  16147. /** mag = linear and min = nearest and mip = none */
  16148. static readonly LINEAR_NEAREST: number;
  16149. /** Explicit coordinates mode */
  16150. static readonly EXPLICIT_MODE: number;
  16151. /** Spherical coordinates mode */
  16152. static readonly SPHERICAL_MODE: number;
  16153. /** Planar coordinates mode */
  16154. static readonly PLANAR_MODE: number;
  16155. /** Cubic coordinates mode */
  16156. static readonly CUBIC_MODE: number;
  16157. /** Projection coordinates mode */
  16158. static readonly PROJECTION_MODE: number;
  16159. /** Inverse Cubic coordinates mode */
  16160. static readonly SKYBOX_MODE: number;
  16161. /** Inverse Cubic coordinates mode */
  16162. static readonly INVCUBIC_MODE: number;
  16163. /** Equirectangular coordinates mode */
  16164. static readonly EQUIRECTANGULAR_MODE: number;
  16165. /** Equirectangular Fixed coordinates mode */
  16166. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16167. /** Equirectangular Fixed Mirrored coordinates mode */
  16168. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16169. /** Texture is not repeating outside of 0..1 UVs */
  16170. static readonly CLAMP_ADDRESSMODE: number;
  16171. /** Texture is repeating outside of 0..1 UVs */
  16172. static readonly WRAP_ADDRESSMODE: number;
  16173. /** Texture is repeating and mirrored */
  16174. static readonly MIRROR_ADDRESSMODE: number;
  16175. /**
  16176. * 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
  16177. */
  16178. static UseSerializedUrlIfAny: boolean;
  16179. /**
  16180. * Define the url of the texture.
  16181. */
  16182. url: Nullable<string>;
  16183. /**
  16184. * Define an offset on the texture to offset the u coordinates of the UVs
  16185. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16186. */
  16187. uOffset: number;
  16188. /**
  16189. * Define an offset on the texture to offset the v coordinates of the UVs
  16190. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16191. */
  16192. vOffset: number;
  16193. /**
  16194. * Define an offset on the texture to scale the u coordinates of the UVs
  16195. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16196. */
  16197. uScale: number;
  16198. /**
  16199. * Define an offset on the texture to scale the v coordinates of the UVs
  16200. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16201. */
  16202. vScale: number;
  16203. /**
  16204. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16205. * @see http://doc.babylonjs.com/how_to/more_materials
  16206. */
  16207. uAng: number;
  16208. /**
  16209. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16210. * @see http://doc.babylonjs.com/how_to/more_materials
  16211. */
  16212. vAng: number;
  16213. /**
  16214. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16215. * @see http://doc.babylonjs.com/how_to/more_materials
  16216. */
  16217. wAng: number;
  16218. /**
  16219. * Defines the center of rotation (U)
  16220. */
  16221. uRotationCenter: number;
  16222. /**
  16223. * Defines the center of rotation (V)
  16224. */
  16225. vRotationCenter: number;
  16226. /**
  16227. * Defines the center of rotation (W)
  16228. */
  16229. wRotationCenter: number;
  16230. /**
  16231. * Are mip maps generated for this texture or not.
  16232. */
  16233. readonly noMipmap: boolean;
  16234. /**
  16235. * List of inspectable custom properties (used by the Inspector)
  16236. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16237. */
  16238. inspectableCustomProperties: Nullable<IInspectable[]>;
  16239. private _noMipmap;
  16240. /** @hidden */
  16241. _invertY: boolean;
  16242. private _rowGenerationMatrix;
  16243. private _cachedTextureMatrix;
  16244. private _projectionModeMatrix;
  16245. private _t0;
  16246. private _t1;
  16247. private _t2;
  16248. private _cachedUOffset;
  16249. private _cachedVOffset;
  16250. private _cachedUScale;
  16251. private _cachedVScale;
  16252. private _cachedUAng;
  16253. private _cachedVAng;
  16254. private _cachedWAng;
  16255. private _cachedProjectionMatrixId;
  16256. private _cachedCoordinatesMode;
  16257. /** @hidden */
  16258. protected _initialSamplingMode: number;
  16259. /** @hidden */
  16260. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16261. private _deleteBuffer;
  16262. protected _format: Nullable<number>;
  16263. private _delayedOnLoad;
  16264. private _delayedOnError;
  16265. private _mimeType?;
  16266. /**
  16267. * Observable triggered once the texture has been loaded.
  16268. */
  16269. onLoadObservable: Observable<Texture>;
  16270. protected _isBlocking: boolean;
  16271. /**
  16272. * Is the texture preventing material to render while loading.
  16273. * If false, a default texture will be used instead of the loading one during the preparation step.
  16274. */
  16275. isBlocking: boolean;
  16276. /**
  16277. * Get the current sampling mode associated with the texture.
  16278. */
  16279. readonly samplingMode: number;
  16280. /**
  16281. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16282. */
  16283. readonly invertY: boolean;
  16284. /**
  16285. * Instantiates a new texture.
  16286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16287. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16288. * @param url defines the url of the picture to load as a texture
  16289. * @param scene defines the scene or engine the texture will belong to
  16290. * @param noMipmap defines if the texture will require mip maps or not
  16291. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16292. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16293. * @param onLoad defines a callback triggered when the texture has been loaded
  16294. * @param onError defines a callback triggered when an error occurred during the loading session
  16295. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16296. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16297. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16298. * @param mimeType defines an optional mime type information
  16299. */
  16300. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16301. /**
  16302. * Update the url (and optional buffer) of this texture if url was null during construction.
  16303. * @param url the url of the texture
  16304. * @param buffer the buffer of the texture (defaults to null)
  16305. * @param onLoad callback called when the texture is loaded (defaults to null)
  16306. */
  16307. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16308. /**
  16309. * Finish the loading sequence of a texture flagged as delayed load.
  16310. * @hidden
  16311. */
  16312. delayLoad(): void;
  16313. private _prepareRowForTextureGeneration;
  16314. /**
  16315. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16316. * @returns the transform matrix of the texture.
  16317. */
  16318. getTextureMatrix(): Matrix;
  16319. /**
  16320. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16321. * @returns The reflection texture transform
  16322. */
  16323. getReflectionTextureMatrix(): Matrix;
  16324. /**
  16325. * Clones the texture.
  16326. * @returns the cloned texture
  16327. */
  16328. clone(): Texture;
  16329. /**
  16330. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16331. * @returns The JSON representation of the texture
  16332. */
  16333. serialize(): any;
  16334. /**
  16335. * Get the current class name of the texture useful for serialization or dynamic coding.
  16336. * @returns "Texture"
  16337. */
  16338. getClassName(): string;
  16339. /**
  16340. * Dispose the texture and release its associated resources.
  16341. */
  16342. dispose(): void;
  16343. /**
  16344. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16345. * @param parsedTexture Define the JSON representation of the texture
  16346. * @param scene Define the scene the parsed texture should be instantiated in
  16347. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16348. * @returns The parsed texture if successful
  16349. */
  16350. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16351. /**
  16352. * Creates a texture from its base 64 representation.
  16353. * @param data Define the base64 payload without the data: prefix
  16354. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16355. * @param scene Define the scene the texture should belong to
  16356. * @param noMipmap Forces the texture to not create mip map information if true
  16357. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16358. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16359. * @param onLoad define a callback triggered when the texture has been loaded
  16360. * @param onError define a callback triggered when an error occurred during the loading session
  16361. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16362. * @returns the created texture
  16363. */
  16364. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16365. /**
  16366. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16367. * @param data Define the base64 payload without the data: prefix
  16368. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16369. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16370. * @param scene Define the scene the texture should belong to
  16371. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16372. * @param noMipmap Forces the texture to not create mip map information if true
  16373. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16374. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16375. * @param onLoad define a callback triggered when the texture has been loaded
  16376. * @param onError define a callback triggered when an error occurred during the loading session
  16377. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16378. * @returns the created texture
  16379. */
  16380. 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;
  16381. }
  16382. }
  16383. declare module "babylonjs/PostProcesses/postProcessManager" {
  16384. import { Nullable } from "babylonjs/types";
  16385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16387. import { Scene } from "babylonjs/scene";
  16388. /**
  16389. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16391. */
  16392. export class PostProcessManager {
  16393. private _scene;
  16394. private _indexBuffer;
  16395. private _vertexBuffers;
  16396. /**
  16397. * Creates a new instance PostProcess
  16398. * @param scene The scene that the post process is associated with.
  16399. */
  16400. constructor(scene: Scene);
  16401. private _prepareBuffers;
  16402. private _buildIndexBuffer;
  16403. /**
  16404. * Rebuilds the vertex buffers of the manager.
  16405. * @hidden
  16406. */
  16407. _rebuild(): void;
  16408. /**
  16409. * Prepares a frame to be run through a post process.
  16410. * @param sourceTexture The input texture to the post procesess. (default: null)
  16411. * @param postProcesses An array of post processes to be run. (default: null)
  16412. * @returns True if the post processes were able to be run.
  16413. * @hidden
  16414. */
  16415. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16416. /**
  16417. * Manually render a set of post processes to a texture.
  16418. * @param postProcesses An array of post processes to be run.
  16419. * @param targetTexture The target texture to render to.
  16420. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16421. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16422. * @param lodLevel defines which lod of the texture to render to
  16423. */
  16424. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16425. /**
  16426. * Finalize the result of the output of the postprocesses.
  16427. * @param doNotPresent If true the result will not be displayed to the screen.
  16428. * @param targetTexture The target texture to render to.
  16429. * @param faceIndex The index of the face to bind the target texture to.
  16430. * @param postProcesses The array of post processes to render.
  16431. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16432. * @hidden
  16433. */
  16434. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16435. /**
  16436. * Disposes of the post process manager.
  16437. */
  16438. dispose(): void;
  16439. }
  16440. }
  16441. declare module "babylonjs/Misc/gradients" {
  16442. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16443. /** Interface used by value gradients (color, factor, ...) */
  16444. export interface IValueGradient {
  16445. /**
  16446. * Gets or sets the gradient value (between 0 and 1)
  16447. */
  16448. gradient: number;
  16449. }
  16450. /** Class used to store color4 gradient */
  16451. export class ColorGradient implements IValueGradient {
  16452. /**
  16453. * Gets or sets the gradient value (between 0 and 1)
  16454. */
  16455. gradient: number;
  16456. /**
  16457. * Gets or sets first associated color
  16458. */
  16459. color1: Color4;
  16460. /**
  16461. * Gets or sets second associated color
  16462. */
  16463. color2?: Color4;
  16464. /**
  16465. * Will get a color picked randomly between color1 and color2.
  16466. * If color2 is undefined then color1 will be used
  16467. * @param result defines the target Color4 to store the result in
  16468. */
  16469. getColorToRef(result: Color4): void;
  16470. }
  16471. /** Class used to store color 3 gradient */
  16472. export class Color3Gradient implements IValueGradient {
  16473. /**
  16474. * Gets or sets the gradient value (between 0 and 1)
  16475. */
  16476. gradient: number;
  16477. /**
  16478. * Gets or sets the associated color
  16479. */
  16480. color: Color3;
  16481. }
  16482. /** Class used to store factor gradient */
  16483. export class FactorGradient implements IValueGradient {
  16484. /**
  16485. * Gets or sets the gradient value (between 0 and 1)
  16486. */
  16487. gradient: number;
  16488. /**
  16489. * Gets or sets first associated factor
  16490. */
  16491. factor1: number;
  16492. /**
  16493. * Gets or sets second associated factor
  16494. */
  16495. factor2?: number;
  16496. /**
  16497. * Will get a number picked randomly between factor1 and factor2.
  16498. * If factor2 is undefined then factor1 will be used
  16499. * @returns the picked number
  16500. */
  16501. getFactor(): number;
  16502. }
  16503. /**
  16504. * Helper used to simplify some generic gradient tasks
  16505. */
  16506. export class GradientHelper {
  16507. /**
  16508. * Gets the current gradient from an array of IValueGradient
  16509. * @param ratio defines the current ratio to get
  16510. * @param gradients defines the array of IValueGradient
  16511. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16512. */
  16513. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16514. }
  16515. }
  16516. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16518. import { Nullable } from "babylonjs/types";
  16519. module "babylonjs/Engines/thinEngine" {
  16520. interface ThinEngine {
  16521. /**
  16522. * Creates a dynamic texture
  16523. * @param width defines the width of the texture
  16524. * @param height defines the height of the texture
  16525. * @param generateMipMaps defines if the engine should generate the mip levels
  16526. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16527. * @returns the dynamic texture inside an InternalTexture
  16528. */
  16529. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16530. /**
  16531. * Update the content of a dynamic texture
  16532. * @param texture defines the texture to update
  16533. * @param canvas defines the canvas containing the source
  16534. * @param invertY defines if data must be stored with Y axis inverted
  16535. * @param premulAlpha defines if alpha is stored as premultiplied
  16536. * @param format defines the format of the data
  16537. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16538. */
  16539. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16540. }
  16541. }
  16542. }
  16543. declare module "babylonjs/Misc/canvasGenerator" {
  16544. /**
  16545. * Helper class used to generate a canvas to manipulate images
  16546. */
  16547. export class CanvasGenerator {
  16548. /**
  16549. * Create a new canvas (or offscreen canvas depending on the context)
  16550. * @param width defines the expected width
  16551. * @param height defines the expected height
  16552. * @return a new canvas or offscreen canvas
  16553. */
  16554. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16555. }
  16556. }
  16557. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16558. import { Scene } from "babylonjs/scene";
  16559. import { Texture } from "babylonjs/Materials/Textures/texture";
  16560. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16561. /**
  16562. * A class extending Texture allowing drawing on a texture
  16563. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16564. */
  16565. export class DynamicTexture extends Texture {
  16566. private _generateMipMaps;
  16567. private _canvas;
  16568. private _context;
  16569. private _engine;
  16570. /**
  16571. * Creates a DynamicTexture
  16572. * @param name defines the name of the texture
  16573. * @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
  16574. * @param scene defines the scene where you want the texture
  16575. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16576. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16577. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16578. */
  16579. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16580. /**
  16581. * Get the current class name of the texture useful for serialization or dynamic coding.
  16582. * @returns "DynamicTexture"
  16583. */
  16584. getClassName(): string;
  16585. /**
  16586. * Gets the current state of canRescale
  16587. */
  16588. readonly canRescale: boolean;
  16589. private _recreate;
  16590. /**
  16591. * Scales the texture
  16592. * @param ratio the scale factor to apply to both width and height
  16593. */
  16594. scale(ratio: number): void;
  16595. /**
  16596. * Resizes the texture
  16597. * @param width the new width
  16598. * @param height the new height
  16599. */
  16600. scaleTo(width: number, height: number): void;
  16601. /**
  16602. * Gets the context of the canvas used by the texture
  16603. * @returns the canvas context of the dynamic texture
  16604. */
  16605. getContext(): CanvasRenderingContext2D;
  16606. /**
  16607. * Clears the texture
  16608. */
  16609. clear(): void;
  16610. /**
  16611. * Updates the texture
  16612. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16613. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16614. */
  16615. update(invertY?: boolean, premulAlpha?: boolean): void;
  16616. /**
  16617. * Draws text onto the texture
  16618. * @param text defines the text to be drawn
  16619. * @param x defines the placement of the text from the left
  16620. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16621. * @param font defines the font to be used with font-style, font-size, font-name
  16622. * @param color defines the color used for the text
  16623. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16624. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16625. * @param update defines whether texture is immediately update (default is true)
  16626. */
  16627. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16628. /**
  16629. * Clones the texture
  16630. * @returns the clone of the texture.
  16631. */
  16632. clone(): DynamicTexture;
  16633. /**
  16634. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16635. * @returns a serialized dynamic texture object
  16636. */
  16637. serialize(): any;
  16638. /** @hidden */
  16639. _rebuild(): void;
  16640. }
  16641. }
  16642. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16643. import { Scene } from "babylonjs/scene";
  16644. import { ISceneComponent } from "babylonjs/sceneComponent";
  16645. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16646. module "babylonjs/abstractScene" {
  16647. interface AbstractScene {
  16648. /**
  16649. * The list of procedural textures added to the scene
  16650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16651. */
  16652. proceduralTextures: Array<ProceduralTexture>;
  16653. }
  16654. }
  16655. /**
  16656. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16657. * in a given scene.
  16658. */
  16659. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16660. /**
  16661. * The component name helpfull to identify the component in the list of scene components.
  16662. */
  16663. readonly name: string;
  16664. /**
  16665. * The scene the component belongs to.
  16666. */
  16667. scene: Scene;
  16668. /**
  16669. * Creates a new instance of the component for the given scene
  16670. * @param scene Defines the scene to register the component in
  16671. */
  16672. constructor(scene: Scene);
  16673. /**
  16674. * Registers the component in a given scene
  16675. */
  16676. register(): void;
  16677. /**
  16678. * Rebuilds the elements related to this component in case of
  16679. * context lost for instance.
  16680. */
  16681. rebuild(): void;
  16682. /**
  16683. * Disposes the component and the associated ressources.
  16684. */
  16685. dispose(): void;
  16686. private _beforeClear;
  16687. }
  16688. }
  16689. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16691. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16692. module "babylonjs/Engines/thinEngine" {
  16693. interface ThinEngine {
  16694. /**
  16695. * Creates a new render target cube texture
  16696. * @param size defines the size of the texture
  16697. * @param options defines the options used to create the texture
  16698. * @returns a new render target cube texture stored in an InternalTexture
  16699. */
  16700. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16701. }
  16702. }
  16703. }
  16704. declare module "babylonjs/Shaders/procedural.vertex" {
  16705. /** @hidden */
  16706. export var proceduralVertexShader: {
  16707. name: string;
  16708. shader: string;
  16709. };
  16710. }
  16711. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16712. import { Observable } from "babylonjs/Misc/observable";
  16713. import { Nullable } from "babylonjs/types";
  16714. import { Scene } from "babylonjs/scene";
  16715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16716. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16717. import { Effect } from "babylonjs/Materials/effect";
  16718. import { Texture } from "babylonjs/Materials/Textures/texture";
  16719. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16720. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16721. import "babylonjs/Shaders/procedural.vertex";
  16722. /**
  16723. * 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.
  16724. * This is the base class of any Procedural texture and contains most of the shareable code.
  16725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16726. */
  16727. export class ProceduralTexture extends Texture {
  16728. isCube: boolean;
  16729. /**
  16730. * Define if the texture is enabled or not (disabled texture will not render)
  16731. */
  16732. isEnabled: boolean;
  16733. /**
  16734. * Define if the texture must be cleared before rendering (default is true)
  16735. */
  16736. autoClear: boolean;
  16737. /**
  16738. * Callback called when the texture is generated
  16739. */
  16740. onGenerated: () => void;
  16741. /**
  16742. * Event raised when the texture is generated
  16743. */
  16744. onGeneratedObservable: Observable<ProceduralTexture>;
  16745. /** @hidden */
  16746. _generateMipMaps: boolean;
  16747. /** @hidden **/
  16748. _effect: Effect;
  16749. /** @hidden */
  16750. _textures: {
  16751. [key: string]: Texture;
  16752. };
  16753. private _size;
  16754. private _currentRefreshId;
  16755. private _refreshRate;
  16756. private _vertexBuffers;
  16757. private _indexBuffer;
  16758. private _uniforms;
  16759. private _samplers;
  16760. private _fragment;
  16761. private _floats;
  16762. private _ints;
  16763. private _floatsArrays;
  16764. private _colors3;
  16765. private _colors4;
  16766. private _vectors2;
  16767. private _vectors3;
  16768. private _matrices;
  16769. private _fallbackTexture;
  16770. private _fallbackTextureUsed;
  16771. private _engine;
  16772. private _cachedDefines;
  16773. private _contentUpdateId;
  16774. private _contentData;
  16775. /**
  16776. * Instantiates a new procedural texture.
  16777. * 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.
  16778. * This is the base class of any Procedural texture and contains most of the shareable code.
  16779. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16780. * @param name Define the name of the texture
  16781. * @param size Define the size of the texture to create
  16782. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16783. * @param scene Define the scene the texture belongs to
  16784. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16785. * @param generateMipMaps Define if the texture should creates mip maps or not
  16786. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16787. */
  16788. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16789. /**
  16790. * The effect that is created when initializing the post process.
  16791. * @returns The created effect corresponding the the postprocess.
  16792. */
  16793. getEffect(): Effect;
  16794. /**
  16795. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16796. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16797. */
  16798. getContent(): Nullable<ArrayBufferView>;
  16799. private _createIndexBuffer;
  16800. /** @hidden */
  16801. _rebuild(): void;
  16802. /**
  16803. * Resets the texture in order to recreate its associated resources.
  16804. * This can be called in case of context loss
  16805. */
  16806. reset(): void;
  16807. protected _getDefines(): string;
  16808. /**
  16809. * Is the texture ready to be used ? (rendered at least once)
  16810. * @returns true if ready, otherwise, false.
  16811. */
  16812. isReady(): boolean;
  16813. /**
  16814. * Resets the refresh counter of the texture and start bak from scratch.
  16815. * Could be useful to regenerate the texture if it is setup to render only once.
  16816. */
  16817. resetRefreshCounter(): void;
  16818. /**
  16819. * Set the fragment shader to use in order to render the texture.
  16820. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16821. */
  16822. setFragment(fragment: any): void;
  16823. /**
  16824. * Define the refresh rate of the texture or the rendering frequency.
  16825. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16826. */
  16827. refreshRate: number;
  16828. /** @hidden */
  16829. _shouldRender(): boolean;
  16830. /**
  16831. * Get the size the texture is rendering at.
  16832. * @returns the size (texture is always squared)
  16833. */
  16834. getRenderSize(): number;
  16835. /**
  16836. * Resize the texture to new value.
  16837. * @param size Define the new size the texture should have
  16838. * @param generateMipMaps Define whether the new texture should create mip maps
  16839. */
  16840. resize(size: number, generateMipMaps: boolean): void;
  16841. private _checkUniform;
  16842. /**
  16843. * Set a texture in the shader program used to render.
  16844. * @param name Define the name of the uniform samplers as defined in the shader
  16845. * @param texture Define the texture to bind to this sampler
  16846. * @return the texture itself allowing "fluent" like uniform updates
  16847. */
  16848. setTexture(name: string, texture: Texture): ProceduralTexture;
  16849. /**
  16850. * Set a float in the shader.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the texture itself allowing "fluent" like uniform updates
  16854. */
  16855. setFloat(name: string, value: number): ProceduralTexture;
  16856. /**
  16857. * Set a int in the shader.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the texture itself allowing "fluent" like uniform updates
  16861. */
  16862. setInt(name: string, value: number): ProceduralTexture;
  16863. /**
  16864. * Set an array of floats in the shader.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the texture itself allowing "fluent" like uniform updates
  16868. */
  16869. setFloats(name: string, value: number[]): ProceduralTexture;
  16870. /**
  16871. * Set a vec3 in the shader from a Color3.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the texture itself allowing "fluent" like uniform updates
  16875. */
  16876. setColor3(name: string, value: Color3): ProceduralTexture;
  16877. /**
  16878. * Set a vec4 in the shader from a Color4.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the texture itself allowing "fluent" like uniform updates
  16882. */
  16883. setColor4(name: string, value: Color4): ProceduralTexture;
  16884. /**
  16885. * Set a vec2 in the shader from a Vector2.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the texture itself allowing "fluent" like uniform updates
  16889. */
  16890. setVector2(name: string, value: Vector2): ProceduralTexture;
  16891. /**
  16892. * Set a vec3 in the shader from a Vector3.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the texture itself allowing "fluent" like uniform updates
  16896. */
  16897. setVector3(name: string, value: Vector3): ProceduralTexture;
  16898. /**
  16899. * Set a mat4 in the shader from a MAtrix.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the texture itself allowing "fluent" like uniform updates
  16903. */
  16904. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16905. /**
  16906. * Render the texture to its associated render target.
  16907. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16908. */
  16909. render(useCameraPostProcess?: boolean): void;
  16910. /**
  16911. * Clone the texture.
  16912. * @returns the cloned texture
  16913. */
  16914. clone(): ProceduralTexture;
  16915. /**
  16916. * Dispose the texture and release its asoociated resources.
  16917. */
  16918. dispose(): void;
  16919. }
  16920. }
  16921. declare module "babylonjs/Particles/baseParticleSystem" {
  16922. import { Nullable } from "babylonjs/types";
  16923. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16925. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16927. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16928. import { Scene } from "babylonjs/scene";
  16929. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16930. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16931. import { Texture } from "babylonjs/Materials/Textures/texture";
  16932. import { Color4 } from "babylonjs/Maths/math.color";
  16933. import { Animation } from "babylonjs/Animations/animation";
  16934. /**
  16935. * This represents the base class for particle system in Babylon.
  16936. * 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.
  16937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16938. * @example https://doc.babylonjs.com/babylon101/particles
  16939. */
  16940. export class BaseParticleSystem {
  16941. /**
  16942. * Source color is added to the destination color without alpha affecting the result
  16943. */
  16944. static BLENDMODE_ONEONE: number;
  16945. /**
  16946. * Blend current color and particle color using particle’s alpha
  16947. */
  16948. static BLENDMODE_STANDARD: number;
  16949. /**
  16950. * Add current color and particle color multiplied by particle’s alpha
  16951. */
  16952. static BLENDMODE_ADD: number;
  16953. /**
  16954. * Multiply current color with particle color
  16955. */
  16956. static BLENDMODE_MULTIPLY: number;
  16957. /**
  16958. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16959. */
  16960. static BLENDMODE_MULTIPLYADD: number;
  16961. /**
  16962. * List of animations used by the particle system.
  16963. */
  16964. animations: Animation[];
  16965. /**
  16966. * The id of the Particle system.
  16967. */
  16968. id: string;
  16969. /**
  16970. * The friendly name of the Particle system.
  16971. */
  16972. name: string;
  16973. /**
  16974. * The rendering group used by the Particle system to chose when to render.
  16975. */
  16976. renderingGroupId: number;
  16977. /**
  16978. * The emitter represents the Mesh or position we are attaching the particle system to.
  16979. */
  16980. emitter: Nullable<AbstractMesh | Vector3>;
  16981. /**
  16982. * The maximum number of particles to emit per frame
  16983. */
  16984. emitRate: number;
  16985. /**
  16986. * If you want to launch only a few particles at once, that can be done, as well.
  16987. */
  16988. manualEmitCount: number;
  16989. /**
  16990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16991. */
  16992. updateSpeed: number;
  16993. /**
  16994. * The amount of time the particle system is running (depends of the overall update speed).
  16995. */
  16996. targetStopDuration: number;
  16997. /**
  16998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16999. */
  17000. disposeOnStop: boolean;
  17001. /**
  17002. * Minimum power of emitting particles.
  17003. */
  17004. minEmitPower: number;
  17005. /**
  17006. * Maximum power of emitting particles.
  17007. */
  17008. maxEmitPower: number;
  17009. /**
  17010. * Minimum life time of emitting particles.
  17011. */
  17012. minLifeTime: number;
  17013. /**
  17014. * Maximum life time of emitting particles.
  17015. */
  17016. maxLifeTime: number;
  17017. /**
  17018. * Minimum Size of emitting particles.
  17019. */
  17020. minSize: number;
  17021. /**
  17022. * Maximum Size of emitting particles.
  17023. */
  17024. maxSize: number;
  17025. /**
  17026. * Minimum scale of emitting particles on X axis.
  17027. */
  17028. minScaleX: number;
  17029. /**
  17030. * Maximum scale of emitting particles on X axis.
  17031. */
  17032. maxScaleX: number;
  17033. /**
  17034. * Minimum scale of emitting particles on Y axis.
  17035. */
  17036. minScaleY: number;
  17037. /**
  17038. * Maximum scale of emitting particles on Y axis.
  17039. */
  17040. maxScaleY: number;
  17041. /**
  17042. * Gets or sets the minimal initial rotation in radians.
  17043. */
  17044. minInitialRotation: number;
  17045. /**
  17046. * Gets or sets the maximal initial rotation in radians.
  17047. */
  17048. maxInitialRotation: number;
  17049. /**
  17050. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17051. */
  17052. minAngularSpeed: number;
  17053. /**
  17054. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17055. */
  17056. maxAngularSpeed: number;
  17057. /**
  17058. * The texture used to render each particle. (this can be a spritesheet)
  17059. */
  17060. particleTexture: Nullable<Texture>;
  17061. /**
  17062. * The layer mask we are rendering the particles through.
  17063. */
  17064. layerMask: number;
  17065. /**
  17066. * This can help using your own shader to render the particle system.
  17067. * The according effect will be created
  17068. */
  17069. customShader: any;
  17070. /**
  17071. * By default particle system starts as soon as they are created. This prevents the
  17072. * automatic start to happen and let you decide when to start emitting particles.
  17073. */
  17074. preventAutoStart: boolean;
  17075. private _noiseTexture;
  17076. /**
  17077. * Gets or sets a texture used to add random noise to particle positions
  17078. */
  17079. noiseTexture: Nullable<ProceduralTexture>;
  17080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17081. noiseStrength: Vector3;
  17082. /**
  17083. * Callback triggered when the particle animation is ending.
  17084. */
  17085. onAnimationEnd: Nullable<() => void>;
  17086. /**
  17087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17088. */
  17089. blendMode: number;
  17090. /**
  17091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17092. * to override the particles.
  17093. */
  17094. forceDepthWrite: boolean;
  17095. /** 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 */
  17096. preWarmCycles: number;
  17097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17098. preWarmStepOffset: number;
  17099. /**
  17100. * 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)
  17101. */
  17102. spriteCellChangeSpeed: number;
  17103. /**
  17104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17105. */
  17106. startSpriteCellID: number;
  17107. /**
  17108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17109. */
  17110. endSpriteCellID: number;
  17111. /**
  17112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17113. */
  17114. spriteCellWidth: number;
  17115. /**
  17116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17117. */
  17118. spriteCellHeight: number;
  17119. /**
  17120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17121. */
  17122. spriteRandomStartCell: boolean;
  17123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17124. translationPivot: Vector2;
  17125. /** @hidden */
  17126. protected _isAnimationSheetEnabled: boolean;
  17127. /**
  17128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17129. */
  17130. beginAnimationOnStart: boolean;
  17131. /**
  17132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17133. */
  17134. beginAnimationFrom: number;
  17135. /**
  17136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17137. */
  17138. beginAnimationTo: number;
  17139. /**
  17140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17141. */
  17142. beginAnimationLoop: boolean;
  17143. /**
  17144. * Gets or sets a world offset applied to all particles
  17145. */
  17146. worldOffset: Vector3;
  17147. /**
  17148. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17149. */
  17150. isAnimationSheetEnabled: boolean;
  17151. /**
  17152. * Get hosting scene
  17153. * @returns the scene
  17154. */
  17155. getScene(): Scene;
  17156. /**
  17157. * You can use gravity if you want to give an orientation to your particles.
  17158. */
  17159. gravity: Vector3;
  17160. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17161. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17162. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17163. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17164. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17165. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17166. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17167. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17168. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17169. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17170. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17171. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17172. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17173. /**
  17174. * Defines the delay in milliseconds before starting the system (0 by default)
  17175. */
  17176. startDelay: number;
  17177. /**
  17178. * Gets the current list of drag gradients.
  17179. * You must use addDragGradient and removeDragGradient to udpate this list
  17180. * @returns the list of drag gradients
  17181. */
  17182. getDragGradients(): Nullable<Array<FactorGradient>>;
  17183. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17184. limitVelocityDamping: number;
  17185. /**
  17186. * Gets the current list of limit velocity gradients.
  17187. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17188. * @returns the list of limit velocity gradients
  17189. */
  17190. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17191. /**
  17192. * Gets the current list of color gradients.
  17193. * You must use addColorGradient and removeColorGradient to udpate this list
  17194. * @returns the list of color gradients
  17195. */
  17196. getColorGradients(): Nullable<Array<ColorGradient>>;
  17197. /**
  17198. * Gets the current list of size gradients.
  17199. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17200. * @returns the list of size gradients
  17201. */
  17202. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17203. /**
  17204. * Gets the current list of color remap gradients.
  17205. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17206. * @returns the list of color remap gradients
  17207. */
  17208. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17209. /**
  17210. * Gets the current list of alpha remap gradients.
  17211. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17212. * @returns the list of alpha remap gradients
  17213. */
  17214. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17215. /**
  17216. * Gets the current list of life time gradients.
  17217. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17218. * @returns the list of life time gradients
  17219. */
  17220. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17221. /**
  17222. * Gets the current list of angular speed gradients.
  17223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17224. * @returns the list of angular speed gradients
  17225. */
  17226. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17227. /**
  17228. * Gets the current list of velocity gradients.
  17229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17230. * @returns the list of velocity gradients
  17231. */
  17232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17233. /**
  17234. * Gets the current list of start size gradients.
  17235. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17236. * @returns the list of start size gradients
  17237. */
  17238. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17239. /**
  17240. * Gets the current list of emit rate gradients.
  17241. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17242. * @returns the list of emit rate gradients
  17243. */
  17244. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17245. /**
  17246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17248. */
  17249. direction1: Vector3;
  17250. /**
  17251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17252. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17253. */
  17254. direction2: Vector3;
  17255. /**
  17256. * 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.
  17257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17258. */
  17259. minEmitBox: Vector3;
  17260. /**
  17261. * 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.
  17262. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17263. */
  17264. maxEmitBox: Vector3;
  17265. /**
  17266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17267. */
  17268. color1: Color4;
  17269. /**
  17270. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17271. */
  17272. color2: Color4;
  17273. /**
  17274. * Color the particle will have at the end of its lifetime
  17275. */
  17276. colorDead: Color4;
  17277. /**
  17278. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17279. */
  17280. textureMask: Color4;
  17281. /**
  17282. * The particle emitter type defines the emitter used by the particle system.
  17283. * It can be for example box, sphere, or cone...
  17284. */
  17285. particleEmitterType: IParticleEmitterType;
  17286. /** @hidden */
  17287. _isSubEmitter: boolean;
  17288. /**
  17289. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17290. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17291. */
  17292. billboardMode: number;
  17293. protected _isBillboardBased: boolean;
  17294. /**
  17295. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17296. */
  17297. isBillboardBased: boolean;
  17298. /**
  17299. * The scene the particle system belongs to.
  17300. */
  17301. protected _scene: Scene;
  17302. /**
  17303. * Local cache of defines for image processing.
  17304. */
  17305. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17306. /**
  17307. * Default configuration related to image processing available in the standard Material.
  17308. */
  17309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17310. /**
  17311. * Gets the image processing configuration used either in this material.
  17312. */
  17313. /**
  17314. * Sets the Default image processing configuration used either in the this material.
  17315. *
  17316. * If sets to null, the scene one is in use.
  17317. */
  17318. imageProcessingConfiguration: ImageProcessingConfiguration;
  17319. /**
  17320. * Attaches a new image processing configuration to the Standard Material.
  17321. * @param configuration
  17322. */
  17323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17324. /** @hidden */
  17325. protected _reset(): void;
  17326. /** @hidden */
  17327. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17328. /**
  17329. * Instantiates a particle system.
  17330. * 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.
  17331. * @param name The name of the particle system
  17332. */
  17333. constructor(name: string);
  17334. /**
  17335. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17338. * @returns the emitter
  17339. */
  17340. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17341. /**
  17342. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17343. * @param radius The radius of the hemisphere to emit from
  17344. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17345. * @returns the emitter
  17346. */
  17347. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17348. /**
  17349. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17350. * @param radius The radius of the sphere to emit from
  17351. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17352. * @returns the emitter
  17353. */
  17354. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17355. /**
  17356. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17357. * @param radius The radius of the sphere to emit from
  17358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17360. * @returns the emitter
  17361. */
  17362. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17363. /**
  17364. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17365. * @param radius The radius of the emission cylinder
  17366. * @param height The height of the emission cylinder
  17367. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17368. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17369. * @returns the emitter
  17370. */
  17371. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17372. /**
  17373. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17374. * @param radius The radius of the cylinder to emit from
  17375. * @param height The height of the emission cylinder
  17376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17379. * @returns the emitter
  17380. */
  17381. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17382. /**
  17383. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17384. * @param radius The radius of the cone to emit from
  17385. * @param angle The base angle of the cone
  17386. * @returns the emitter
  17387. */
  17388. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17389. /**
  17390. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17391. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17392. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17393. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17394. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17395. * @returns the emitter
  17396. */
  17397. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17398. }
  17399. }
  17400. declare module "babylonjs/Particles/subEmitter" {
  17401. import { Scene } from "babylonjs/scene";
  17402. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17403. /**
  17404. * Type of sub emitter
  17405. */
  17406. export enum SubEmitterType {
  17407. /**
  17408. * Attached to the particle over it's lifetime
  17409. */
  17410. ATTACHED = 0,
  17411. /**
  17412. * Created when the particle dies
  17413. */
  17414. END = 1
  17415. }
  17416. /**
  17417. * Sub emitter class used to emit particles from an existing particle
  17418. */
  17419. export class SubEmitter {
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem;
  17424. /**
  17425. * Type of the submitter (Default: END)
  17426. */
  17427. type: SubEmitterType;
  17428. /**
  17429. * 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)
  17430. * Note: This only is supported when using an emitter of type Mesh
  17431. */
  17432. inheritDirection: boolean;
  17433. /**
  17434. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17435. */
  17436. inheritedVelocityAmount: number;
  17437. /**
  17438. * Creates a sub emitter
  17439. * @param particleSystem the particle system to be used by the sub emitter
  17440. */
  17441. constructor(
  17442. /**
  17443. * the particle system to be used by the sub emitter
  17444. */
  17445. particleSystem: ParticleSystem);
  17446. /**
  17447. * Clones the sub emitter
  17448. * @returns the cloned sub emitter
  17449. */
  17450. clone(): SubEmitter;
  17451. /**
  17452. * Serialize current object to a JSON object
  17453. * @returns the serialized object
  17454. */
  17455. serialize(): any;
  17456. /** @hidden */
  17457. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17458. /**
  17459. * Creates a new SubEmitter from a serialized JSON version
  17460. * @param serializationObject defines the JSON object to read from
  17461. * @param scene defines the hosting scene
  17462. * @param rootUrl defines the rootUrl for data loading
  17463. * @returns a new SubEmitter
  17464. */
  17465. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17466. /** Release associated resources */
  17467. dispose(): void;
  17468. }
  17469. }
  17470. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17471. /** @hidden */
  17472. export var clipPlaneFragmentDeclaration: {
  17473. name: string;
  17474. shader: string;
  17475. };
  17476. }
  17477. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17478. /** @hidden */
  17479. export var imageProcessingDeclaration: {
  17480. name: string;
  17481. shader: string;
  17482. };
  17483. }
  17484. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17485. /** @hidden */
  17486. export var imageProcessingFunctions: {
  17487. name: string;
  17488. shader: string;
  17489. };
  17490. }
  17491. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17492. /** @hidden */
  17493. export var clipPlaneFragment: {
  17494. name: string;
  17495. shader: string;
  17496. };
  17497. }
  17498. declare module "babylonjs/Shaders/particles.fragment" {
  17499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17500. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17502. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17504. /** @hidden */
  17505. export var particlesPixelShader: {
  17506. name: string;
  17507. shader: string;
  17508. };
  17509. }
  17510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17511. /** @hidden */
  17512. export var clipPlaneVertexDeclaration: {
  17513. name: string;
  17514. shader: string;
  17515. };
  17516. }
  17517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17518. /** @hidden */
  17519. export var clipPlaneVertex: {
  17520. name: string;
  17521. shader: string;
  17522. };
  17523. }
  17524. declare module "babylonjs/Shaders/particles.vertex" {
  17525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17527. /** @hidden */
  17528. export var particlesVertexShader: {
  17529. name: string;
  17530. shader: string;
  17531. };
  17532. }
  17533. declare module "babylonjs/Particles/particleSystem" {
  17534. import { Nullable } from "babylonjs/types";
  17535. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17536. import { Observable } from "babylonjs/Misc/observable";
  17537. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17538. import { Effect } from "babylonjs/Materials/effect";
  17539. import { Scene, IDisposable } from "babylonjs/scene";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17542. import { Particle } from "babylonjs/Particles/particle";
  17543. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17545. import "babylonjs/Shaders/particles.fragment";
  17546. import "babylonjs/Shaders/particles.vertex";
  17547. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17548. /**
  17549. * This represents a particle system in Babylon.
  17550. * 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.
  17551. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17552. * @example https://doc.babylonjs.com/babylon101/particles
  17553. */
  17554. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17555. /**
  17556. * Billboard mode will only apply to Y axis
  17557. */
  17558. static readonly BILLBOARDMODE_Y: number;
  17559. /**
  17560. * Billboard mode will apply to all axes
  17561. */
  17562. static readonly BILLBOARDMODE_ALL: number;
  17563. /**
  17564. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17565. */
  17566. static readonly BILLBOARDMODE_STRETCHED: number;
  17567. /**
  17568. * This function can be defined to provide custom update for active particles.
  17569. * This function will be called instead of regular update (age, position, color, etc.).
  17570. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17571. */
  17572. updateFunction: (particles: Particle[]) => void;
  17573. private _emitterWorldMatrix;
  17574. /**
  17575. * This function can be defined to specify initial direction for every new particle.
  17576. * It by default use the emitterType defined function
  17577. */
  17578. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17579. /**
  17580. * This function can be defined to specify initial position for every new particle.
  17581. * It by default use the emitterType defined function
  17582. */
  17583. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17584. /**
  17585. * @hidden
  17586. */
  17587. _inheritedVelocityOffset: Vector3;
  17588. /**
  17589. * An event triggered when the system is disposed
  17590. */
  17591. onDisposeObservable: Observable<ParticleSystem>;
  17592. private _onDisposeObserver;
  17593. /**
  17594. * Sets a callback that will be triggered when the system is disposed
  17595. */
  17596. onDispose: () => void;
  17597. private _particles;
  17598. private _epsilon;
  17599. private _capacity;
  17600. private _stockParticles;
  17601. private _newPartsExcess;
  17602. private _vertexData;
  17603. private _vertexBuffer;
  17604. private _vertexBuffers;
  17605. private _spriteBuffer;
  17606. private _indexBuffer;
  17607. private _effect;
  17608. private _customEffect;
  17609. private _cachedDefines;
  17610. private _scaledColorStep;
  17611. private _colorDiff;
  17612. private _scaledDirection;
  17613. private _scaledGravity;
  17614. private _currentRenderId;
  17615. private _alive;
  17616. private _useInstancing;
  17617. private _started;
  17618. private _stopped;
  17619. private _actualFrame;
  17620. private _scaledUpdateSpeed;
  17621. private _vertexBufferSize;
  17622. /** @hidden */
  17623. _currentEmitRateGradient: Nullable<FactorGradient>;
  17624. /** @hidden */
  17625. _currentEmitRate1: number;
  17626. /** @hidden */
  17627. _currentEmitRate2: number;
  17628. /** @hidden */
  17629. _currentStartSizeGradient: Nullable<FactorGradient>;
  17630. /** @hidden */
  17631. _currentStartSize1: number;
  17632. /** @hidden */
  17633. _currentStartSize2: number;
  17634. private readonly _rawTextureWidth;
  17635. private _rampGradientsTexture;
  17636. private _useRampGradients;
  17637. /** Gets or sets a boolean indicating that ramp gradients must be used
  17638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17639. */
  17640. useRampGradients: boolean;
  17641. /**
  17642. * 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.
  17643. * 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: [])
  17644. */
  17645. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17646. private _subEmitters;
  17647. /**
  17648. * @hidden
  17649. * If the particle systems emitter should be disposed when the particle system is disposed
  17650. */
  17651. _disposeEmitterOnDispose: boolean;
  17652. /**
  17653. * The current active Sub-systems, this property is used by the root particle system only.
  17654. */
  17655. activeSubSystems: Array<ParticleSystem>;
  17656. private _rootParticleSystem;
  17657. /**
  17658. * Gets the current list of active particles
  17659. */
  17660. readonly particles: Particle[];
  17661. /**
  17662. * Returns the string "ParticleSystem"
  17663. * @returns a string containing the class name
  17664. */
  17665. getClassName(): string;
  17666. /**
  17667. * Instantiates a particle system.
  17668. * 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.
  17669. * @param name The name of the particle system
  17670. * @param capacity The max number of particles alive at the same time
  17671. * @param scene The scene the particle system belongs to
  17672. * @param customEffect a custom effect used to change the way particles are rendered by default
  17673. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17674. * @param epsilon Offset used to render the particles
  17675. */
  17676. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17677. private _addFactorGradient;
  17678. private _removeFactorGradient;
  17679. /**
  17680. * Adds a new life time gradient
  17681. * @param gradient defines the gradient to use (between 0 and 1)
  17682. * @param factor defines the life time factor to affect to the specified gradient
  17683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17684. * @returns the current particle system
  17685. */
  17686. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17687. /**
  17688. * Remove a specific life time gradient
  17689. * @param gradient defines the gradient to remove
  17690. * @returns the current particle system
  17691. */
  17692. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17693. /**
  17694. * Adds a new size gradient
  17695. * @param gradient defines the gradient to use (between 0 and 1)
  17696. * @param factor defines the size factor to affect to the specified gradient
  17697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17698. * @returns the current particle system
  17699. */
  17700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17701. /**
  17702. * Remove a specific size gradient
  17703. * @param gradient defines the gradient to remove
  17704. * @returns the current particle system
  17705. */
  17706. removeSizeGradient(gradient: number): IParticleSystem;
  17707. /**
  17708. * Adds a new color remap gradient
  17709. * @param gradient defines the gradient to use (between 0 and 1)
  17710. * @param min defines the color remap minimal range
  17711. * @param max defines the color remap maximal range
  17712. * @returns the current particle system
  17713. */
  17714. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17715. /**
  17716. * Remove a specific color remap gradient
  17717. * @param gradient defines the gradient to remove
  17718. * @returns the current particle system
  17719. */
  17720. removeColorRemapGradient(gradient: number): IParticleSystem;
  17721. /**
  17722. * Adds a new alpha remap gradient
  17723. * @param gradient defines the gradient to use (between 0 and 1)
  17724. * @param min defines the alpha remap minimal range
  17725. * @param max defines the alpha remap maximal range
  17726. * @returns the current particle system
  17727. */
  17728. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17729. /**
  17730. * Remove a specific alpha remap gradient
  17731. * @param gradient defines the gradient to remove
  17732. * @returns the current particle system
  17733. */
  17734. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17735. /**
  17736. * Adds a new angular speed gradient
  17737. * @param gradient defines the gradient to use (between 0 and 1)
  17738. * @param factor defines the angular speed to affect to the specified gradient
  17739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17740. * @returns the current particle system
  17741. */
  17742. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17743. /**
  17744. * Remove a specific angular speed gradient
  17745. * @param gradient defines the gradient to remove
  17746. * @returns the current particle system
  17747. */
  17748. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17749. /**
  17750. * Adds a new velocity gradient
  17751. * @param gradient defines the gradient to use (between 0 and 1)
  17752. * @param factor defines the velocity to affect to the specified gradient
  17753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17754. * @returns the current particle system
  17755. */
  17756. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17757. /**
  17758. * Remove a specific velocity gradient
  17759. * @param gradient defines the gradient to remove
  17760. * @returns the current particle system
  17761. */
  17762. removeVelocityGradient(gradient: number): IParticleSystem;
  17763. /**
  17764. * Adds a new limit velocity gradient
  17765. * @param gradient defines the gradient to use (between 0 and 1)
  17766. * @param factor defines the limit velocity value to affect to the specified gradient
  17767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17768. * @returns the current particle system
  17769. */
  17770. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17771. /**
  17772. * Remove a specific limit velocity gradient
  17773. * @param gradient defines the gradient to remove
  17774. * @returns the current particle system
  17775. */
  17776. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17777. /**
  17778. * Adds a new drag gradient
  17779. * @param gradient defines the gradient to use (between 0 and 1)
  17780. * @param factor defines the drag value to affect to the specified gradient
  17781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17782. * @returns the current particle system
  17783. */
  17784. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17785. /**
  17786. * Remove a specific drag gradient
  17787. * @param gradient defines the gradient to remove
  17788. * @returns the current particle system
  17789. */
  17790. removeDragGradient(gradient: number): IParticleSystem;
  17791. /**
  17792. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17793. * @param gradient defines the gradient to use (between 0 and 1)
  17794. * @param factor defines the emit rate value to affect to the specified gradient
  17795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17796. * @returns the current particle system
  17797. */
  17798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17799. /**
  17800. * Remove a specific emit rate gradient
  17801. * @param gradient defines the gradient to remove
  17802. * @returns the current particle system
  17803. */
  17804. removeEmitRateGradient(gradient: number): IParticleSystem;
  17805. /**
  17806. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17807. * @param gradient defines the gradient to use (between 0 and 1)
  17808. * @param factor defines the start size value to affect to the specified gradient
  17809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17810. * @returns the current particle system
  17811. */
  17812. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17813. /**
  17814. * Remove a specific start size gradient
  17815. * @param gradient defines the gradient to remove
  17816. * @returns the current particle system
  17817. */
  17818. removeStartSizeGradient(gradient: number): IParticleSystem;
  17819. private _createRampGradientTexture;
  17820. /**
  17821. * Gets the current list of ramp gradients.
  17822. * You must use addRampGradient and removeRampGradient to udpate this list
  17823. * @returns the list of ramp gradients
  17824. */
  17825. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17826. /**
  17827. * Adds a new ramp gradient used to remap particle colors
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param color defines the color to affect to the specified gradient
  17830. * @returns the current particle system
  17831. */
  17832. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17833. /**
  17834. * Remove a specific ramp gradient
  17835. * @param gradient defines the gradient to remove
  17836. * @returns the current particle system
  17837. */
  17838. removeRampGradient(gradient: number): ParticleSystem;
  17839. /**
  17840. * Adds a new color gradient
  17841. * @param gradient defines the gradient to use (between 0 and 1)
  17842. * @param color1 defines the color to affect to the specified gradient
  17843. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17844. * @returns this particle system
  17845. */
  17846. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17847. /**
  17848. * Remove a specific color gradient
  17849. * @param gradient defines the gradient to remove
  17850. * @returns this particle system
  17851. */
  17852. removeColorGradient(gradient: number): IParticleSystem;
  17853. private _fetchR;
  17854. protected _reset(): void;
  17855. private _resetEffect;
  17856. private _createVertexBuffers;
  17857. private _createIndexBuffer;
  17858. /**
  17859. * Gets the maximum number of particles active at the same time.
  17860. * @returns The max number of active particles.
  17861. */
  17862. getCapacity(): number;
  17863. /**
  17864. * Gets whether there are still active particles in the system.
  17865. * @returns True if it is alive, otherwise false.
  17866. */
  17867. isAlive(): boolean;
  17868. /**
  17869. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17870. * @returns True if it has been started, otherwise false.
  17871. */
  17872. isStarted(): boolean;
  17873. private _prepareSubEmitterInternalArray;
  17874. /**
  17875. * Starts the particle system and begins to emit
  17876. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17877. */
  17878. start(delay?: number): void;
  17879. /**
  17880. * Stops the particle system.
  17881. * @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.
  17882. */
  17883. stop(stopSubEmitters?: boolean): void;
  17884. /**
  17885. * Remove all active particles
  17886. */
  17887. reset(): void;
  17888. /**
  17889. * @hidden (for internal use only)
  17890. */
  17891. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17892. /**
  17893. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17894. * Its lifetime will start back at 0.
  17895. */
  17896. recycleParticle: (particle: Particle) => void;
  17897. private _stopSubEmitters;
  17898. private _createParticle;
  17899. private _removeFromRoot;
  17900. private _emitFromParticle;
  17901. private _update;
  17902. /** @hidden */
  17903. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17904. /** @hidden */
  17905. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17906. /** @hidden */
  17907. private _getEffect;
  17908. /**
  17909. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17910. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17911. */
  17912. animate(preWarmOnly?: boolean): void;
  17913. private _appendParticleVertices;
  17914. /**
  17915. * Rebuilds the particle system.
  17916. */
  17917. rebuild(): void;
  17918. /**
  17919. * Is this system ready to be used/rendered
  17920. * @return true if the system is ready
  17921. */
  17922. isReady(): boolean;
  17923. private _render;
  17924. /**
  17925. * Renders the particle system in its current state.
  17926. * @returns the current number of particles
  17927. */
  17928. render(): number;
  17929. /**
  17930. * Disposes the particle system and free the associated resources
  17931. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17932. */
  17933. dispose(disposeTexture?: boolean): void;
  17934. /**
  17935. * Clones the particle system.
  17936. * @param name The name of the cloned object
  17937. * @param newEmitter The new emitter to use
  17938. * @returns the cloned particle system
  17939. */
  17940. clone(name: string, newEmitter: any): ParticleSystem;
  17941. /**
  17942. * Serializes the particle system to a JSON object.
  17943. * @returns the JSON object
  17944. */
  17945. serialize(): any;
  17946. /** @hidden */
  17947. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17948. /** @hidden */
  17949. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17950. /**
  17951. * Parses a JSON object to create a particle system.
  17952. * @param parsedParticleSystem The JSON object to parse
  17953. * @param scene The scene to create the particle system in
  17954. * @param rootUrl The root url to use to load external dependencies like texture
  17955. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17956. * @returns the Parsed particle system
  17957. */
  17958. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17959. }
  17960. }
  17961. declare module "babylonjs/Particles/particle" {
  17962. import { Nullable } from "babylonjs/types";
  17963. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17964. import { Color4 } from "babylonjs/Maths/math.color";
  17965. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17966. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17967. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17968. /**
  17969. * A particle represents one of the element emitted by a particle system.
  17970. * This is mainly define by its coordinates, direction, velocity and age.
  17971. */
  17972. export class Particle {
  17973. /**
  17974. * The particle system the particle belongs to.
  17975. */
  17976. particleSystem: ParticleSystem;
  17977. private static _Count;
  17978. /**
  17979. * Unique ID of the particle
  17980. */
  17981. id: number;
  17982. /**
  17983. * The world position of the particle in the scene.
  17984. */
  17985. position: Vector3;
  17986. /**
  17987. * The world direction of the particle in the scene.
  17988. */
  17989. direction: Vector3;
  17990. /**
  17991. * The color of the particle.
  17992. */
  17993. color: Color4;
  17994. /**
  17995. * The color change of the particle per step.
  17996. */
  17997. colorStep: Color4;
  17998. /**
  17999. * Defines how long will the life of the particle be.
  18000. */
  18001. lifeTime: number;
  18002. /**
  18003. * The current age of the particle.
  18004. */
  18005. age: number;
  18006. /**
  18007. * The current size of the particle.
  18008. */
  18009. size: number;
  18010. /**
  18011. * The current scale of the particle.
  18012. */
  18013. scale: Vector2;
  18014. /**
  18015. * The current angle of the particle.
  18016. */
  18017. angle: number;
  18018. /**
  18019. * Defines how fast is the angle changing.
  18020. */
  18021. angularSpeed: number;
  18022. /**
  18023. * Defines the cell index used by the particle to be rendered from a sprite.
  18024. */
  18025. cellIndex: number;
  18026. /**
  18027. * The information required to support color remapping
  18028. */
  18029. remapData: Vector4;
  18030. /** @hidden */
  18031. _randomCellOffset?: number;
  18032. /** @hidden */
  18033. _initialDirection: Nullable<Vector3>;
  18034. /** @hidden */
  18035. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18036. /** @hidden */
  18037. _initialStartSpriteCellID: number;
  18038. /** @hidden */
  18039. _initialEndSpriteCellID: number;
  18040. /** @hidden */
  18041. _currentColorGradient: Nullable<ColorGradient>;
  18042. /** @hidden */
  18043. _currentColor1: Color4;
  18044. /** @hidden */
  18045. _currentColor2: Color4;
  18046. /** @hidden */
  18047. _currentSizeGradient: Nullable<FactorGradient>;
  18048. /** @hidden */
  18049. _currentSize1: number;
  18050. /** @hidden */
  18051. _currentSize2: number;
  18052. /** @hidden */
  18053. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18054. /** @hidden */
  18055. _currentAngularSpeed1: number;
  18056. /** @hidden */
  18057. _currentAngularSpeed2: number;
  18058. /** @hidden */
  18059. _currentVelocityGradient: Nullable<FactorGradient>;
  18060. /** @hidden */
  18061. _currentVelocity1: number;
  18062. /** @hidden */
  18063. _currentVelocity2: number;
  18064. /** @hidden */
  18065. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18066. /** @hidden */
  18067. _currentLimitVelocity1: number;
  18068. /** @hidden */
  18069. _currentLimitVelocity2: number;
  18070. /** @hidden */
  18071. _currentDragGradient: Nullable<FactorGradient>;
  18072. /** @hidden */
  18073. _currentDrag1: number;
  18074. /** @hidden */
  18075. _currentDrag2: number;
  18076. /** @hidden */
  18077. _randomNoiseCoordinates1: Vector3;
  18078. /** @hidden */
  18079. _randomNoiseCoordinates2: Vector3;
  18080. /**
  18081. * Creates a new instance Particle
  18082. * @param particleSystem the particle system the particle belongs to
  18083. */
  18084. constructor(
  18085. /**
  18086. * The particle system the particle belongs to.
  18087. */
  18088. particleSystem: ParticleSystem);
  18089. private updateCellInfoFromSystem;
  18090. /**
  18091. * Defines how the sprite cell index is updated for the particle
  18092. */
  18093. updateCellIndex(): void;
  18094. /** @hidden */
  18095. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18096. /** @hidden */
  18097. _inheritParticleInfoToSubEmitters(): void;
  18098. /** @hidden */
  18099. _reset(): void;
  18100. /**
  18101. * Copy the properties of particle to another one.
  18102. * @param other the particle to copy the information to.
  18103. */
  18104. copyTo(other: Particle): void;
  18105. }
  18106. }
  18107. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18108. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18109. import { Effect } from "babylonjs/Materials/effect";
  18110. import { Particle } from "babylonjs/Particles/particle";
  18111. /**
  18112. * Particle emitter represents a volume emitting particles.
  18113. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18114. */
  18115. export interface IParticleEmitterType {
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Called by the particle System when the position is computed for the created particle.
  18125. * @param worldMatrix is the world matrix of the particle system
  18126. * @param positionToUpdate is the position vector to update with the result
  18127. * @param particle is the particle we are computed the position for
  18128. */
  18129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18130. /**
  18131. * Clones the current emitter and returns a copy of it
  18132. * @returns the new emitter
  18133. */
  18134. clone(): IParticleEmitterType;
  18135. /**
  18136. * Called by the GPUParticleSystem to setup the update shader
  18137. * @param effect defines the update shader
  18138. */
  18139. applyToShader(effect: Effect): void;
  18140. /**
  18141. * Returns a string to use to update the GPU particles update shader
  18142. * @returns the effect defines string
  18143. */
  18144. getEffectDefines(): string;
  18145. /**
  18146. * Returns a string representing the class name
  18147. * @returns a string containing the class name
  18148. */
  18149. getClassName(): string;
  18150. /**
  18151. * Serializes the particle system to a JSON object.
  18152. * @returns the JSON object
  18153. */
  18154. serialize(): any;
  18155. /**
  18156. * Parse properties from a JSON object
  18157. * @param serializationObject defines the JSON object
  18158. */
  18159. parse(serializationObject: any): void;
  18160. }
  18161. }
  18162. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18163. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18164. import { Effect } from "babylonjs/Materials/effect";
  18165. import { Particle } from "babylonjs/Particles/particle";
  18166. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18167. /**
  18168. * Particle emitter emitting particles from the inside of a box.
  18169. * It emits the particles randomly between 2 given directions.
  18170. */
  18171. export class BoxParticleEmitter implements IParticleEmitterType {
  18172. /**
  18173. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18174. */
  18175. direction1: Vector3;
  18176. /**
  18177. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18178. */
  18179. direction2: Vector3;
  18180. /**
  18181. * 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.
  18182. */
  18183. minEmitBox: Vector3;
  18184. /**
  18185. * 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.
  18186. */
  18187. maxEmitBox: Vector3;
  18188. /**
  18189. * Creates a new instance BoxParticleEmitter
  18190. */
  18191. constructor();
  18192. /**
  18193. * Called by the particle System when the direction is computed for the created particle.
  18194. * @param worldMatrix is the world matrix of the particle system
  18195. * @param directionToUpdate is the direction vector to update with the result
  18196. * @param particle is the particle we are computed the direction for
  18197. */
  18198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18199. /**
  18200. * Called by the particle System when the position is computed for the created particle.
  18201. * @param worldMatrix is the world matrix of the particle system
  18202. * @param positionToUpdate is the position vector to update with the result
  18203. * @param particle is the particle we are computed the position for
  18204. */
  18205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18206. /**
  18207. * Clones the current emitter and returns a copy of it
  18208. * @returns the new emitter
  18209. */
  18210. clone(): BoxParticleEmitter;
  18211. /**
  18212. * Called by the GPUParticleSystem to setup the update shader
  18213. * @param effect defines the update shader
  18214. */
  18215. applyToShader(effect: Effect): void;
  18216. /**
  18217. * Returns a string to use to update the GPU particles update shader
  18218. * @returns a string containng the defines string
  18219. */
  18220. getEffectDefines(): string;
  18221. /**
  18222. * Returns the string "BoxParticleEmitter"
  18223. * @returns a string containing the class name
  18224. */
  18225. getClassName(): string;
  18226. /**
  18227. * Serializes the particle system to a JSON object.
  18228. * @returns the JSON object
  18229. */
  18230. serialize(): any;
  18231. /**
  18232. * Parse properties from a JSON object
  18233. * @param serializationObject defines the JSON object
  18234. */
  18235. parse(serializationObject: any): void;
  18236. }
  18237. }
  18238. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18240. import { Effect } from "babylonjs/Materials/effect";
  18241. import { Particle } from "babylonjs/Particles/particle";
  18242. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18243. /**
  18244. * Particle emitter emitting particles from the inside of a cone.
  18245. * It emits the particles alongside the cone volume from the base to the particle.
  18246. * The emission direction might be randomized.
  18247. */
  18248. export class ConeParticleEmitter implements IParticleEmitterType {
  18249. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18250. directionRandomizer: number;
  18251. private _radius;
  18252. private _angle;
  18253. private _height;
  18254. /**
  18255. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18260. */
  18261. heightRange: number;
  18262. /**
  18263. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18264. */
  18265. emitFromSpawnPointOnly: boolean;
  18266. /**
  18267. * Gets or sets the radius of the emission cone
  18268. */
  18269. radius: number;
  18270. /**
  18271. * Gets or sets the angle of the emission cone
  18272. */
  18273. angle: number;
  18274. private _buildHeight;
  18275. /**
  18276. * Creates a new instance ConeParticleEmitter
  18277. * @param radius the radius of the emission cone (1 by default)
  18278. * @param angle the cone base angle (PI by default)
  18279. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18280. */
  18281. constructor(radius?: number, angle?: number,
  18282. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18283. directionRandomizer?: number);
  18284. /**
  18285. * Called by the particle System when the direction is computed for the created particle.
  18286. * @param worldMatrix is the world matrix of the particle system
  18287. * @param directionToUpdate is the direction vector to update with the result
  18288. * @param particle is the particle we are computed the direction for
  18289. */
  18290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18291. /**
  18292. * Called by the particle System when the position is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param positionToUpdate is the position vector to update with the result
  18295. * @param particle is the particle we are computed the position for
  18296. */
  18297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Clones the current emitter and returns a copy of it
  18300. * @returns the new emitter
  18301. */
  18302. clone(): ConeParticleEmitter;
  18303. /**
  18304. * Called by the GPUParticleSystem to setup the update shader
  18305. * @param effect defines the update shader
  18306. */
  18307. applyToShader(effect: Effect): void;
  18308. /**
  18309. * Returns a string to use to update the GPU particles update shader
  18310. * @returns a string containng the defines string
  18311. */
  18312. getEffectDefines(): string;
  18313. /**
  18314. * Returns the string "ConeParticleEmitter"
  18315. * @returns a string containing the class name
  18316. */
  18317. getClassName(): string;
  18318. /**
  18319. * Serializes the particle system to a JSON object.
  18320. * @returns the JSON object
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Parse properties from a JSON object
  18325. * @param serializationObject defines the JSON object
  18326. */
  18327. parse(serializationObject: any): void;
  18328. }
  18329. }
  18330. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18332. import { Effect } from "babylonjs/Materials/effect";
  18333. import { Particle } from "babylonjs/Particles/particle";
  18334. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18335. /**
  18336. * Particle emitter emitting particles from the inside of a cylinder.
  18337. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18338. */
  18339. export class CylinderParticleEmitter implements IParticleEmitterType {
  18340. /**
  18341. * The radius of the emission cylinder.
  18342. */
  18343. radius: number;
  18344. /**
  18345. * The height of the emission cylinder.
  18346. */
  18347. height: number;
  18348. /**
  18349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18350. */
  18351. radiusRange: number;
  18352. /**
  18353. * How much to randomize the particle direction [0-1].
  18354. */
  18355. directionRandomizer: number;
  18356. /**
  18357. * Creates a new instance CylinderParticleEmitter
  18358. * @param radius the radius of the emission cylinder (1 by default)
  18359. * @param height the height of the emission cylinder (1 by default)
  18360. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18361. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18362. */
  18363. constructor(
  18364. /**
  18365. * The radius of the emission cylinder.
  18366. */
  18367. radius?: number,
  18368. /**
  18369. * The height of the emission cylinder.
  18370. */
  18371. height?: number,
  18372. /**
  18373. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18374. */
  18375. radiusRange?: number,
  18376. /**
  18377. * How much to randomize the particle direction [0-1].
  18378. */
  18379. directionRandomizer?: number);
  18380. /**
  18381. * Called by the particle System when the direction is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param directionToUpdate is the direction vector to update with the result
  18384. * @param particle is the particle we are computed the direction for
  18385. */
  18386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Called by the particle System when the position is computed for the created particle.
  18389. * @param worldMatrix is the world matrix of the particle system
  18390. * @param positionToUpdate is the position vector to update with the result
  18391. * @param particle is the particle we are computed the position for
  18392. */
  18393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18394. /**
  18395. * Clones the current emitter and returns a copy of it
  18396. * @returns the new emitter
  18397. */
  18398. clone(): CylinderParticleEmitter;
  18399. /**
  18400. * Called by the GPUParticleSystem to setup the update shader
  18401. * @param effect defines the update shader
  18402. */
  18403. applyToShader(effect: Effect): void;
  18404. /**
  18405. * Returns a string to use to update the GPU particles update shader
  18406. * @returns a string containng the defines string
  18407. */
  18408. getEffectDefines(): string;
  18409. /**
  18410. * Returns the string "CylinderParticleEmitter"
  18411. * @returns a string containing the class name
  18412. */
  18413. getClassName(): string;
  18414. /**
  18415. * Serializes the particle system to a JSON object.
  18416. * @returns the JSON object
  18417. */
  18418. serialize(): any;
  18419. /**
  18420. * Parse properties from a JSON object
  18421. * @param serializationObject defines the JSON object
  18422. */
  18423. parse(serializationObject: any): void;
  18424. }
  18425. /**
  18426. * Particle emitter emitting particles from the inside of a cylinder.
  18427. * It emits the particles randomly between two vectors.
  18428. */
  18429. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18430. /**
  18431. * The min limit of the emission direction.
  18432. */
  18433. direction1: Vector3;
  18434. /**
  18435. * The max limit of the emission direction.
  18436. */
  18437. direction2: Vector3;
  18438. /**
  18439. * Creates a new instance CylinderDirectedParticleEmitter
  18440. * @param radius the radius of the emission cylinder (1 by default)
  18441. * @param height the height of the emission cylinder (1 by default)
  18442. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18443. * @param direction1 the min limit of the emission direction (up vector by default)
  18444. * @param direction2 the max limit of the emission direction (up vector by default)
  18445. */
  18446. constructor(radius?: number, height?: number, radiusRange?: number,
  18447. /**
  18448. * The min limit of the emission direction.
  18449. */
  18450. direction1?: Vector3,
  18451. /**
  18452. * The max limit of the emission direction.
  18453. */
  18454. direction2?: Vector3);
  18455. /**
  18456. * Called by the particle System when the direction is computed for the created particle.
  18457. * @param worldMatrix is the world matrix of the particle system
  18458. * @param directionToUpdate is the direction vector to update with the result
  18459. * @param particle is the particle we are computed the direction for
  18460. */
  18461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18462. /**
  18463. * Clones the current emitter and returns a copy of it
  18464. * @returns the new emitter
  18465. */
  18466. clone(): CylinderDirectedParticleEmitter;
  18467. /**
  18468. * Called by the GPUParticleSystem to setup the update shader
  18469. * @param effect defines the update shader
  18470. */
  18471. applyToShader(effect: Effect): void;
  18472. /**
  18473. * Returns a string to use to update the GPU particles update shader
  18474. * @returns a string containng the defines string
  18475. */
  18476. getEffectDefines(): string;
  18477. /**
  18478. * Returns the string "CylinderDirectedParticleEmitter"
  18479. * @returns a string containing the class name
  18480. */
  18481. getClassName(): string;
  18482. /**
  18483. * Serializes the particle system to a JSON object.
  18484. * @returns the JSON object
  18485. */
  18486. serialize(): any;
  18487. /**
  18488. * Parse properties from a JSON object
  18489. * @param serializationObject defines the JSON object
  18490. */
  18491. parse(serializationObject: any): void;
  18492. }
  18493. }
  18494. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18496. import { Effect } from "babylonjs/Materials/effect";
  18497. import { Particle } from "babylonjs/Particles/particle";
  18498. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18499. /**
  18500. * Particle emitter emitting particles from the inside of a hemisphere.
  18501. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18502. */
  18503. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18504. /**
  18505. * The radius of the emission hemisphere.
  18506. */
  18507. radius: number;
  18508. /**
  18509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18510. */
  18511. radiusRange: number;
  18512. /**
  18513. * How much to randomize the particle direction [0-1].
  18514. */
  18515. directionRandomizer: number;
  18516. /**
  18517. * Creates a new instance HemisphericParticleEmitter
  18518. * @param radius the radius of the emission hemisphere (1 by default)
  18519. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18521. */
  18522. constructor(
  18523. /**
  18524. * The radius of the emission hemisphere.
  18525. */
  18526. radius?: number,
  18527. /**
  18528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18529. */
  18530. radiusRange?: number,
  18531. /**
  18532. * How much to randomize the particle direction [0-1].
  18533. */
  18534. directionRandomizer?: number);
  18535. /**
  18536. * Called by the particle System when the direction is computed for the created particle.
  18537. * @param worldMatrix is the world matrix of the particle system
  18538. * @param directionToUpdate is the direction vector to update with the result
  18539. * @param particle is the particle we are computed the direction for
  18540. */
  18541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18542. /**
  18543. * Called by the particle System when the position is computed for the created particle.
  18544. * @param worldMatrix is the world matrix of the particle system
  18545. * @param positionToUpdate is the position vector to update with the result
  18546. * @param particle is the particle we are computed the position for
  18547. */
  18548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18549. /**
  18550. * Clones the current emitter and returns a copy of it
  18551. * @returns the new emitter
  18552. */
  18553. clone(): HemisphericParticleEmitter;
  18554. /**
  18555. * Called by the GPUParticleSystem to setup the update shader
  18556. * @param effect defines the update shader
  18557. */
  18558. applyToShader(effect: Effect): void;
  18559. /**
  18560. * Returns a string to use to update the GPU particles update shader
  18561. * @returns a string containng the defines string
  18562. */
  18563. getEffectDefines(): string;
  18564. /**
  18565. * Returns the string "HemisphericParticleEmitter"
  18566. * @returns a string containing the class name
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Serializes the particle system to a JSON object.
  18571. * @returns the JSON object
  18572. */
  18573. serialize(): any;
  18574. /**
  18575. * Parse properties from a JSON object
  18576. * @param serializationObject defines the JSON object
  18577. */
  18578. parse(serializationObject: any): void;
  18579. }
  18580. }
  18581. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18582. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18583. import { Effect } from "babylonjs/Materials/effect";
  18584. import { Particle } from "babylonjs/Particles/particle";
  18585. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18586. /**
  18587. * Particle emitter emitting particles from a point.
  18588. * It emits the particles randomly between 2 given directions.
  18589. */
  18590. export class PointParticleEmitter implements IParticleEmitterType {
  18591. /**
  18592. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18593. */
  18594. direction1: Vector3;
  18595. /**
  18596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18597. */
  18598. direction2: Vector3;
  18599. /**
  18600. * Creates a new instance PointParticleEmitter
  18601. */
  18602. constructor();
  18603. /**
  18604. * Called by the particle System when the direction is computed for the created particle.
  18605. * @param worldMatrix is the world matrix of the particle system
  18606. * @param directionToUpdate is the direction vector to update with the result
  18607. * @param particle is the particle we are computed the direction for
  18608. */
  18609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18610. /**
  18611. * Called by the particle System when the position is computed for the created particle.
  18612. * @param worldMatrix is the world matrix of the particle system
  18613. * @param positionToUpdate is the position vector to update with the result
  18614. * @param particle is the particle we are computed the position for
  18615. */
  18616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18617. /**
  18618. * Clones the current emitter and returns a copy of it
  18619. * @returns the new emitter
  18620. */
  18621. clone(): PointParticleEmitter;
  18622. /**
  18623. * Called by the GPUParticleSystem to setup the update shader
  18624. * @param effect defines the update shader
  18625. */
  18626. applyToShader(effect: Effect): void;
  18627. /**
  18628. * Returns a string to use to update the GPU particles update shader
  18629. * @returns a string containng the defines string
  18630. */
  18631. getEffectDefines(): string;
  18632. /**
  18633. * Returns the string "PointParticleEmitter"
  18634. * @returns a string containing the class name
  18635. */
  18636. getClassName(): string;
  18637. /**
  18638. * Serializes the particle system to a JSON object.
  18639. * @returns the JSON object
  18640. */
  18641. serialize(): any;
  18642. /**
  18643. * Parse properties from a JSON object
  18644. * @param serializationObject defines the JSON object
  18645. */
  18646. parse(serializationObject: any): void;
  18647. }
  18648. }
  18649. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18650. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18651. import { Effect } from "babylonjs/Materials/effect";
  18652. import { Particle } from "babylonjs/Particles/particle";
  18653. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18654. /**
  18655. * Particle emitter emitting particles from the inside of a sphere.
  18656. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18657. */
  18658. export class SphereParticleEmitter implements IParticleEmitterType {
  18659. /**
  18660. * The radius of the emission sphere.
  18661. */
  18662. radius: number;
  18663. /**
  18664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18665. */
  18666. radiusRange: number;
  18667. /**
  18668. * How much to randomize the particle direction [0-1].
  18669. */
  18670. directionRandomizer: number;
  18671. /**
  18672. * Creates a new instance SphereParticleEmitter
  18673. * @param radius the radius of the emission sphere (1 by default)
  18674. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18676. */
  18677. constructor(
  18678. /**
  18679. * The radius of the emission sphere.
  18680. */
  18681. radius?: number,
  18682. /**
  18683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18684. */
  18685. radiusRange?: number,
  18686. /**
  18687. * How much to randomize the particle direction [0-1].
  18688. */
  18689. directionRandomizer?: number);
  18690. /**
  18691. * Called by the particle System when the direction is computed for the created particle.
  18692. * @param worldMatrix is the world matrix of the particle system
  18693. * @param directionToUpdate is the direction vector to update with the result
  18694. * @param particle is the particle we are computed the direction for
  18695. */
  18696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18697. /**
  18698. * Called by the particle System when the position is computed for the created particle.
  18699. * @param worldMatrix is the world matrix of the particle system
  18700. * @param positionToUpdate is the position vector to update with the result
  18701. * @param particle is the particle we are computed the position for
  18702. */
  18703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18704. /**
  18705. * Clones the current emitter and returns a copy of it
  18706. * @returns the new emitter
  18707. */
  18708. clone(): SphereParticleEmitter;
  18709. /**
  18710. * Called by the GPUParticleSystem to setup the update shader
  18711. * @param effect defines the update shader
  18712. */
  18713. applyToShader(effect: Effect): void;
  18714. /**
  18715. * Returns a string to use to update the GPU particles update shader
  18716. * @returns a string containng the defines string
  18717. */
  18718. getEffectDefines(): string;
  18719. /**
  18720. * Returns the string "SphereParticleEmitter"
  18721. * @returns a string containing the class name
  18722. */
  18723. getClassName(): string;
  18724. /**
  18725. * Serializes the particle system to a JSON object.
  18726. * @returns the JSON object
  18727. */
  18728. serialize(): any;
  18729. /**
  18730. * Parse properties from a JSON object
  18731. * @param serializationObject defines the JSON object
  18732. */
  18733. parse(serializationObject: any): void;
  18734. }
  18735. /**
  18736. * Particle emitter emitting particles from the inside of a sphere.
  18737. * It emits the particles randomly between two vectors.
  18738. */
  18739. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18740. /**
  18741. * The min limit of the emission direction.
  18742. */
  18743. direction1: Vector3;
  18744. /**
  18745. * The max limit of the emission direction.
  18746. */
  18747. direction2: Vector3;
  18748. /**
  18749. * Creates a new instance SphereDirectedParticleEmitter
  18750. * @param radius the radius of the emission sphere (1 by default)
  18751. * @param direction1 the min limit of the emission direction (up vector by default)
  18752. * @param direction2 the max limit of the emission direction (up vector by default)
  18753. */
  18754. constructor(radius?: number,
  18755. /**
  18756. * The min limit of the emission direction.
  18757. */
  18758. direction1?: Vector3,
  18759. /**
  18760. * The max limit of the emission direction.
  18761. */
  18762. direction2?: Vector3);
  18763. /**
  18764. * Called by the particle System when the direction is computed for the created particle.
  18765. * @param worldMatrix is the world matrix of the particle system
  18766. * @param directionToUpdate is the direction vector to update with the result
  18767. * @param particle is the particle we are computed the direction for
  18768. */
  18769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18770. /**
  18771. * Clones the current emitter and returns a copy of it
  18772. * @returns the new emitter
  18773. */
  18774. clone(): SphereDirectedParticleEmitter;
  18775. /**
  18776. * Called by the GPUParticleSystem to setup the update shader
  18777. * @param effect defines the update shader
  18778. */
  18779. applyToShader(effect: Effect): void;
  18780. /**
  18781. * Returns a string to use to update the GPU particles update shader
  18782. * @returns a string containng the defines string
  18783. */
  18784. getEffectDefines(): string;
  18785. /**
  18786. * Returns the string "SphereDirectedParticleEmitter"
  18787. * @returns a string containing the class name
  18788. */
  18789. getClassName(): string;
  18790. /**
  18791. * Serializes the particle system to a JSON object.
  18792. * @returns the JSON object
  18793. */
  18794. serialize(): any;
  18795. /**
  18796. * Parse properties from a JSON object
  18797. * @param serializationObject defines the JSON object
  18798. */
  18799. parse(serializationObject: any): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Particles/EmitterTypes/index" {
  18803. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18804. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18805. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18806. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18807. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18808. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18809. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18810. }
  18811. declare module "babylonjs/Particles/IParticleSystem" {
  18812. import { Nullable } from "babylonjs/types";
  18813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18814. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18817. import { Texture } from "babylonjs/Materials/Textures/texture";
  18818. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18819. import { Scene } from "babylonjs/scene";
  18820. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18821. import { Animation } from "babylonjs/Animations/animation";
  18822. /**
  18823. * Interface representing a particle system in Babylon.js.
  18824. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18825. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18826. */
  18827. export interface IParticleSystem {
  18828. /**
  18829. * List of animations used by the particle system.
  18830. */
  18831. animations: Animation[];
  18832. /**
  18833. * The id of the Particle system.
  18834. */
  18835. id: string;
  18836. /**
  18837. * The name of the Particle system.
  18838. */
  18839. name: string;
  18840. /**
  18841. * The emitter represents the Mesh or position we are attaching the particle system to.
  18842. */
  18843. emitter: Nullable<AbstractMesh | Vector3>;
  18844. /**
  18845. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18846. */
  18847. isBillboardBased: boolean;
  18848. /**
  18849. * The rendering group used by the Particle system to chose when to render.
  18850. */
  18851. renderingGroupId: number;
  18852. /**
  18853. * The layer mask we are rendering the particles through.
  18854. */
  18855. layerMask: number;
  18856. /**
  18857. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18858. */
  18859. updateSpeed: number;
  18860. /**
  18861. * The amount of time the particle system is running (depends of the overall update speed).
  18862. */
  18863. targetStopDuration: number;
  18864. /**
  18865. * The texture used to render each particle. (this can be a spritesheet)
  18866. */
  18867. particleTexture: Nullable<Texture>;
  18868. /**
  18869. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18870. */
  18871. blendMode: number;
  18872. /**
  18873. * Minimum life time of emitting particles.
  18874. */
  18875. minLifeTime: number;
  18876. /**
  18877. * Maximum life time of emitting particles.
  18878. */
  18879. maxLifeTime: number;
  18880. /**
  18881. * Minimum Size of emitting particles.
  18882. */
  18883. minSize: number;
  18884. /**
  18885. * Maximum Size of emitting particles.
  18886. */
  18887. maxSize: number;
  18888. /**
  18889. * Minimum scale of emitting particles on X axis.
  18890. */
  18891. minScaleX: number;
  18892. /**
  18893. * Maximum scale of emitting particles on X axis.
  18894. */
  18895. maxScaleX: number;
  18896. /**
  18897. * Minimum scale of emitting particles on Y axis.
  18898. */
  18899. minScaleY: number;
  18900. /**
  18901. * Maximum scale of emitting particles on Y axis.
  18902. */
  18903. maxScaleY: number;
  18904. /**
  18905. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18906. */
  18907. color1: Color4;
  18908. /**
  18909. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18910. */
  18911. color2: Color4;
  18912. /**
  18913. * Color the particle will have at the end of its lifetime.
  18914. */
  18915. colorDead: Color4;
  18916. /**
  18917. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18918. */
  18919. emitRate: number;
  18920. /**
  18921. * You can use gravity if you want to give an orientation to your particles.
  18922. */
  18923. gravity: Vector3;
  18924. /**
  18925. * Minimum power of emitting particles.
  18926. */
  18927. minEmitPower: number;
  18928. /**
  18929. * Maximum power of emitting particles.
  18930. */
  18931. maxEmitPower: number;
  18932. /**
  18933. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18934. */
  18935. minAngularSpeed: number;
  18936. /**
  18937. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18938. */
  18939. maxAngularSpeed: number;
  18940. /**
  18941. * Gets or sets the minimal initial rotation in radians.
  18942. */
  18943. minInitialRotation: number;
  18944. /**
  18945. * Gets or sets the maximal initial rotation in radians.
  18946. */
  18947. maxInitialRotation: number;
  18948. /**
  18949. * The particle emitter type defines the emitter used by the particle system.
  18950. * It can be for example box, sphere, or cone...
  18951. */
  18952. particleEmitterType: Nullable<IParticleEmitterType>;
  18953. /**
  18954. * Defines the delay in milliseconds before starting the system (0 by default)
  18955. */
  18956. startDelay: number;
  18957. /**
  18958. * 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
  18959. */
  18960. preWarmCycles: number;
  18961. /**
  18962. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18963. */
  18964. preWarmStepOffset: number;
  18965. /**
  18966. * 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)
  18967. */
  18968. spriteCellChangeSpeed: number;
  18969. /**
  18970. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18971. */
  18972. startSpriteCellID: number;
  18973. /**
  18974. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18975. */
  18976. endSpriteCellID: number;
  18977. /**
  18978. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18979. */
  18980. spriteCellWidth: number;
  18981. /**
  18982. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18983. */
  18984. spriteCellHeight: number;
  18985. /**
  18986. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18987. */
  18988. spriteRandomStartCell: boolean;
  18989. /**
  18990. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18991. */
  18992. isAnimationSheetEnabled: boolean;
  18993. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18994. translationPivot: Vector2;
  18995. /**
  18996. * Gets or sets a texture used to add random noise to particle positions
  18997. */
  18998. noiseTexture: Nullable<BaseTexture>;
  18999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19000. noiseStrength: Vector3;
  19001. /**
  19002. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19003. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19004. */
  19005. billboardMode: number;
  19006. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19007. limitVelocityDamping: number;
  19008. /**
  19009. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19010. */
  19011. beginAnimationOnStart: boolean;
  19012. /**
  19013. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19014. */
  19015. beginAnimationFrom: number;
  19016. /**
  19017. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19018. */
  19019. beginAnimationTo: number;
  19020. /**
  19021. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19022. */
  19023. beginAnimationLoop: boolean;
  19024. /**
  19025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19026. */
  19027. disposeOnStop: boolean;
  19028. /**
  19029. * Gets the maximum number of particles active at the same time.
  19030. * @returns The max number of active particles.
  19031. */
  19032. getCapacity(): number;
  19033. /**
  19034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19035. * @returns True if it has been started, otherwise false.
  19036. */
  19037. isStarted(): boolean;
  19038. /**
  19039. * Animates the particle system for this frame.
  19040. */
  19041. animate(): void;
  19042. /**
  19043. * Renders the particle system in its current state.
  19044. * @returns the current number of particles
  19045. */
  19046. render(): number;
  19047. /**
  19048. * Dispose the particle system and frees its associated resources.
  19049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19050. */
  19051. dispose(disposeTexture?: boolean): void;
  19052. /**
  19053. * Clones the particle system.
  19054. * @param name The name of the cloned object
  19055. * @param newEmitter The new emitter to use
  19056. * @returns the cloned particle system
  19057. */
  19058. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19059. /**
  19060. * Serializes the particle system to a JSON object.
  19061. * @returns the JSON object
  19062. */
  19063. serialize(): any;
  19064. /**
  19065. * Rebuild the particle system
  19066. */
  19067. rebuild(): void;
  19068. /**
  19069. * Starts the particle system and begins to emit
  19070. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19071. */
  19072. start(delay?: number): void;
  19073. /**
  19074. * Stops the particle system.
  19075. */
  19076. stop(): void;
  19077. /**
  19078. * Remove all active particles
  19079. */
  19080. reset(): void;
  19081. /**
  19082. * Is this system ready to be used/rendered
  19083. * @return true if the system is ready
  19084. */
  19085. isReady(): boolean;
  19086. /**
  19087. * Adds a new color gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param color1 defines the color to affect to the specified gradient
  19090. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19091. * @returns the current particle system
  19092. */
  19093. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19094. /**
  19095. * Remove a specific color gradient
  19096. * @param gradient defines the gradient to remove
  19097. * @returns the current particle system
  19098. */
  19099. removeColorGradient(gradient: number): IParticleSystem;
  19100. /**
  19101. * Adds a new size gradient
  19102. * @param gradient defines the gradient to use (between 0 and 1)
  19103. * @param factor defines the size factor to affect to the specified gradient
  19104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19105. * @returns the current particle system
  19106. */
  19107. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19108. /**
  19109. * Remove a specific size gradient
  19110. * @param gradient defines the gradient to remove
  19111. * @returns the current particle system
  19112. */
  19113. removeSizeGradient(gradient: number): IParticleSystem;
  19114. /**
  19115. * Gets the current list of color gradients.
  19116. * You must use addColorGradient and removeColorGradient to udpate this list
  19117. * @returns the list of color gradients
  19118. */
  19119. getColorGradients(): Nullable<Array<ColorGradient>>;
  19120. /**
  19121. * Gets the current list of size gradients.
  19122. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19123. * @returns the list of size gradients
  19124. */
  19125. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19126. /**
  19127. * Gets the current list of angular speed gradients.
  19128. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19129. * @returns the list of angular speed gradients
  19130. */
  19131. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19132. /**
  19133. * Adds a new angular speed gradient
  19134. * @param gradient defines the gradient to use (between 0 and 1)
  19135. * @param factor defines the angular speed to affect to the specified gradient
  19136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19137. * @returns the current particle system
  19138. */
  19139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19140. /**
  19141. * Remove a specific angular speed gradient
  19142. * @param gradient defines the gradient to remove
  19143. * @returns the current particle system
  19144. */
  19145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of velocity gradients.
  19148. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19149. * @returns the list of velocity gradients
  19150. */
  19151. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new velocity gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param factor defines the velocity to affect to the specified gradient
  19156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19157. * @returns the current particle system
  19158. */
  19159. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19160. /**
  19161. * Remove a specific velocity gradient
  19162. * @param gradient defines the gradient to remove
  19163. * @returns the current particle system
  19164. */
  19165. removeVelocityGradient(gradient: number): IParticleSystem;
  19166. /**
  19167. * Gets the current list of limit velocity gradients.
  19168. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19169. * @returns the list of limit velocity gradients
  19170. */
  19171. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19172. /**
  19173. * Adds a new limit velocity gradient
  19174. * @param gradient defines the gradient to use (between 0 and 1)
  19175. * @param factor defines the limit velocity to affect to the specified gradient
  19176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19177. * @returns the current particle system
  19178. */
  19179. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19180. /**
  19181. * Remove a specific limit velocity gradient
  19182. * @param gradient defines the gradient to remove
  19183. * @returns the current particle system
  19184. */
  19185. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19186. /**
  19187. * Adds a new drag gradient
  19188. * @param gradient defines the gradient to use (between 0 and 1)
  19189. * @param factor defines the drag to affect to the specified gradient
  19190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19191. * @returns the current particle system
  19192. */
  19193. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19194. /**
  19195. * Remove a specific drag gradient
  19196. * @param gradient defines the gradient to remove
  19197. * @returns the current particle system
  19198. */
  19199. removeDragGradient(gradient: number): IParticleSystem;
  19200. /**
  19201. * Gets the current list of drag gradients.
  19202. * You must use addDragGradient and removeDragGradient to udpate this list
  19203. * @returns the list of drag gradients
  19204. */
  19205. getDragGradients(): Nullable<Array<FactorGradient>>;
  19206. /**
  19207. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19208. * @param gradient defines the gradient to use (between 0 and 1)
  19209. * @param factor defines the emit rate to affect to the specified gradient
  19210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19211. * @returns the current particle system
  19212. */
  19213. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19214. /**
  19215. * Remove a specific emit rate gradient
  19216. * @param gradient defines the gradient to remove
  19217. * @returns the current particle system
  19218. */
  19219. removeEmitRateGradient(gradient: number): IParticleSystem;
  19220. /**
  19221. * Gets the current list of emit rate gradients.
  19222. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19223. * @returns the list of emit rate gradients
  19224. */
  19225. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19228. * @param gradient defines the gradient to use (between 0 and 1)
  19229. * @param factor defines the start size to affect to the specified gradient
  19230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19231. * @returns the current particle system
  19232. */
  19233. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19234. /**
  19235. * Remove a specific start size gradient
  19236. * @param gradient defines the gradient to remove
  19237. * @returns the current particle system
  19238. */
  19239. removeStartSizeGradient(gradient: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of start size gradients.
  19242. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19243. * @returns the list of start size gradients
  19244. */
  19245. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Adds a new life time gradient
  19248. * @param gradient defines the gradient to use (between 0 and 1)
  19249. * @param factor defines the life time factor to affect to the specified gradient
  19250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19251. * @returns the current particle system
  19252. */
  19253. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19254. /**
  19255. * Remove a specific life time gradient
  19256. * @param gradient defines the gradient to remove
  19257. * @returns the current particle system
  19258. */
  19259. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19260. /**
  19261. * Gets the current list of life time gradients.
  19262. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19263. * @returns the list of life time gradients
  19264. */
  19265. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19266. /**
  19267. * Gets the current list of color gradients.
  19268. * You must use addColorGradient and removeColorGradient to udpate this list
  19269. * @returns the list of color gradients
  19270. */
  19271. getColorGradients(): Nullable<Array<ColorGradient>>;
  19272. /**
  19273. * Adds a new ramp gradient used to remap particle colors
  19274. * @param gradient defines the gradient to use (between 0 and 1)
  19275. * @param color defines the color to affect to the specified gradient
  19276. * @returns the current particle system
  19277. */
  19278. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19279. /**
  19280. * Gets the current list of ramp gradients.
  19281. * You must use addRampGradient and removeRampGradient to udpate this list
  19282. * @returns the list of ramp gradients
  19283. */
  19284. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19285. /** Gets or sets a boolean indicating that ramp gradients must be used
  19286. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19287. */
  19288. useRampGradients: boolean;
  19289. /**
  19290. * Adds a new color remap gradient
  19291. * @param gradient defines the gradient to use (between 0 and 1)
  19292. * @param min defines the color remap minimal range
  19293. * @param max defines the color remap maximal range
  19294. * @returns the current particle system
  19295. */
  19296. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19297. /**
  19298. * Gets the current list of color remap gradients.
  19299. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19300. * @returns the list of color remap gradients
  19301. */
  19302. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19303. /**
  19304. * Adds a new alpha remap gradient
  19305. * @param gradient defines the gradient to use (between 0 and 1)
  19306. * @param min defines the alpha remap minimal range
  19307. * @param max defines the alpha remap maximal range
  19308. * @returns the current particle system
  19309. */
  19310. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of alpha remap gradients.
  19313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19314. * @returns the list of alpha remap gradients
  19315. */
  19316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19321. * @returns the emitter
  19322. */
  19323. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19324. /**
  19325. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19326. * @param radius The radius of the hemisphere to emit from
  19327. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19328. * @returns the emitter
  19329. */
  19330. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19331. /**
  19332. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19333. * @param radius The radius of the sphere to emit from
  19334. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19335. * @returns the emitter
  19336. */
  19337. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19338. /**
  19339. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19340. * @param radius The radius of the sphere to emit from
  19341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19343. * @returns the emitter
  19344. */
  19345. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19346. /**
  19347. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19348. * @param radius The radius of the emission cylinder
  19349. * @param height The height of the emission cylinder
  19350. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19351. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19352. * @returns the emitter
  19353. */
  19354. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19355. /**
  19356. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19357. * @param radius The radius of the cylinder to emit from
  19358. * @param height The height of the emission cylinder
  19359. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19360. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19361. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19362. * @returns the emitter
  19363. */
  19364. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19365. /**
  19366. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19367. * @param radius The radius of the cone to emit from
  19368. * @param angle The base angle of the cone
  19369. * @returns the emitter
  19370. */
  19371. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19372. /**
  19373. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19374. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19375. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19376. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19377. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19378. * @returns the emitter
  19379. */
  19380. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19381. /**
  19382. * Get hosting scene
  19383. * @returns the scene
  19384. */
  19385. getScene(): Scene;
  19386. }
  19387. }
  19388. declare module "babylonjs/Meshes/instancedMesh" {
  19389. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19391. import { Camera } from "babylonjs/Cameras/camera";
  19392. import { Node } from "babylonjs/node";
  19393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19394. import { Mesh } from "babylonjs/Meshes/mesh";
  19395. import { Material } from "babylonjs/Materials/material";
  19396. import { Skeleton } from "babylonjs/Bones/skeleton";
  19397. import { Light } from "babylonjs/Lights/light";
  19398. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19399. /**
  19400. * Creates an instance based on a source mesh.
  19401. */
  19402. export class InstancedMesh extends AbstractMesh {
  19403. private _sourceMesh;
  19404. private _currentLOD;
  19405. /** @hidden */
  19406. _indexInSourceMeshInstanceArray: number;
  19407. constructor(name: string, source: Mesh);
  19408. /**
  19409. * Returns the string "InstancedMesh".
  19410. */
  19411. getClassName(): string;
  19412. /** Gets the list of lights affecting that mesh */
  19413. readonly lightSources: Light[];
  19414. _resyncLightSources(): void;
  19415. _resyncLighSource(light: Light): void;
  19416. _removeLightSource(light: Light, dispose: boolean): void;
  19417. /**
  19418. * If the source mesh receives shadows
  19419. */
  19420. readonly receiveShadows: boolean;
  19421. /**
  19422. * The material of the source mesh
  19423. */
  19424. readonly material: Nullable<Material>;
  19425. /**
  19426. * Visibility of the source mesh
  19427. */
  19428. readonly visibility: number;
  19429. /**
  19430. * Skeleton of the source mesh
  19431. */
  19432. readonly skeleton: Nullable<Skeleton>;
  19433. /**
  19434. * Rendering ground id of the source mesh
  19435. */
  19436. renderingGroupId: number;
  19437. /**
  19438. * Returns the total number of vertices (integer).
  19439. */
  19440. getTotalVertices(): number;
  19441. /**
  19442. * Returns a positive integer : the total number of indices in this mesh geometry.
  19443. * @returns the numner of indices or zero if the mesh has no geometry.
  19444. */
  19445. getTotalIndices(): number;
  19446. /**
  19447. * The source mesh of the instance
  19448. */
  19449. readonly sourceMesh: Mesh;
  19450. /**
  19451. * Is this node ready to be used/rendered
  19452. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19453. * @return {boolean} is it ready
  19454. */
  19455. isReady(completeCheck?: boolean): boolean;
  19456. /**
  19457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19458. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19459. * @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.
  19460. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19461. */
  19462. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19463. /**
  19464. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19465. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19466. * The `data` are either a numeric array either a Float32Array.
  19467. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19468. * 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).
  19469. * Note that a new underlying VertexBuffer object is created each call.
  19470. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19471. *
  19472. * Possible `kind` values :
  19473. * - VertexBuffer.PositionKind
  19474. * - VertexBuffer.UVKind
  19475. * - VertexBuffer.UV2Kind
  19476. * - VertexBuffer.UV3Kind
  19477. * - VertexBuffer.UV4Kind
  19478. * - VertexBuffer.UV5Kind
  19479. * - VertexBuffer.UV6Kind
  19480. * - VertexBuffer.ColorKind
  19481. * - VertexBuffer.MatricesIndicesKind
  19482. * - VertexBuffer.MatricesIndicesExtraKind
  19483. * - VertexBuffer.MatricesWeightsKind
  19484. * - VertexBuffer.MatricesWeightsExtraKind
  19485. *
  19486. * Returns the Mesh.
  19487. */
  19488. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19489. /**
  19490. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19491. * If the mesh has no geometry, it is simply returned as it is.
  19492. * The `data` are either a numeric array either a Float32Array.
  19493. * No new underlying VertexBuffer object is created.
  19494. * 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.
  19495. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19496. *
  19497. * Possible `kind` values :
  19498. * - VertexBuffer.PositionKind
  19499. * - VertexBuffer.UVKind
  19500. * - VertexBuffer.UV2Kind
  19501. * - VertexBuffer.UV3Kind
  19502. * - VertexBuffer.UV4Kind
  19503. * - VertexBuffer.UV5Kind
  19504. * - VertexBuffer.UV6Kind
  19505. * - VertexBuffer.ColorKind
  19506. * - VertexBuffer.MatricesIndicesKind
  19507. * - VertexBuffer.MatricesIndicesExtraKind
  19508. * - VertexBuffer.MatricesWeightsKind
  19509. * - VertexBuffer.MatricesWeightsExtraKind
  19510. *
  19511. * Returns the Mesh.
  19512. */
  19513. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19514. /**
  19515. * Sets the mesh indices.
  19516. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19518. * This method creates a new index buffer each call.
  19519. * Returns the Mesh.
  19520. */
  19521. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19522. /**
  19523. * Boolean : True if the mesh owns the requested kind of data.
  19524. */
  19525. isVerticesDataPresent(kind: string): boolean;
  19526. /**
  19527. * Returns an array of indices (IndicesArray).
  19528. */
  19529. getIndices(): Nullable<IndicesArray>;
  19530. readonly _positions: Nullable<Vector3[]>;
  19531. /**
  19532. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19533. * This means the mesh underlying bounding box and sphere are recomputed.
  19534. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19535. * @returns the current mesh
  19536. */
  19537. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19538. /** @hidden */
  19539. _preActivate(): InstancedMesh;
  19540. /** @hidden */
  19541. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19542. /** @hidden */
  19543. _postActivate(): void;
  19544. getWorldMatrix(): Matrix;
  19545. readonly isAnInstance: boolean;
  19546. /**
  19547. * Returns the current associated LOD AbstractMesh.
  19548. */
  19549. getLOD(camera: Camera): AbstractMesh;
  19550. /** @hidden */
  19551. _syncSubMeshes(): InstancedMesh;
  19552. /** @hidden */
  19553. _generatePointsArray(): boolean;
  19554. /**
  19555. * Creates a new InstancedMesh from the current mesh.
  19556. * - name (string) : the cloned mesh name
  19557. * - newParent (optional Node) : the optional Node to parent the clone to.
  19558. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19559. *
  19560. * Returns the clone.
  19561. */
  19562. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19563. /**
  19564. * Disposes the InstancedMesh.
  19565. * Returns nothing.
  19566. */
  19567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19568. }
  19569. module "babylonjs/Meshes/mesh" {
  19570. interface Mesh {
  19571. /**
  19572. * Register a custom buffer that will be instanced
  19573. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19574. * @param kind defines the buffer kind
  19575. * @param stride defines the stride in floats
  19576. */
  19577. registerInstancedBuffer(kind: string, stride: number): void;
  19578. /** @hidden */
  19579. _userInstancedBuffersStorage: {
  19580. data: {
  19581. [key: string]: Float32Array;
  19582. };
  19583. sizes: {
  19584. [key: string]: number;
  19585. };
  19586. vertexBuffers: {
  19587. [key: string]: Nullable<VertexBuffer>;
  19588. };
  19589. strides: {
  19590. [key: string]: number;
  19591. };
  19592. };
  19593. }
  19594. }
  19595. module "babylonjs/Meshes/abstractMesh" {
  19596. interface AbstractMesh {
  19597. /**
  19598. * Object used to store instanced buffers defined by user
  19599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19600. */
  19601. instancedBuffers: {
  19602. [key: string]: any;
  19603. };
  19604. }
  19605. }
  19606. }
  19607. declare module "babylonjs/Materials/shaderMaterial" {
  19608. import { Scene } from "babylonjs/scene";
  19609. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19611. import { Mesh } from "babylonjs/Meshes/mesh";
  19612. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19614. import { Texture } from "babylonjs/Materials/Textures/texture";
  19615. import { Material } from "babylonjs/Materials/material";
  19616. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19617. /**
  19618. * Defines the options associated with the creation of a shader material.
  19619. */
  19620. export interface IShaderMaterialOptions {
  19621. /**
  19622. * Does the material work in alpha blend mode
  19623. */
  19624. needAlphaBlending: boolean;
  19625. /**
  19626. * Does the material work in alpha test mode
  19627. */
  19628. needAlphaTesting: boolean;
  19629. /**
  19630. * The list of attribute names used in the shader
  19631. */
  19632. attributes: string[];
  19633. /**
  19634. * The list of unifrom names used in the shader
  19635. */
  19636. uniforms: string[];
  19637. /**
  19638. * The list of UBO names used in the shader
  19639. */
  19640. uniformBuffers: string[];
  19641. /**
  19642. * The list of sampler names used in the shader
  19643. */
  19644. samplers: string[];
  19645. /**
  19646. * The list of defines used in the shader
  19647. */
  19648. defines: string[];
  19649. }
  19650. /**
  19651. * 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.
  19652. *
  19653. * This returned material effects how the mesh will look based on the code in the shaders.
  19654. *
  19655. * @see http://doc.babylonjs.com/how_to/shader_material
  19656. */
  19657. export class ShaderMaterial extends Material {
  19658. private _shaderPath;
  19659. private _options;
  19660. private _textures;
  19661. private _textureArrays;
  19662. private _floats;
  19663. private _ints;
  19664. private _floatsArrays;
  19665. private _colors3;
  19666. private _colors3Arrays;
  19667. private _colors4;
  19668. private _colors4Arrays;
  19669. private _vectors2;
  19670. private _vectors3;
  19671. private _vectors4;
  19672. private _matrices;
  19673. private _matrixArrays;
  19674. private _matrices3x3;
  19675. private _matrices2x2;
  19676. private _vectors2Arrays;
  19677. private _vectors3Arrays;
  19678. private _vectors4Arrays;
  19679. private _cachedWorldViewMatrix;
  19680. private _cachedWorldViewProjectionMatrix;
  19681. private _renderId;
  19682. /**
  19683. * Instantiate a new shader material.
  19684. * 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.
  19685. * This returned material effects how the mesh will look based on the code in the shaders.
  19686. * @see http://doc.babylonjs.com/how_to/shader_material
  19687. * @param name Define the name of the material in the scene
  19688. * @param scene Define the scene the material belongs to
  19689. * @param shaderPath Defines the route to the shader code in one of three ways:
  19690. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19691. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19692. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19693. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19694. * @param options Define the options used to create the shader
  19695. */
  19696. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19697. /**
  19698. * Gets the options used to compile the shader.
  19699. * They can be modified to trigger a new compilation
  19700. */
  19701. readonly options: IShaderMaterialOptions;
  19702. /**
  19703. * Gets the current class name of the material e.g. "ShaderMaterial"
  19704. * Mainly use in serialization.
  19705. * @returns the class name
  19706. */
  19707. getClassName(): string;
  19708. /**
  19709. * Specifies if the material will require alpha blending
  19710. * @returns a boolean specifying if alpha blending is needed
  19711. */
  19712. needAlphaBlending(): boolean;
  19713. /**
  19714. * Specifies if this material should be rendered in alpha test mode
  19715. * @returns a boolean specifying if an alpha test is needed.
  19716. */
  19717. needAlphaTesting(): boolean;
  19718. private _checkUniform;
  19719. /**
  19720. * Set a texture in the shader.
  19721. * @param name Define the name of the uniform samplers as defined in the shader
  19722. * @param texture Define the texture to bind to this sampler
  19723. * @return the material itself allowing "fluent" like uniform updates
  19724. */
  19725. setTexture(name: string, texture: Texture): ShaderMaterial;
  19726. /**
  19727. * Set a texture array in the shader.
  19728. * @param name Define the name of the uniform sampler array as defined in the shader
  19729. * @param textures Define the list of textures to bind to this sampler
  19730. * @return the material itself allowing "fluent" like uniform updates
  19731. */
  19732. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19733. /**
  19734. * Set a float in the shader.
  19735. * @param name Define the name of the uniform as defined in the shader
  19736. * @param value Define the value to give to the uniform
  19737. * @return the material itself allowing "fluent" like uniform updates
  19738. */
  19739. setFloat(name: string, value: number): ShaderMaterial;
  19740. /**
  19741. * Set a int in the shader.
  19742. * @param name Define the name of the uniform as defined in the shader
  19743. * @param value Define the value to give to the uniform
  19744. * @return the material itself allowing "fluent" like uniform updates
  19745. */
  19746. setInt(name: string, value: number): ShaderMaterial;
  19747. /**
  19748. * Set an array of floats in the shader.
  19749. * @param name Define the name of the uniform as defined in the shader
  19750. * @param value Define the value to give to the uniform
  19751. * @return the material itself allowing "fluent" like uniform updates
  19752. */
  19753. setFloats(name: string, value: number[]): ShaderMaterial;
  19754. /**
  19755. * Set a vec3 in the shader from a Color3.
  19756. * @param name Define the name of the uniform as defined in the shader
  19757. * @param value Define the value to give to the uniform
  19758. * @return the material itself allowing "fluent" like uniform updates
  19759. */
  19760. setColor3(name: string, value: Color3): ShaderMaterial;
  19761. /**
  19762. * Set a vec3 array in the shader from a Color3 array.
  19763. * @param name Define the name of the uniform as defined in the shader
  19764. * @param value Define the value to give to the uniform
  19765. * @return the material itself allowing "fluent" like uniform updates
  19766. */
  19767. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19768. /**
  19769. * Set a vec4 in the shader from a Color4.
  19770. * @param name Define the name of the uniform as defined in the shader
  19771. * @param value Define the value to give to the uniform
  19772. * @return the material itself allowing "fluent" like uniform updates
  19773. */
  19774. setColor4(name: string, value: Color4): ShaderMaterial;
  19775. /**
  19776. * Set a vec4 array in the shader from a Color4 array.
  19777. * @param name Define the name of the uniform as defined in the shader
  19778. * @param value Define the value to give to the uniform
  19779. * @return the material itself allowing "fluent" like uniform updates
  19780. */
  19781. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19782. /**
  19783. * Set a vec2 in the shader from a Vector2.
  19784. * @param name Define the name of the uniform as defined in the shader
  19785. * @param value Define the value to give to the uniform
  19786. * @return the material itself allowing "fluent" like uniform updates
  19787. */
  19788. setVector2(name: string, value: Vector2): ShaderMaterial;
  19789. /**
  19790. * Set a vec3 in the shader from a Vector3.
  19791. * @param name Define the name of the uniform as defined in the shader
  19792. * @param value Define the value to give to the uniform
  19793. * @return the material itself allowing "fluent" like uniform updates
  19794. */
  19795. setVector3(name: string, value: Vector3): ShaderMaterial;
  19796. /**
  19797. * Set a vec4 in the shader from a Vector4.
  19798. * @param name Define the name of the uniform as defined in the shader
  19799. * @param value Define the value to give to the uniform
  19800. * @return the material itself allowing "fluent" like uniform updates
  19801. */
  19802. setVector4(name: string, value: Vector4): ShaderMaterial;
  19803. /**
  19804. * Set a mat4 in the shader from a Matrix.
  19805. * @param name Define the name of the uniform as defined in the shader
  19806. * @param value Define the value to give to the uniform
  19807. * @return the material itself allowing "fluent" like uniform updates
  19808. */
  19809. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19810. /**
  19811. * Set a float32Array in the shader from a matrix array.
  19812. * @param name Define the name of the uniform as defined in the shader
  19813. * @param value Define the value to give to the uniform
  19814. * @return the material itself allowing "fluent" like uniform updates
  19815. */
  19816. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19817. /**
  19818. * Set a mat3 in the shader from a Float32Array.
  19819. * @param name Define the name of the uniform as defined in the shader
  19820. * @param value Define the value to give to the uniform
  19821. * @return the material itself allowing "fluent" like uniform updates
  19822. */
  19823. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19824. /**
  19825. * Set a mat2 in the shader from a Float32Array.
  19826. * @param name Define the name of the uniform as defined in the shader
  19827. * @param value Define the value to give to the uniform
  19828. * @return the material itself allowing "fluent" like uniform updates
  19829. */
  19830. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19831. /**
  19832. * Set a vec2 array in the shader from a number array.
  19833. * @param name Define the name of the uniform as defined in the shader
  19834. * @param value Define the value to give to the uniform
  19835. * @return the material itself allowing "fluent" like uniform updates
  19836. */
  19837. setArray2(name: string, value: number[]): ShaderMaterial;
  19838. /**
  19839. * Set a vec3 array in the shader from a number array.
  19840. * @param name Define the name of the uniform as defined in the shader
  19841. * @param value Define the value to give to the uniform
  19842. * @return the material itself allowing "fluent" like uniform updates
  19843. */
  19844. setArray3(name: string, value: number[]): ShaderMaterial;
  19845. /**
  19846. * Set a vec4 array in the shader from a number array.
  19847. * @param name Define the name of the uniform as defined in the shader
  19848. * @param value Define the value to give to the uniform
  19849. * @return the material itself allowing "fluent" like uniform updates
  19850. */
  19851. setArray4(name: string, value: number[]): ShaderMaterial;
  19852. private _checkCache;
  19853. /**
  19854. * Specifies that the submesh is ready to be used
  19855. * @param mesh defines the mesh to check
  19856. * @param subMesh defines which submesh to check
  19857. * @param useInstances specifies that instances should be used
  19858. * @returns a boolean indicating that the submesh is ready or not
  19859. */
  19860. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19861. /**
  19862. * Checks if the material is ready to render the requested mesh
  19863. * @param mesh Define the mesh to render
  19864. * @param useInstances Define whether or not the material is used with instances
  19865. * @returns true if ready, otherwise false
  19866. */
  19867. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19868. /**
  19869. * Binds the world matrix to the material
  19870. * @param world defines the world transformation matrix
  19871. */
  19872. bindOnlyWorldMatrix(world: Matrix): void;
  19873. /**
  19874. * Binds the material to the mesh
  19875. * @param world defines the world transformation matrix
  19876. * @param mesh defines the mesh to bind the material to
  19877. */
  19878. bind(world: Matrix, mesh?: Mesh): void;
  19879. /**
  19880. * Gets the active textures from the material
  19881. * @returns an array of textures
  19882. */
  19883. getActiveTextures(): BaseTexture[];
  19884. /**
  19885. * Specifies if the material uses a texture
  19886. * @param texture defines the texture to check against the material
  19887. * @returns a boolean specifying if the material uses the texture
  19888. */
  19889. hasTexture(texture: BaseTexture): boolean;
  19890. /**
  19891. * Makes a duplicate of the material, and gives it a new name
  19892. * @param name defines the new name for the duplicated material
  19893. * @returns the cloned material
  19894. */
  19895. clone(name: string): ShaderMaterial;
  19896. /**
  19897. * Disposes the material
  19898. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19899. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19900. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19901. */
  19902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19903. /**
  19904. * Serializes this material in a JSON representation
  19905. * @returns the serialized material object
  19906. */
  19907. serialize(): any;
  19908. /**
  19909. * Creates a shader material from parsed shader material data
  19910. * @param source defines the JSON represnetation of the material
  19911. * @param scene defines the hosting scene
  19912. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19913. * @returns a new material
  19914. */
  19915. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19916. }
  19917. }
  19918. declare module "babylonjs/Shaders/color.fragment" {
  19919. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19920. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19921. /** @hidden */
  19922. export var colorPixelShader: {
  19923. name: string;
  19924. shader: string;
  19925. };
  19926. }
  19927. declare module "babylonjs/Shaders/color.vertex" {
  19928. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19929. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19930. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19931. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19932. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19933. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19934. /** @hidden */
  19935. export var colorVertexShader: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module "babylonjs/Meshes/linesMesh" {
  19941. import { Nullable } from "babylonjs/types";
  19942. import { Scene } from "babylonjs/scene";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { Node } from "babylonjs/node";
  19945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19946. import { Mesh } from "babylonjs/Meshes/mesh";
  19947. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19948. import { Effect } from "babylonjs/Materials/effect";
  19949. import { Material } from "babylonjs/Materials/material";
  19950. import "babylonjs/Shaders/color.fragment";
  19951. import "babylonjs/Shaders/color.vertex";
  19952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19953. /**
  19954. * Line mesh
  19955. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19956. */
  19957. export class LinesMesh extends Mesh {
  19958. /**
  19959. * If vertex color should be applied to the mesh
  19960. */
  19961. readonly useVertexColor?: boolean | undefined;
  19962. /**
  19963. * If vertex alpha should be applied to the mesh
  19964. */
  19965. readonly useVertexAlpha?: boolean | undefined;
  19966. /**
  19967. * Color of the line (Default: White)
  19968. */
  19969. color: Color3;
  19970. /**
  19971. * Alpha of the line (Default: 1)
  19972. */
  19973. alpha: number;
  19974. /**
  19975. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19976. * This margin is expressed in world space coordinates, so its value may vary.
  19977. * Default value is 0.1
  19978. */
  19979. intersectionThreshold: number;
  19980. private _colorShader;
  19981. private color4;
  19982. /**
  19983. * Creates a new LinesMesh
  19984. * @param name defines the name
  19985. * @param scene defines the hosting scene
  19986. * @param parent defines the parent mesh if any
  19987. * @param source defines the optional source LinesMesh used to clone data from
  19988. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19989. * When false, achieved by calling a clone(), also passing False.
  19990. * This will make creation of children, recursive.
  19991. * @param useVertexColor defines if this LinesMesh supports vertex color
  19992. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19993. */
  19994. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19995. /**
  19996. * If vertex color should be applied to the mesh
  19997. */
  19998. useVertexColor?: boolean | undefined,
  19999. /**
  20000. * If vertex alpha should be applied to the mesh
  20001. */
  20002. useVertexAlpha?: boolean | undefined);
  20003. private _addClipPlaneDefine;
  20004. private _removeClipPlaneDefine;
  20005. isReady(): boolean;
  20006. /**
  20007. * Returns the string "LineMesh"
  20008. */
  20009. getClassName(): string;
  20010. /**
  20011. * @hidden
  20012. */
  20013. /**
  20014. * @hidden
  20015. */
  20016. material: Material;
  20017. /**
  20018. * @hidden
  20019. */
  20020. readonly checkCollisions: boolean;
  20021. /** @hidden */
  20022. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20023. /** @hidden */
  20024. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20025. /**
  20026. * Disposes of the line mesh
  20027. * @param doNotRecurse If children should be disposed
  20028. */
  20029. dispose(doNotRecurse?: boolean): void;
  20030. /**
  20031. * Returns a new LineMesh object cloned from the current one.
  20032. */
  20033. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20034. /**
  20035. * Creates a new InstancedLinesMesh object from the mesh model.
  20036. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20037. * @param name defines the name of the new instance
  20038. * @returns a new InstancedLinesMesh
  20039. */
  20040. createInstance(name: string): InstancedLinesMesh;
  20041. }
  20042. /**
  20043. * Creates an instance based on a source LinesMesh
  20044. */
  20045. export class InstancedLinesMesh extends InstancedMesh {
  20046. /**
  20047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20048. * This margin is expressed in world space coordinates, so its value may vary.
  20049. * Initilized with the intersectionThreshold value of the source LinesMesh
  20050. */
  20051. intersectionThreshold: number;
  20052. constructor(name: string, source: LinesMesh);
  20053. /**
  20054. * Returns the string "InstancedLinesMesh".
  20055. */
  20056. getClassName(): string;
  20057. }
  20058. }
  20059. declare module "babylonjs/Shaders/line.fragment" {
  20060. /** @hidden */
  20061. export var linePixelShader: {
  20062. name: string;
  20063. shader: string;
  20064. };
  20065. }
  20066. declare module "babylonjs/Shaders/line.vertex" {
  20067. /** @hidden */
  20068. export var lineVertexShader: {
  20069. name: string;
  20070. shader: string;
  20071. };
  20072. }
  20073. declare module "babylonjs/Rendering/edgesRenderer" {
  20074. import { Nullable } from "babylonjs/types";
  20075. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20077. import { Vector3 } from "babylonjs/Maths/math.vector";
  20078. import { IDisposable } from "babylonjs/scene";
  20079. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20080. import "babylonjs/Shaders/line.fragment";
  20081. import "babylonjs/Shaders/line.vertex";
  20082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20083. module "babylonjs/Meshes/abstractMesh" {
  20084. interface AbstractMesh {
  20085. /**
  20086. * Gets the edgesRenderer associated with the mesh
  20087. */
  20088. edgesRenderer: Nullable<EdgesRenderer>;
  20089. }
  20090. }
  20091. module "babylonjs/Meshes/linesMesh" {
  20092. interface LinesMesh {
  20093. /**
  20094. * Enables the edge rendering mode on the mesh.
  20095. * This mode makes the mesh edges visible
  20096. * @param epsilon defines the maximal distance between two angles to detect a face
  20097. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20098. * @returns the currentAbstractMesh
  20099. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20100. */
  20101. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20102. }
  20103. }
  20104. module "babylonjs/Meshes/linesMesh" {
  20105. interface InstancedLinesMesh {
  20106. /**
  20107. * Enables the edge rendering mode on the mesh.
  20108. * This mode makes the mesh edges visible
  20109. * @param epsilon defines the maximal distance between two angles to detect a face
  20110. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20111. * @returns the current InstancedLinesMesh
  20112. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20113. */
  20114. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20115. }
  20116. }
  20117. /**
  20118. * Defines the minimum contract an Edges renderer should follow.
  20119. */
  20120. export interface IEdgesRenderer extends IDisposable {
  20121. /**
  20122. * Gets or sets a boolean indicating if the edgesRenderer is active
  20123. */
  20124. isEnabled: boolean;
  20125. /**
  20126. * Renders the edges of the attached mesh,
  20127. */
  20128. render(): void;
  20129. /**
  20130. * Checks wether or not the edges renderer is ready to render.
  20131. * @return true if ready, otherwise false.
  20132. */
  20133. isReady(): boolean;
  20134. }
  20135. /**
  20136. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20137. */
  20138. export class EdgesRenderer implements IEdgesRenderer {
  20139. /**
  20140. * Define the size of the edges with an orthographic camera
  20141. */
  20142. edgesWidthScalerForOrthographic: number;
  20143. /**
  20144. * Define the size of the edges with a perspective camera
  20145. */
  20146. edgesWidthScalerForPerspective: number;
  20147. protected _source: AbstractMesh;
  20148. protected _linesPositions: number[];
  20149. protected _linesNormals: number[];
  20150. protected _linesIndices: number[];
  20151. protected _epsilon: number;
  20152. protected _indicesCount: number;
  20153. protected _lineShader: ShaderMaterial;
  20154. protected _ib: DataBuffer;
  20155. protected _buffers: {
  20156. [key: string]: Nullable<VertexBuffer>;
  20157. };
  20158. protected _checkVerticesInsteadOfIndices: boolean;
  20159. private _meshRebuildObserver;
  20160. private _meshDisposeObserver;
  20161. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20162. isEnabled: boolean;
  20163. /**
  20164. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20165. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20166. * @param source Mesh used to create edges
  20167. * @param epsilon sum of angles in adjacency to check for edge
  20168. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20169. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20170. */
  20171. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20172. protected _prepareRessources(): void;
  20173. /** @hidden */
  20174. _rebuild(): void;
  20175. /**
  20176. * Releases the required resources for the edges renderer
  20177. */
  20178. dispose(): void;
  20179. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20180. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20181. /**
  20182. * Checks if the pair of p0 and p1 is en edge
  20183. * @param faceIndex
  20184. * @param edge
  20185. * @param faceNormals
  20186. * @param p0
  20187. * @param p1
  20188. * @private
  20189. */
  20190. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20191. /**
  20192. * push line into the position, normal and index buffer
  20193. * @protected
  20194. */
  20195. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20196. /**
  20197. * Generates lines edges from adjacencjes
  20198. * @private
  20199. */
  20200. _generateEdgesLines(): void;
  20201. /**
  20202. * Checks wether or not the edges renderer is ready to render.
  20203. * @return true if ready, otherwise false.
  20204. */
  20205. isReady(): boolean;
  20206. /**
  20207. * Renders the edges of the attached mesh,
  20208. */
  20209. render(): void;
  20210. }
  20211. /**
  20212. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20213. */
  20214. export class LineEdgesRenderer extends EdgesRenderer {
  20215. /**
  20216. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20217. * @param source LineMesh used to generate edges
  20218. * @param epsilon not important (specified angle for edge detection)
  20219. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20220. */
  20221. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20222. /**
  20223. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20224. */
  20225. _generateEdgesLines(): void;
  20226. }
  20227. }
  20228. declare module "babylonjs/Rendering/renderingGroup" {
  20229. import { SmartArray } from "babylonjs/Misc/smartArray";
  20230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20232. import { Nullable } from "babylonjs/types";
  20233. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20234. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20235. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20236. import { Material } from "babylonjs/Materials/material";
  20237. import { Scene } from "babylonjs/scene";
  20238. /**
  20239. * This represents the object necessary to create a rendering group.
  20240. * This is exclusively used and created by the rendering manager.
  20241. * To modify the behavior, you use the available helpers in your scene or meshes.
  20242. * @hidden
  20243. */
  20244. export class RenderingGroup {
  20245. index: number;
  20246. private static _zeroVector;
  20247. private _scene;
  20248. private _opaqueSubMeshes;
  20249. private _transparentSubMeshes;
  20250. private _alphaTestSubMeshes;
  20251. private _depthOnlySubMeshes;
  20252. private _particleSystems;
  20253. private _spriteManagers;
  20254. private _opaqueSortCompareFn;
  20255. private _alphaTestSortCompareFn;
  20256. private _transparentSortCompareFn;
  20257. private _renderOpaque;
  20258. private _renderAlphaTest;
  20259. private _renderTransparent;
  20260. /** @hidden */
  20261. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20262. onBeforeTransparentRendering: () => void;
  20263. /**
  20264. * Set the opaque sort comparison function.
  20265. * If null the sub meshes will be render in the order they were created
  20266. */
  20267. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20268. /**
  20269. * Set the alpha test sort comparison function.
  20270. * If null the sub meshes will be render in the order they were created
  20271. */
  20272. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20273. /**
  20274. * Set the transparent sort comparison function.
  20275. * If null the sub meshes will be render in the order they were created
  20276. */
  20277. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20278. /**
  20279. * Creates a new rendering group.
  20280. * @param index The rendering group index
  20281. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20282. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20283. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20284. */
  20285. 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>);
  20286. /**
  20287. * Render all the sub meshes contained in the group.
  20288. * @param customRenderFunction Used to override the default render behaviour of the group.
  20289. * @returns true if rendered some submeshes.
  20290. */
  20291. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20292. /**
  20293. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20294. * @param subMeshes The submeshes to render
  20295. */
  20296. private renderOpaqueSorted;
  20297. /**
  20298. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20299. * @param subMeshes The submeshes to render
  20300. */
  20301. private renderAlphaTestSorted;
  20302. /**
  20303. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20304. * @param subMeshes The submeshes to render
  20305. */
  20306. private renderTransparentSorted;
  20307. /**
  20308. * Renders the submeshes in a specified order.
  20309. * @param subMeshes The submeshes to sort before render
  20310. * @param sortCompareFn The comparison function use to sort
  20311. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20312. * @param transparent Specifies to activate blending if true
  20313. */
  20314. private static renderSorted;
  20315. /**
  20316. * Renders the submeshes in the order they were dispatched (no sort applied).
  20317. * @param subMeshes The submeshes to render
  20318. */
  20319. private static renderUnsorted;
  20320. /**
  20321. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20322. * are rendered back to front if in the same alpha index.
  20323. *
  20324. * @param a The first submesh
  20325. * @param b The second submesh
  20326. * @returns The result of the comparison
  20327. */
  20328. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20329. /**
  20330. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20331. * are rendered back to front.
  20332. *
  20333. * @param a The first submesh
  20334. * @param b The second submesh
  20335. * @returns The result of the comparison
  20336. */
  20337. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20338. /**
  20339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20340. * are rendered front to back (prevent overdraw).
  20341. *
  20342. * @param a The first submesh
  20343. * @param b The second submesh
  20344. * @returns The result of the comparison
  20345. */
  20346. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20347. /**
  20348. * Resets the different lists of submeshes to prepare a new frame.
  20349. */
  20350. prepare(): void;
  20351. dispose(): void;
  20352. /**
  20353. * Inserts the submesh in its correct queue depending on its material.
  20354. * @param subMesh The submesh to dispatch
  20355. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20356. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20357. */
  20358. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20359. dispatchSprites(spriteManager: ISpriteManager): void;
  20360. dispatchParticles(particleSystem: IParticleSystem): void;
  20361. private _renderParticles;
  20362. private _renderSprites;
  20363. }
  20364. }
  20365. declare module "babylonjs/Rendering/renderingManager" {
  20366. import { Nullable } from "babylonjs/types";
  20367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20369. import { SmartArray } from "babylonjs/Misc/smartArray";
  20370. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20372. import { Material } from "babylonjs/Materials/material";
  20373. import { Scene } from "babylonjs/scene";
  20374. import { Camera } from "babylonjs/Cameras/camera";
  20375. /**
  20376. * Interface describing the different options available in the rendering manager
  20377. * regarding Auto Clear between groups.
  20378. */
  20379. export interface IRenderingManagerAutoClearSetup {
  20380. /**
  20381. * Defines whether or not autoclear is enable.
  20382. */
  20383. autoClear: boolean;
  20384. /**
  20385. * Defines whether or not to autoclear the depth buffer.
  20386. */
  20387. depth: boolean;
  20388. /**
  20389. * Defines whether or not to autoclear the stencil buffer.
  20390. */
  20391. stencil: boolean;
  20392. }
  20393. /**
  20394. * This class is used by the onRenderingGroupObservable
  20395. */
  20396. export class RenderingGroupInfo {
  20397. /**
  20398. * The Scene that being rendered
  20399. */
  20400. scene: Scene;
  20401. /**
  20402. * The camera currently used for the rendering pass
  20403. */
  20404. camera: Nullable<Camera>;
  20405. /**
  20406. * The ID of the renderingGroup being processed
  20407. */
  20408. renderingGroupId: number;
  20409. }
  20410. /**
  20411. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20412. * It is enable to manage the different groups as well as the different necessary sort functions.
  20413. * This should not be used directly aside of the few static configurations
  20414. */
  20415. export class RenderingManager {
  20416. /**
  20417. * The max id used for rendering groups (not included)
  20418. */
  20419. static MAX_RENDERINGGROUPS: number;
  20420. /**
  20421. * The min id used for rendering groups (included)
  20422. */
  20423. static MIN_RENDERINGGROUPS: number;
  20424. /**
  20425. * Used to globally prevent autoclearing scenes.
  20426. */
  20427. static AUTOCLEAR: boolean;
  20428. /**
  20429. * @hidden
  20430. */
  20431. _useSceneAutoClearSetup: boolean;
  20432. private _scene;
  20433. private _renderingGroups;
  20434. private _depthStencilBufferAlreadyCleaned;
  20435. private _autoClearDepthStencil;
  20436. private _customOpaqueSortCompareFn;
  20437. private _customAlphaTestSortCompareFn;
  20438. private _customTransparentSortCompareFn;
  20439. private _renderingGroupInfo;
  20440. /**
  20441. * Instantiates a new rendering group for a particular scene
  20442. * @param scene Defines the scene the groups belongs to
  20443. */
  20444. constructor(scene: Scene);
  20445. private _clearDepthStencilBuffer;
  20446. /**
  20447. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20448. * @hidden
  20449. */
  20450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20451. /**
  20452. * Resets the different information of the group to prepare a new frame
  20453. * @hidden
  20454. */
  20455. reset(): void;
  20456. /**
  20457. * Dispose and release the group and its associated resources.
  20458. * @hidden
  20459. */
  20460. dispose(): void;
  20461. /**
  20462. * Clear the info related to rendering groups preventing retention points during dispose.
  20463. */
  20464. freeRenderingGroups(): void;
  20465. private _prepareRenderingGroup;
  20466. /**
  20467. * Add a sprite manager to the rendering manager in order to render it this frame.
  20468. * @param spriteManager Define the sprite manager to render
  20469. */
  20470. dispatchSprites(spriteManager: ISpriteManager): void;
  20471. /**
  20472. * Add a particle system to the rendering manager in order to render it this frame.
  20473. * @param particleSystem Define the particle system to render
  20474. */
  20475. dispatchParticles(particleSystem: IParticleSystem): void;
  20476. /**
  20477. * Add a submesh to the manager in order to render it this frame
  20478. * @param subMesh The submesh to dispatch
  20479. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20480. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20481. */
  20482. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20483. /**
  20484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20485. * This allowed control for front to back rendering or reversly depending of the special needs.
  20486. *
  20487. * @param renderingGroupId The rendering group id corresponding to its index
  20488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20491. */
  20492. 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;
  20493. /**
  20494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20495. *
  20496. * @param renderingGroupId The rendering group id corresponding to its index
  20497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20500. */
  20501. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20502. /**
  20503. * Gets the current auto clear configuration for one rendering group of the rendering
  20504. * manager.
  20505. * @param index the rendering group index to get the information for
  20506. * @returns The auto clear setup for the requested rendering group
  20507. */
  20508. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20509. }
  20510. }
  20511. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20512. import { Observable } from "babylonjs/Misc/observable";
  20513. import { SmartArray } from "babylonjs/Misc/smartArray";
  20514. import { Nullable } from "babylonjs/types";
  20515. import { Camera } from "babylonjs/Cameras/camera";
  20516. import { Scene } from "babylonjs/scene";
  20517. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20518. import { Color4 } from "babylonjs/Maths/math.color";
  20519. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20523. import { Texture } from "babylonjs/Materials/Textures/texture";
  20524. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20525. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20526. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20527. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20528. import { Engine } from "babylonjs/Engines/engine";
  20529. /**
  20530. * This Helps creating a texture that will be created from a camera in your scene.
  20531. * It is basically a dynamic texture that could be used to create special effects for instance.
  20532. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20533. */
  20534. export class RenderTargetTexture extends Texture {
  20535. isCube: boolean;
  20536. /**
  20537. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20538. */
  20539. static readonly REFRESHRATE_RENDER_ONCE: number;
  20540. /**
  20541. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20542. */
  20543. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20544. /**
  20545. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20546. * the central point of your effect and can save a lot of performances.
  20547. */
  20548. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20549. /**
  20550. * Use this predicate to dynamically define the list of mesh you want to render.
  20551. * If set, the renderList property will be overwritten.
  20552. */
  20553. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20554. private _renderList;
  20555. /**
  20556. * Use this list to define the list of mesh you want to render.
  20557. */
  20558. renderList: Nullable<Array<AbstractMesh>>;
  20559. private _hookArray;
  20560. /**
  20561. * Define if particles should be rendered in your texture.
  20562. */
  20563. renderParticles: boolean;
  20564. /**
  20565. * Define if sprites should be rendered in your texture.
  20566. */
  20567. renderSprites: boolean;
  20568. /**
  20569. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20570. */
  20571. coordinatesMode: number;
  20572. /**
  20573. * Define the camera used to render the texture.
  20574. */
  20575. activeCamera: Nullable<Camera>;
  20576. /**
  20577. * Override the render function of the texture with your own one.
  20578. */
  20579. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20580. /**
  20581. * Define if camera post processes should be use while rendering the texture.
  20582. */
  20583. useCameraPostProcesses: boolean;
  20584. /**
  20585. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20586. */
  20587. ignoreCameraViewport: boolean;
  20588. private _postProcessManager;
  20589. private _postProcesses;
  20590. private _resizeObserver;
  20591. /**
  20592. * An event triggered when the texture is unbind.
  20593. */
  20594. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20595. /**
  20596. * An event triggered when the texture is unbind.
  20597. */
  20598. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20599. private _onAfterUnbindObserver;
  20600. /**
  20601. * Set a after unbind callback in the texture.
  20602. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20603. */
  20604. onAfterUnbind: () => void;
  20605. /**
  20606. * An event triggered before rendering the texture
  20607. */
  20608. onBeforeRenderObservable: Observable<number>;
  20609. private _onBeforeRenderObserver;
  20610. /**
  20611. * Set a before render callback in the texture.
  20612. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20613. */
  20614. onBeforeRender: (faceIndex: number) => void;
  20615. /**
  20616. * An event triggered after rendering the texture
  20617. */
  20618. onAfterRenderObservable: Observable<number>;
  20619. private _onAfterRenderObserver;
  20620. /**
  20621. * Set a after render callback in the texture.
  20622. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20623. */
  20624. onAfterRender: (faceIndex: number) => void;
  20625. /**
  20626. * An event triggered after the texture clear
  20627. */
  20628. onClearObservable: Observable<Engine>;
  20629. private _onClearObserver;
  20630. /**
  20631. * Set a clear callback in the texture.
  20632. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20633. */
  20634. onClear: (Engine: Engine) => void;
  20635. /**
  20636. * An event triggered when the texture is resized.
  20637. */
  20638. onResizeObservable: Observable<RenderTargetTexture>;
  20639. /**
  20640. * Define the clear color of the Render Target if it should be different from the scene.
  20641. */
  20642. clearColor: Color4;
  20643. protected _size: number | {
  20644. width: number;
  20645. height: number;
  20646. };
  20647. protected _initialSizeParameter: number | {
  20648. width: number;
  20649. height: number;
  20650. } | {
  20651. ratio: number;
  20652. };
  20653. protected _sizeRatio: Nullable<number>;
  20654. /** @hidden */
  20655. _generateMipMaps: boolean;
  20656. protected _renderingManager: RenderingManager;
  20657. /** @hidden */
  20658. _waitingRenderList: string[];
  20659. protected _doNotChangeAspectRatio: boolean;
  20660. protected _currentRefreshId: number;
  20661. protected _refreshRate: number;
  20662. protected _textureMatrix: Matrix;
  20663. protected _samples: number;
  20664. protected _renderTargetOptions: RenderTargetCreationOptions;
  20665. /**
  20666. * Gets render target creation options that were used.
  20667. */
  20668. readonly renderTargetOptions: RenderTargetCreationOptions;
  20669. protected _engine: Engine;
  20670. protected _onRatioRescale(): void;
  20671. /**
  20672. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20673. * It must define where the camera used to render the texture is set
  20674. */
  20675. boundingBoxPosition: Vector3;
  20676. private _boundingBoxSize;
  20677. /**
  20678. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20679. * When defined, the cubemap will switch to local mode
  20680. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20681. * @example https://www.babylonjs-playground.com/#RNASML
  20682. */
  20683. boundingBoxSize: Vector3;
  20684. /**
  20685. * In case the RTT has been created with a depth texture, get the associated
  20686. * depth texture.
  20687. * Otherwise, return null.
  20688. */
  20689. depthStencilTexture: Nullable<InternalTexture>;
  20690. /**
  20691. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20692. * or used a shadow, depth texture...
  20693. * @param name The friendly name of the texture
  20694. * @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)
  20695. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20696. * @param generateMipMaps True if mip maps need to be generated after render.
  20697. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20698. * @param type The type of the buffer in the RTT (int, half float, float...)
  20699. * @param isCube True if a cube texture needs to be created
  20700. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20701. * @param generateDepthBuffer True to generate a depth buffer
  20702. * @param generateStencilBuffer True to generate a stencil buffer
  20703. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20704. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20705. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20706. */
  20707. constructor(name: string, size: number | {
  20708. width: number;
  20709. height: number;
  20710. } | {
  20711. ratio: number;
  20712. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20713. /**
  20714. * Creates a depth stencil texture.
  20715. * This is only available in WebGL 2 or with the depth texture extension available.
  20716. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20717. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20718. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20719. */
  20720. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20721. private _processSizeParameter;
  20722. /**
  20723. * Define the number of samples to use in case of MSAA.
  20724. * It defaults to one meaning no MSAA has been enabled.
  20725. */
  20726. samples: number;
  20727. /**
  20728. * Resets the refresh counter of the texture and start bak from scratch.
  20729. * Could be useful to regenerate the texture if it is setup to render only once.
  20730. */
  20731. resetRefreshCounter(): void;
  20732. /**
  20733. * Define the refresh rate of the texture or the rendering frequency.
  20734. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20735. */
  20736. refreshRate: number;
  20737. /**
  20738. * Adds a post process to the render target rendering passes.
  20739. * @param postProcess define the post process to add
  20740. */
  20741. addPostProcess(postProcess: PostProcess): void;
  20742. /**
  20743. * Clear all the post processes attached to the render target
  20744. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20745. */
  20746. clearPostProcesses(dispose?: boolean): void;
  20747. /**
  20748. * Remove one of the post process from the list of attached post processes to the texture
  20749. * @param postProcess define the post process to remove from the list
  20750. */
  20751. removePostProcess(postProcess: PostProcess): void;
  20752. /** @hidden */
  20753. _shouldRender(): boolean;
  20754. /**
  20755. * Gets the actual render size of the texture.
  20756. * @returns the width of the render size
  20757. */
  20758. getRenderSize(): number;
  20759. /**
  20760. * Gets the actual render width of the texture.
  20761. * @returns the width of the render size
  20762. */
  20763. getRenderWidth(): number;
  20764. /**
  20765. * Gets the actual render height of the texture.
  20766. * @returns the height of the render size
  20767. */
  20768. getRenderHeight(): number;
  20769. /**
  20770. * Get if the texture can be rescaled or not.
  20771. */
  20772. readonly canRescale: boolean;
  20773. /**
  20774. * Resize the texture using a ratio.
  20775. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20776. */
  20777. scale(ratio: number): void;
  20778. /**
  20779. * Get the texture reflection matrix used to rotate/transform the reflection.
  20780. * @returns the reflection matrix
  20781. */
  20782. getReflectionTextureMatrix(): Matrix;
  20783. /**
  20784. * Resize the texture to a new desired size.
  20785. * Be carrefull as it will recreate all the data in the new texture.
  20786. * @param size Define the new size. It can be:
  20787. * - a number for squared texture,
  20788. * - an object containing { width: number, height: number }
  20789. * - or an object containing a ratio { ratio: number }
  20790. */
  20791. resize(size: number | {
  20792. width: number;
  20793. height: number;
  20794. } | {
  20795. ratio: number;
  20796. }): void;
  20797. /**
  20798. * Renders all the objects from the render list into the texture.
  20799. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20800. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20801. */
  20802. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20803. private _bestReflectionRenderTargetDimension;
  20804. /**
  20805. * @hidden
  20806. * @param faceIndex face index to bind to if this is a cubetexture
  20807. */
  20808. _bindFrameBuffer(faceIndex?: number): void;
  20809. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20810. private renderToTarget;
  20811. /**
  20812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20813. * This allowed control for front to back rendering or reversly depending of the special needs.
  20814. *
  20815. * @param renderingGroupId The rendering group id corresponding to its index
  20816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20819. */
  20820. 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;
  20821. /**
  20822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20823. *
  20824. * @param renderingGroupId The rendering group id corresponding to its index
  20825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20826. */
  20827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20828. /**
  20829. * Clones the texture.
  20830. * @returns the cloned texture
  20831. */
  20832. clone(): RenderTargetTexture;
  20833. /**
  20834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20835. * @returns The JSON representation of the texture
  20836. */
  20837. serialize(): any;
  20838. /**
  20839. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20840. */
  20841. disposeFramebufferObjects(): void;
  20842. /**
  20843. * Dispose the texture and release its associated resources.
  20844. */
  20845. dispose(): void;
  20846. /** @hidden */
  20847. _rebuild(): void;
  20848. /**
  20849. * Clear the info related to rendering groups preventing retention point in material dispose.
  20850. */
  20851. freeRenderingGroups(): void;
  20852. /**
  20853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20854. * @returns the view count
  20855. */
  20856. getViewCount(): number;
  20857. }
  20858. }
  20859. declare module "babylonjs/Materials/material" {
  20860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20861. import { SmartArray } from "babylonjs/Misc/smartArray";
  20862. import { Observable } from "babylonjs/Misc/observable";
  20863. import { Nullable } from "babylonjs/types";
  20864. import { Scene } from "babylonjs/scene";
  20865. import { Matrix } from "babylonjs/Maths/math.vector";
  20866. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20869. import { Effect } from "babylonjs/Materials/effect";
  20870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20872. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20873. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20874. import { Mesh } from "babylonjs/Meshes/mesh";
  20875. import { Animation } from "babylonjs/Animations/animation";
  20876. /**
  20877. * Options for compiling materials.
  20878. */
  20879. export interface IMaterialCompilationOptions {
  20880. /**
  20881. * Defines whether clip planes are enabled.
  20882. */
  20883. clipPlane: boolean;
  20884. /**
  20885. * Defines whether instances are enabled.
  20886. */
  20887. useInstances: boolean;
  20888. }
  20889. /**
  20890. * Base class for the main features of a material in Babylon.js
  20891. */
  20892. export class Material implements IAnimatable {
  20893. /**
  20894. * Returns the triangle fill mode
  20895. */
  20896. static readonly TriangleFillMode: number;
  20897. /**
  20898. * Returns the wireframe mode
  20899. */
  20900. static readonly WireFrameFillMode: number;
  20901. /**
  20902. * Returns the point fill mode
  20903. */
  20904. static readonly PointFillMode: number;
  20905. /**
  20906. * Returns the point list draw mode
  20907. */
  20908. static readonly PointListDrawMode: number;
  20909. /**
  20910. * Returns the line list draw mode
  20911. */
  20912. static readonly LineListDrawMode: number;
  20913. /**
  20914. * Returns the line loop draw mode
  20915. */
  20916. static readonly LineLoopDrawMode: number;
  20917. /**
  20918. * Returns the line strip draw mode
  20919. */
  20920. static readonly LineStripDrawMode: number;
  20921. /**
  20922. * Returns the triangle strip draw mode
  20923. */
  20924. static readonly TriangleStripDrawMode: number;
  20925. /**
  20926. * Returns the triangle fan draw mode
  20927. */
  20928. static readonly TriangleFanDrawMode: number;
  20929. /**
  20930. * Stores the clock-wise side orientation
  20931. */
  20932. static readonly ClockWiseSideOrientation: number;
  20933. /**
  20934. * Stores the counter clock-wise side orientation
  20935. */
  20936. static readonly CounterClockWiseSideOrientation: number;
  20937. /**
  20938. * The dirty texture flag value
  20939. */
  20940. static readonly TextureDirtyFlag: number;
  20941. /**
  20942. * The dirty light flag value
  20943. */
  20944. static readonly LightDirtyFlag: number;
  20945. /**
  20946. * The dirty fresnel flag value
  20947. */
  20948. static readonly FresnelDirtyFlag: number;
  20949. /**
  20950. * The dirty attribute flag value
  20951. */
  20952. static readonly AttributesDirtyFlag: number;
  20953. /**
  20954. * The dirty misc flag value
  20955. */
  20956. static readonly MiscDirtyFlag: number;
  20957. /**
  20958. * The all dirty flag value
  20959. */
  20960. static readonly AllDirtyFlag: number;
  20961. /**
  20962. * The ID of the material
  20963. */
  20964. id: string;
  20965. /**
  20966. * Gets or sets the unique id of the material
  20967. */
  20968. uniqueId: number;
  20969. /**
  20970. * The name of the material
  20971. */
  20972. name: string;
  20973. /**
  20974. * Gets or sets user defined metadata
  20975. */
  20976. metadata: any;
  20977. /**
  20978. * For internal use only. Please do not use.
  20979. */
  20980. reservedDataStore: any;
  20981. /**
  20982. * Specifies if the ready state should be checked on each call
  20983. */
  20984. checkReadyOnEveryCall: boolean;
  20985. /**
  20986. * Specifies if the ready state should be checked once
  20987. */
  20988. checkReadyOnlyOnce: boolean;
  20989. /**
  20990. * The state of the material
  20991. */
  20992. state: string;
  20993. /**
  20994. * The alpha value of the material
  20995. */
  20996. protected _alpha: number;
  20997. /**
  20998. * List of inspectable custom properties (used by the Inspector)
  20999. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21000. */
  21001. inspectableCustomProperties: IInspectable[];
  21002. /**
  21003. * Sets the alpha value of the material
  21004. */
  21005. /**
  21006. * Gets the alpha value of the material
  21007. */
  21008. alpha: number;
  21009. /**
  21010. * Specifies if back face culling is enabled
  21011. */
  21012. protected _backFaceCulling: boolean;
  21013. /**
  21014. * Sets the back-face culling state
  21015. */
  21016. /**
  21017. * Gets the back-face culling state
  21018. */
  21019. backFaceCulling: boolean;
  21020. /**
  21021. * Stores the value for side orientation
  21022. */
  21023. sideOrientation: number;
  21024. /**
  21025. * Callback triggered when the material is compiled
  21026. */
  21027. onCompiled: Nullable<(effect: Effect) => void>;
  21028. /**
  21029. * Callback triggered when an error occurs
  21030. */
  21031. onError: Nullable<(effect: Effect, errors: string) => void>;
  21032. /**
  21033. * Callback triggered to get the render target textures
  21034. */
  21035. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21036. /**
  21037. * Gets a boolean indicating that current material needs to register RTT
  21038. */
  21039. readonly hasRenderTargetTextures: boolean;
  21040. /**
  21041. * Specifies if the material should be serialized
  21042. */
  21043. doNotSerialize: boolean;
  21044. /**
  21045. * @hidden
  21046. */
  21047. _storeEffectOnSubMeshes: boolean;
  21048. /**
  21049. * Stores the animations for the material
  21050. */
  21051. animations: Nullable<Array<Animation>>;
  21052. /**
  21053. * An event triggered when the material is disposed
  21054. */
  21055. onDisposeObservable: Observable<Material>;
  21056. /**
  21057. * An observer which watches for dispose events
  21058. */
  21059. private _onDisposeObserver;
  21060. private _onUnBindObservable;
  21061. /**
  21062. * Called during a dispose event
  21063. */
  21064. onDispose: () => void;
  21065. private _onBindObservable;
  21066. /**
  21067. * An event triggered when the material is bound
  21068. */
  21069. readonly onBindObservable: Observable<AbstractMesh>;
  21070. /**
  21071. * An observer which watches for bind events
  21072. */
  21073. private _onBindObserver;
  21074. /**
  21075. * Called during a bind event
  21076. */
  21077. onBind: (Mesh: AbstractMesh) => void;
  21078. /**
  21079. * An event triggered when the material is unbound
  21080. */
  21081. readonly onUnBindObservable: Observable<Material>;
  21082. /**
  21083. * Stores the value of the alpha mode
  21084. */
  21085. private _alphaMode;
  21086. /**
  21087. * Sets the value of the alpha mode.
  21088. *
  21089. * | Value | Type | Description |
  21090. * | --- | --- | --- |
  21091. * | 0 | ALPHA_DISABLE | |
  21092. * | 1 | ALPHA_ADD | |
  21093. * | 2 | ALPHA_COMBINE | |
  21094. * | 3 | ALPHA_SUBTRACT | |
  21095. * | 4 | ALPHA_MULTIPLY | |
  21096. * | 5 | ALPHA_MAXIMIZED | |
  21097. * | 6 | ALPHA_ONEONE | |
  21098. * | 7 | ALPHA_PREMULTIPLIED | |
  21099. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21100. * | 9 | ALPHA_INTERPOLATE | |
  21101. * | 10 | ALPHA_SCREENMODE | |
  21102. *
  21103. */
  21104. /**
  21105. * Gets the value of the alpha mode
  21106. */
  21107. alphaMode: number;
  21108. /**
  21109. * Stores the state of the need depth pre-pass value
  21110. */
  21111. private _needDepthPrePass;
  21112. /**
  21113. * Sets the need depth pre-pass value
  21114. */
  21115. /**
  21116. * Gets the depth pre-pass value
  21117. */
  21118. needDepthPrePass: boolean;
  21119. /**
  21120. * Specifies if depth writing should be disabled
  21121. */
  21122. disableDepthWrite: boolean;
  21123. /**
  21124. * Specifies if depth writing should be forced
  21125. */
  21126. forceDepthWrite: boolean;
  21127. /**
  21128. * Specifies if there should be a separate pass for culling
  21129. */
  21130. separateCullingPass: boolean;
  21131. /**
  21132. * Stores the state specifing if fog should be enabled
  21133. */
  21134. private _fogEnabled;
  21135. /**
  21136. * Sets the state for enabling fog
  21137. */
  21138. /**
  21139. * Gets the value of the fog enabled state
  21140. */
  21141. fogEnabled: boolean;
  21142. /**
  21143. * Stores the size of points
  21144. */
  21145. pointSize: number;
  21146. /**
  21147. * Stores the z offset value
  21148. */
  21149. zOffset: number;
  21150. /**
  21151. * Gets a value specifying if wireframe mode is enabled
  21152. */
  21153. /**
  21154. * Sets the state of wireframe mode
  21155. */
  21156. wireframe: boolean;
  21157. /**
  21158. * Gets the value specifying if point clouds are enabled
  21159. */
  21160. /**
  21161. * Sets the state of point cloud mode
  21162. */
  21163. pointsCloud: boolean;
  21164. /**
  21165. * Gets the material fill mode
  21166. */
  21167. /**
  21168. * Sets the material fill mode
  21169. */
  21170. fillMode: number;
  21171. /**
  21172. * @hidden
  21173. * Stores the effects for the material
  21174. */
  21175. _effect: Nullable<Effect>;
  21176. /**
  21177. * @hidden
  21178. * Specifies if the material was previously ready
  21179. */
  21180. _wasPreviouslyReady: boolean;
  21181. /**
  21182. * Specifies if uniform buffers should be used
  21183. */
  21184. private _useUBO;
  21185. /**
  21186. * Stores a reference to the scene
  21187. */
  21188. private _scene;
  21189. /**
  21190. * Stores the fill mode state
  21191. */
  21192. private _fillMode;
  21193. /**
  21194. * Specifies if the depth write state should be cached
  21195. */
  21196. private _cachedDepthWriteState;
  21197. /**
  21198. * Stores the uniform buffer
  21199. */
  21200. protected _uniformBuffer: UniformBuffer;
  21201. /** @hidden */
  21202. _indexInSceneMaterialArray: number;
  21203. /** @hidden */
  21204. meshMap: Nullable<{
  21205. [id: string]: AbstractMesh | undefined;
  21206. }>;
  21207. /**
  21208. * Creates a material instance
  21209. * @param name defines the name of the material
  21210. * @param scene defines the scene to reference
  21211. * @param doNotAdd specifies if the material should be added to the scene
  21212. */
  21213. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21214. /**
  21215. * Returns a string representation of the current material
  21216. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21217. * @returns a string with material information
  21218. */
  21219. toString(fullDetails?: boolean): string;
  21220. /**
  21221. * Gets the class name of the material
  21222. * @returns a string with the class name of the material
  21223. */
  21224. getClassName(): string;
  21225. /**
  21226. * Specifies if updates for the material been locked
  21227. */
  21228. readonly isFrozen: boolean;
  21229. /**
  21230. * Locks updates for the material
  21231. */
  21232. freeze(): void;
  21233. /**
  21234. * Unlocks updates for the material
  21235. */
  21236. unfreeze(): void;
  21237. /**
  21238. * Specifies if the material is ready to be used
  21239. * @param mesh defines the mesh to check
  21240. * @param useInstances specifies if instances should be used
  21241. * @returns a boolean indicating if the material is ready to be used
  21242. */
  21243. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21244. /**
  21245. * Specifies that the submesh is ready to be used
  21246. * @param mesh defines the mesh to check
  21247. * @param subMesh defines which submesh to check
  21248. * @param useInstances specifies that instances should be used
  21249. * @returns a boolean indicating that the submesh is ready or not
  21250. */
  21251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21252. /**
  21253. * Returns the material effect
  21254. * @returns the effect associated with the material
  21255. */
  21256. getEffect(): Nullable<Effect>;
  21257. /**
  21258. * Returns the current scene
  21259. * @returns a Scene
  21260. */
  21261. getScene(): Scene;
  21262. /**
  21263. * Specifies if the material will require alpha blending
  21264. * @returns a boolean specifying if alpha blending is needed
  21265. */
  21266. needAlphaBlending(): boolean;
  21267. /**
  21268. * Specifies if the mesh will require alpha blending
  21269. * @param mesh defines the mesh to check
  21270. * @returns a boolean specifying if alpha blending is needed for the mesh
  21271. */
  21272. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21273. /**
  21274. * Specifies if this material should be rendered in alpha test mode
  21275. * @returns a boolean specifying if an alpha test is needed.
  21276. */
  21277. needAlphaTesting(): boolean;
  21278. /**
  21279. * Gets the texture used for the alpha test
  21280. * @returns the texture to use for alpha testing
  21281. */
  21282. getAlphaTestTexture(): Nullable<BaseTexture>;
  21283. /**
  21284. * Marks the material to indicate that it needs to be re-calculated
  21285. */
  21286. markDirty(): void;
  21287. /** @hidden */
  21288. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21289. /**
  21290. * Binds the material to the mesh
  21291. * @param world defines the world transformation matrix
  21292. * @param mesh defines the mesh to bind the material to
  21293. */
  21294. bind(world: Matrix, mesh?: Mesh): void;
  21295. /**
  21296. * Binds the submesh to the material
  21297. * @param world defines the world transformation matrix
  21298. * @param mesh defines the mesh containing the submesh
  21299. * @param subMesh defines the submesh to bind the material to
  21300. */
  21301. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21302. /**
  21303. * Binds the world matrix to the material
  21304. * @param world defines the world transformation matrix
  21305. */
  21306. bindOnlyWorldMatrix(world: Matrix): void;
  21307. /**
  21308. * Binds the scene's uniform buffer to the effect.
  21309. * @param effect defines the effect to bind to the scene uniform buffer
  21310. * @param sceneUbo defines the uniform buffer storing scene data
  21311. */
  21312. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21313. /**
  21314. * Binds the view matrix to the effect
  21315. * @param effect defines the effect to bind the view matrix to
  21316. */
  21317. bindView(effect: Effect): void;
  21318. /**
  21319. * Binds the view projection matrix to the effect
  21320. * @param effect defines the effect to bind the view projection matrix to
  21321. */
  21322. bindViewProjection(effect: Effect): void;
  21323. /**
  21324. * Specifies if material alpha testing should be turned on for the mesh
  21325. * @param mesh defines the mesh to check
  21326. */
  21327. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21328. /**
  21329. * Processes to execute after binding the material to a mesh
  21330. * @param mesh defines the rendered mesh
  21331. */
  21332. protected _afterBind(mesh?: Mesh): void;
  21333. /**
  21334. * Unbinds the material from the mesh
  21335. */
  21336. unbind(): void;
  21337. /**
  21338. * Gets the active textures from the material
  21339. * @returns an array of textures
  21340. */
  21341. getActiveTextures(): BaseTexture[];
  21342. /**
  21343. * Specifies if the material uses a texture
  21344. * @param texture defines the texture to check against the material
  21345. * @returns a boolean specifying if the material uses the texture
  21346. */
  21347. hasTexture(texture: BaseTexture): boolean;
  21348. /**
  21349. * Makes a duplicate of the material, and gives it a new name
  21350. * @param name defines the new name for the duplicated material
  21351. * @returns the cloned material
  21352. */
  21353. clone(name: string): Nullable<Material>;
  21354. /**
  21355. * Gets the meshes bound to the material
  21356. * @returns an array of meshes bound to the material
  21357. */
  21358. getBindedMeshes(): AbstractMesh[];
  21359. /**
  21360. * Force shader compilation
  21361. * @param mesh defines the mesh associated with this material
  21362. * @param onCompiled defines a function to execute once the material is compiled
  21363. * @param options defines the options to configure the compilation
  21364. * @param onError defines a function to execute if the material fails compiling
  21365. */
  21366. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21367. /**
  21368. * Force shader compilation
  21369. * @param mesh defines the mesh that will use this material
  21370. * @param options defines additional options for compiling the shaders
  21371. * @returns a promise that resolves when the compilation completes
  21372. */
  21373. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21374. private static readonly _AllDirtyCallBack;
  21375. private static readonly _ImageProcessingDirtyCallBack;
  21376. private static readonly _TextureDirtyCallBack;
  21377. private static readonly _FresnelDirtyCallBack;
  21378. private static readonly _MiscDirtyCallBack;
  21379. private static readonly _LightsDirtyCallBack;
  21380. private static readonly _AttributeDirtyCallBack;
  21381. private static _FresnelAndMiscDirtyCallBack;
  21382. private static _TextureAndMiscDirtyCallBack;
  21383. private static readonly _DirtyCallbackArray;
  21384. private static readonly _RunDirtyCallBacks;
  21385. /**
  21386. * Marks a define in the material to indicate that it needs to be re-computed
  21387. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21388. */
  21389. markAsDirty(flag: number): void;
  21390. /**
  21391. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21392. * @param func defines a function which checks material defines against the submeshes
  21393. */
  21394. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21395. /**
  21396. * Indicates that we need to re-calculated for all submeshes
  21397. */
  21398. protected _markAllSubMeshesAsAllDirty(): void;
  21399. /**
  21400. * Indicates that image processing needs to be re-calculated for all submeshes
  21401. */
  21402. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21403. /**
  21404. * Indicates that textures need to be re-calculated for all submeshes
  21405. */
  21406. protected _markAllSubMeshesAsTexturesDirty(): void;
  21407. /**
  21408. * Indicates that fresnel needs to be re-calculated for all submeshes
  21409. */
  21410. protected _markAllSubMeshesAsFresnelDirty(): void;
  21411. /**
  21412. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21413. */
  21414. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21415. /**
  21416. * Indicates that lights need to be re-calculated for all submeshes
  21417. */
  21418. protected _markAllSubMeshesAsLightsDirty(): void;
  21419. /**
  21420. * Indicates that attributes need to be re-calculated for all submeshes
  21421. */
  21422. protected _markAllSubMeshesAsAttributesDirty(): void;
  21423. /**
  21424. * Indicates that misc needs to be re-calculated for all submeshes
  21425. */
  21426. protected _markAllSubMeshesAsMiscDirty(): void;
  21427. /**
  21428. * Indicates that textures and misc need to be re-calculated for all submeshes
  21429. */
  21430. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21431. /**
  21432. * Disposes the material
  21433. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21434. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21435. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21436. */
  21437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21438. /** @hidden */
  21439. private releaseVertexArrayObject;
  21440. /**
  21441. * Serializes this material
  21442. * @returns the serialized material object
  21443. */
  21444. serialize(): any;
  21445. /**
  21446. * Creates a material from parsed material data
  21447. * @param parsedMaterial defines parsed material data
  21448. * @param scene defines the hosting scene
  21449. * @param rootUrl defines the root URL to use to load textures
  21450. * @returns a new material
  21451. */
  21452. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21453. }
  21454. }
  21455. declare module "babylonjs/Materials/multiMaterial" {
  21456. import { Nullable } from "babylonjs/types";
  21457. import { Scene } from "babylonjs/scene";
  21458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21459. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21461. import { Material } from "babylonjs/Materials/material";
  21462. /**
  21463. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21464. * separate meshes. This can be use to improve performances.
  21465. * @see http://doc.babylonjs.com/how_to/multi_materials
  21466. */
  21467. export class MultiMaterial extends Material {
  21468. private _subMaterials;
  21469. /**
  21470. * Gets or Sets the list of Materials used within the multi material.
  21471. * They need to be ordered according to the submeshes order in the associated mesh
  21472. */
  21473. subMaterials: Nullable<Material>[];
  21474. /**
  21475. * Function used to align with Node.getChildren()
  21476. * @returns the list of Materials used within the multi material
  21477. */
  21478. getChildren(): Nullable<Material>[];
  21479. /**
  21480. * Instantiates a new Multi Material
  21481. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21482. * separate meshes. This can be use to improve performances.
  21483. * @see http://doc.babylonjs.com/how_to/multi_materials
  21484. * @param name Define the name in the scene
  21485. * @param scene Define the scene the material belongs to
  21486. */
  21487. constructor(name: string, scene: Scene);
  21488. private _hookArray;
  21489. /**
  21490. * Get one of the submaterial by its index in the submaterials array
  21491. * @param index The index to look the sub material at
  21492. * @returns The Material if the index has been defined
  21493. */
  21494. getSubMaterial(index: number): Nullable<Material>;
  21495. /**
  21496. * Get the list of active textures for the whole sub materials list.
  21497. * @returns All the textures that will be used during the rendering
  21498. */
  21499. getActiveTextures(): BaseTexture[];
  21500. /**
  21501. * Gets the current class name of the material e.g. "MultiMaterial"
  21502. * Mainly use in serialization.
  21503. * @returns the class name
  21504. */
  21505. getClassName(): string;
  21506. /**
  21507. * Checks if the material is ready to render the requested sub mesh
  21508. * @param mesh Define the mesh the submesh belongs to
  21509. * @param subMesh Define the sub mesh to look readyness for
  21510. * @param useInstances Define whether or not the material is used with instances
  21511. * @returns true if ready, otherwise false
  21512. */
  21513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21514. /**
  21515. * Clones the current material and its related sub materials
  21516. * @param name Define the name of the newly cloned material
  21517. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21518. * @returns the cloned material
  21519. */
  21520. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21521. /**
  21522. * Serializes the materials into a JSON representation.
  21523. * @returns the JSON representation
  21524. */
  21525. serialize(): any;
  21526. /**
  21527. * Dispose the material and release its associated resources
  21528. * @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)
  21529. * @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)
  21530. * @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)
  21531. */
  21532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21533. /**
  21534. * Creates a MultiMaterial from parsed MultiMaterial data.
  21535. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21536. * @param scene defines the hosting scene
  21537. * @returns a new MultiMaterial
  21538. */
  21539. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21540. }
  21541. }
  21542. declare module "babylonjs/Meshes/subMesh" {
  21543. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21544. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21545. import { Engine } from "babylonjs/Engines/engine";
  21546. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21547. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21548. import { Effect } from "babylonjs/Materials/effect";
  21549. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21550. import { Plane } from "babylonjs/Maths/math.plane";
  21551. import { Collider } from "babylonjs/Collisions/collider";
  21552. import { Material } from "babylonjs/Materials/material";
  21553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21555. import { Mesh } from "babylonjs/Meshes/mesh";
  21556. import { Ray } from "babylonjs/Culling/ray";
  21557. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21558. /**
  21559. * Base class for submeshes
  21560. */
  21561. export class BaseSubMesh {
  21562. /** @hidden */
  21563. _materialDefines: Nullable<MaterialDefines>;
  21564. /** @hidden */
  21565. _materialEffect: Nullable<Effect>;
  21566. /**
  21567. * Gets associated effect
  21568. */
  21569. readonly effect: Nullable<Effect>;
  21570. /**
  21571. * Sets associated effect (effect used to render this submesh)
  21572. * @param effect defines the effect to associate with
  21573. * @param defines defines the set of defines used to compile this effect
  21574. */
  21575. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21576. }
  21577. /**
  21578. * Defines a subdivision inside a mesh
  21579. */
  21580. export class SubMesh extends BaseSubMesh implements ICullable {
  21581. /** the material index to use */
  21582. materialIndex: number;
  21583. /** vertex index start */
  21584. verticesStart: number;
  21585. /** vertices count */
  21586. verticesCount: number;
  21587. /** index start */
  21588. indexStart: number;
  21589. /** indices count */
  21590. indexCount: number;
  21591. /** @hidden */
  21592. _linesIndexCount: number;
  21593. private _mesh;
  21594. private _renderingMesh;
  21595. private _boundingInfo;
  21596. private _linesIndexBuffer;
  21597. /** @hidden */
  21598. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21599. /** @hidden */
  21600. _trianglePlanes: Plane[];
  21601. /** @hidden */
  21602. _lastColliderTransformMatrix: Nullable<Matrix>;
  21603. /** @hidden */
  21604. _renderId: number;
  21605. /** @hidden */
  21606. _alphaIndex: number;
  21607. /** @hidden */
  21608. _distanceToCamera: number;
  21609. /** @hidden */
  21610. _id: number;
  21611. private _currentMaterial;
  21612. /**
  21613. * Add a new submesh to a mesh
  21614. * @param materialIndex defines the material index to use
  21615. * @param verticesStart defines vertex index start
  21616. * @param verticesCount defines vertices count
  21617. * @param indexStart defines index start
  21618. * @param indexCount defines indices count
  21619. * @param mesh defines the parent mesh
  21620. * @param renderingMesh defines an optional rendering mesh
  21621. * @param createBoundingBox defines if bounding box should be created for this submesh
  21622. * @returns the new submesh
  21623. */
  21624. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21625. /**
  21626. * Creates a new submesh
  21627. * @param materialIndex defines the material index to use
  21628. * @param verticesStart defines vertex index start
  21629. * @param verticesCount defines vertices count
  21630. * @param indexStart defines index start
  21631. * @param indexCount defines indices count
  21632. * @param mesh defines the parent mesh
  21633. * @param renderingMesh defines an optional rendering mesh
  21634. * @param createBoundingBox defines if bounding box should be created for this submesh
  21635. */
  21636. constructor(
  21637. /** the material index to use */
  21638. materialIndex: number,
  21639. /** vertex index start */
  21640. verticesStart: number,
  21641. /** vertices count */
  21642. verticesCount: number,
  21643. /** index start */
  21644. indexStart: number,
  21645. /** indices count */
  21646. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21647. /**
  21648. * Returns true if this submesh covers the entire parent mesh
  21649. * @ignorenaming
  21650. */
  21651. readonly IsGlobal: boolean;
  21652. /**
  21653. * Returns the submesh BoudingInfo object
  21654. * @returns current bounding info (or mesh's one if the submesh is global)
  21655. */
  21656. getBoundingInfo(): BoundingInfo;
  21657. /**
  21658. * Sets the submesh BoundingInfo
  21659. * @param boundingInfo defines the new bounding info to use
  21660. * @returns the SubMesh
  21661. */
  21662. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21663. /**
  21664. * Returns the mesh of the current submesh
  21665. * @return the parent mesh
  21666. */
  21667. getMesh(): AbstractMesh;
  21668. /**
  21669. * Returns the rendering mesh of the submesh
  21670. * @returns the rendering mesh (could be different from parent mesh)
  21671. */
  21672. getRenderingMesh(): Mesh;
  21673. /**
  21674. * Returns the submesh material
  21675. * @returns null or the current material
  21676. */
  21677. getMaterial(): Nullable<Material>;
  21678. /**
  21679. * Sets a new updated BoundingInfo object to the submesh
  21680. * @param data defines an optional position array to use to determine the bounding info
  21681. * @returns the SubMesh
  21682. */
  21683. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21684. /** @hidden */
  21685. _checkCollision(collider: Collider): boolean;
  21686. /**
  21687. * Updates the submesh BoundingInfo
  21688. * @param world defines the world matrix to use to update the bounding info
  21689. * @returns the submesh
  21690. */
  21691. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21692. /**
  21693. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21694. * @param frustumPlanes defines the frustum planes
  21695. * @returns true if the submesh is intersecting with the frustum
  21696. */
  21697. isInFrustum(frustumPlanes: Plane[]): boolean;
  21698. /**
  21699. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21700. * @param frustumPlanes defines the frustum planes
  21701. * @returns true if the submesh is inside the frustum
  21702. */
  21703. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21704. /**
  21705. * Renders the submesh
  21706. * @param enableAlphaMode defines if alpha needs to be used
  21707. * @returns the submesh
  21708. */
  21709. render(enableAlphaMode: boolean): SubMesh;
  21710. /**
  21711. * @hidden
  21712. */
  21713. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21714. /**
  21715. * Checks if the submesh intersects with a ray
  21716. * @param ray defines the ray to test
  21717. * @returns true is the passed ray intersects the submesh bounding box
  21718. */
  21719. canIntersects(ray: Ray): boolean;
  21720. /**
  21721. * Intersects current submesh with a ray
  21722. * @param ray defines the ray to test
  21723. * @param positions defines mesh's positions array
  21724. * @param indices defines mesh's indices array
  21725. * @param fastCheck defines if only bounding info should be used
  21726. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21727. * @returns intersection info or null if no intersection
  21728. */
  21729. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21730. /** @hidden */
  21731. private _intersectLines;
  21732. /** @hidden */
  21733. private _intersectUnIndexedLines;
  21734. /** @hidden */
  21735. private _intersectTriangles;
  21736. /** @hidden */
  21737. private _intersectUnIndexedTriangles;
  21738. /** @hidden */
  21739. _rebuild(): void;
  21740. /**
  21741. * Creates a new submesh from the passed mesh
  21742. * @param newMesh defines the new hosting mesh
  21743. * @param newRenderingMesh defines an optional rendering mesh
  21744. * @returns the new submesh
  21745. */
  21746. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21747. /**
  21748. * Release associated resources
  21749. */
  21750. dispose(): void;
  21751. /**
  21752. * Gets the class name
  21753. * @returns the string "SubMesh".
  21754. */
  21755. getClassName(): string;
  21756. /**
  21757. * Creates a new submesh from indices data
  21758. * @param materialIndex the index of the main mesh material
  21759. * @param startIndex the index where to start the copy in the mesh indices array
  21760. * @param indexCount the number of indices to copy then from the startIndex
  21761. * @param mesh the main mesh to create the submesh from
  21762. * @param renderingMesh the optional rendering mesh
  21763. * @returns a new submesh
  21764. */
  21765. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21766. }
  21767. }
  21768. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21769. /**
  21770. * Class used to represent data loading progression
  21771. */
  21772. export class SceneLoaderFlags {
  21773. private static _ForceFullSceneLoadingForIncremental;
  21774. private static _ShowLoadingScreen;
  21775. private static _CleanBoneMatrixWeights;
  21776. private static _loggingLevel;
  21777. /**
  21778. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21779. */
  21780. static ForceFullSceneLoadingForIncremental: boolean;
  21781. /**
  21782. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21783. */
  21784. static ShowLoadingScreen: boolean;
  21785. /**
  21786. * Defines the current logging level (while loading the scene)
  21787. * @ignorenaming
  21788. */
  21789. static loggingLevel: number;
  21790. /**
  21791. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21792. */
  21793. static CleanBoneMatrixWeights: boolean;
  21794. }
  21795. }
  21796. declare module "babylonjs/Meshes/geometry" {
  21797. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21798. import { Scene } from "babylonjs/scene";
  21799. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21800. import { Engine } from "babylonjs/Engines/engine";
  21801. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21802. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21803. import { Effect } from "babylonjs/Materials/effect";
  21804. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21805. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21806. import { Mesh } from "babylonjs/Meshes/mesh";
  21807. /**
  21808. * Class used to store geometry data (vertex buffers + index buffer)
  21809. */
  21810. export class Geometry implements IGetSetVerticesData {
  21811. /**
  21812. * Gets or sets the ID of the geometry
  21813. */
  21814. id: string;
  21815. /**
  21816. * Gets or sets the unique ID of the geometry
  21817. */
  21818. uniqueId: number;
  21819. /**
  21820. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21821. */
  21822. delayLoadState: number;
  21823. /**
  21824. * Gets the file containing the data to load when running in delay load state
  21825. */
  21826. delayLoadingFile: Nullable<string>;
  21827. /**
  21828. * Callback called when the geometry is updated
  21829. */
  21830. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21831. private _scene;
  21832. private _engine;
  21833. private _meshes;
  21834. private _totalVertices;
  21835. /** @hidden */
  21836. _indices: IndicesArray;
  21837. /** @hidden */
  21838. _vertexBuffers: {
  21839. [key: string]: VertexBuffer;
  21840. };
  21841. private _isDisposed;
  21842. private _extend;
  21843. private _boundingBias;
  21844. /** @hidden */
  21845. _delayInfo: Array<string>;
  21846. private _indexBuffer;
  21847. private _indexBufferIsUpdatable;
  21848. /** @hidden */
  21849. _boundingInfo: Nullable<BoundingInfo>;
  21850. /** @hidden */
  21851. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21852. /** @hidden */
  21853. _softwareSkinningFrameId: number;
  21854. private _vertexArrayObjects;
  21855. private _updatable;
  21856. /** @hidden */
  21857. _positions: Nullable<Vector3[]>;
  21858. /**
  21859. * 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
  21860. */
  21861. /**
  21862. * 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
  21863. */
  21864. boundingBias: Vector2;
  21865. /**
  21866. * Static function used to attach a new empty geometry to a mesh
  21867. * @param mesh defines the mesh to attach the geometry to
  21868. * @returns the new Geometry
  21869. */
  21870. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21871. /**
  21872. * Creates a new geometry
  21873. * @param id defines the unique ID
  21874. * @param scene defines the hosting scene
  21875. * @param vertexData defines the VertexData used to get geometry data
  21876. * @param updatable defines if geometry must be updatable (false by default)
  21877. * @param mesh defines the mesh that will be associated with the geometry
  21878. */
  21879. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21880. /**
  21881. * Gets the current extend of the geometry
  21882. */
  21883. readonly extend: {
  21884. minimum: Vector3;
  21885. maximum: Vector3;
  21886. };
  21887. /**
  21888. * Gets the hosting scene
  21889. * @returns the hosting Scene
  21890. */
  21891. getScene(): Scene;
  21892. /**
  21893. * Gets the hosting engine
  21894. * @returns the hosting Engine
  21895. */
  21896. getEngine(): Engine;
  21897. /**
  21898. * Defines if the geometry is ready to use
  21899. * @returns true if the geometry is ready to be used
  21900. */
  21901. isReady(): boolean;
  21902. /**
  21903. * Gets a value indicating that the geometry should not be serialized
  21904. */
  21905. readonly doNotSerialize: boolean;
  21906. /** @hidden */
  21907. _rebuild(): void;
  21908. /**
  21909. * Affects all geometry data in one call
  21910. * @param vertexData defines the geometry data
  21911. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21912. */
  21913. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21914. /**
  21915. * Set specific vertex data
  21916. * @param kind defines the data kind (Position, normal, etc...)
  21917. * @param data defines the vertex data to use
  21918. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21919. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21920. */
  21921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21922. /**
  21923. * Removes a specific vertex data
  21924. * @param kind defines the data kind (Position, normal, etc...)
  21925. */
  21926. removeVerticesData(kind: string): void;
  21927. /**
  21928. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21929. * @param buffer defines the vertex buffer to use
  21930. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21931. */
  21932. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21933. /**
  21934. * Update a specific vertex buffer
  21935. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21936. * It will do nothing if the buffer is not updatable
  21937. * @param kind defines the data kind (Position, normal, etc...)
  21938. * @param data defines the data to use
  21939. * @param offset defines the offset in the target buffer where to store the data
  21940. * @param useBytes set to true if the offset is in bytes
  21941. */
  21942. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21943. /**
  21944. * Update a specific vertex buffer
  21945. * This function will create a new buffer if the current one is not updatable
  21946. * @param kind defines the data kind (Position, normal, etc...)
  21947. * @param data defines the data to use
  21948. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21949. */
  21950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21951. private _updateBoundingInfo;
  21952. /** @hidden */
  21953. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21954. /**
  21955. * Gets total number of vertices
  21956. * @returns the total number of vertices
  21957. */
  21958. getTotalVertices(): number;
  21959. /**
  21960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21961. * @param kind defines the data kind (Position, normal, etc...)
  21962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21964. * @returns a float array containing vertex data
  21965. */
  21966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21967. /**
  21968. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21969. * @param kind defines the data kind (Position, normal, etc...)
  21970. * @returns true if the vertex buffer with the specified kind is updatable
  21971. */
  21972. isVertexBufferUpdatable(kind: string): boolean;
  21973. /**
  21974. * Gets a specific vertex buffer
  21975. * @param kind defines the data kind (Position, normal, etc...)
  21976. * @returns a VertexBuffer
  21977. */
  21978. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21979. /**
  21980. * Returns all vertex buffers
  21981. * @return an object holding all vertex buffers indexed by kind
  21982. */
  21983. getVertexBuffers(): Nullable<{
  21984. [key: string]: VertexBuffer;
  21985. }>;
  21986. /**
  21987. * Gets a boolean indicating if specific vertex buffer is present
  21988. * @param kind defines the data kind (Position, normal, etc...)
  21989. * @returns true if data is present
  21990. */
  21991. isVerticesDataPresent(kind: string): boolean;
  21992. /**
  21993. * Gets a list of all attached data kinds (Position, normal, etc...)
  21994. * @returns a list of string containing all kinds
  21995. */
  21996. getVerticesDataKinds(): string[];
  21997. /**
  21998. * Update index buffer
  21999. * @param indices defines the indices to store in the index buffer
  22000. * @param offset defines the offset in the target buffer where to store the data
  22001. * @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)
  22002. */
  22003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22004. /**
  22005. * Creates a new index buffer
  22006. * @param indices defines the indices to store in the index buffer
  22007. * @param totalVertices defines the total number of vertices (could be null)
  22008. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22009. */
  22010. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22011. /**
  22012. * Return the total number of indices
  22013. * @returns the total number of indices
  22014. */
  22015. getTotalIndices(): number;
  22016. /**
  22017. * Gets the index buffer array
  22018. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22020. * @returns the index buffer array
  22021. */
  22022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22023. /**
  22024. * Gets the index buffer
  22025. * @return the index buffer
  22026. */
  22027. getIndexBuffer(): Nullable<DataBuffer>;
  22028. /** @hidden */
  22029. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22030. /**
  22031. * Release the associated resources for a specific mesh
  22032. * @param mesh defines the source mesh
  22033. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22034. */
  22035. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22036. /**
  22037. * Apply current geometry to a given mesh
  22038. * @param mesh defines the mesh to apply geometry to
  22039. */
  22040. applyToMesh(mesh: Mesh): void;
  22041. private _updateExtend;
  22042. private _applyToMesh;
  22043. private notifyUpdate;
  22044. /**
  22045. * Load the geometry if it was flagged as delay loaded
  22046. * @param scene defines the hosting scene
  22047. * @param onLoaded defines a callback called when the geometry is loaded
  22048. */
  22049. load(scene: Scene, onLoaded?: () => void): void;
  22050. private _queueLoad;
  22051. /**
  22052. * Invert the geometry to move from a right handed system to a left handed one.
  22053. */
  22054. toLeftHanded(): void;
  22055. /** @hidden */
  22056. _resetPointsArrayCache(): void;
  22057. /** @hidden */
  22058. _generatePointsArray(): boolean;
  22059. /**
  22060. * Gets a value indicating if the geometry is disposed
  22061. * @returns true if the geometry was disposed
  22062. */
  22063. isDisposed(): boolean;
  22064. private _disposeVertexArrayObjects;
  22065. /**
  22066. * Free all associated resources
  22067. */
  22068. dispose(): void;
  22069. /**
  22070. * Clone the current geometry into a new geometry
  22071. * @param id defines the unique ID of the new geometry
  22072. * @returns a new geometry object
  22073. */
  22074. copy(id: string): Geometry;
  22075. /**
  22076. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22077. * @return a JSON representation of the current geometry data (without the vertices data)
  22078. */
  22079. serialize(): any;
  22080. private toNumberArray;
  22081. /**
  22082. * Serialize all vertices data into a JSON oject
  22083. * @returns a JSON representation of the current geometry data
  22084. */
  22085. serializeVerticeData(): any;
  22086. /**
  22087. * Extracts a clone of a mesh geometry
  22088. * @param mesh defines the source mesh
  22089. * @param id defines the unique ID of the new geometry object
  22090. * @returns the new geometry object
  22091. */
  22092. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22093. /**
  22094. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22096. * Be aware Math.random() could cause collisions, but:
  22097. * "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"
  22098. * @returns a string containing a new GUID
  22099. */
  22100. static RandomId(): string;
  22101. /** @hidden */
  22102. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22103. private static _CleanMatricesWeights;
  22104. /**
  22105. * Create a new geometry from persisted data (Using .babylon file format)
  22106. * @param parsedVertexData defines the persisted data
  22107. * @param scene defines the hosting scene
  22108. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22109. * @returns the new geometry object
  22110. */
  22111. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22112. }
  22113. }
  22114. declare module "babylonjs/Meshes/mesh.vertexData" {
  22115. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22116. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22117. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22118. import { Geometry } from "babylonjs/Meshes/geometry";
  22119. import { Mesh } from "babylonjs/Meshes/mesh";
  22120. /**
  22121. * Define an interface for all classes that will get and set the data on vertices
  22122. */
  22123. export interface IGetSetVerticesData {
  22124. /**
  22125. * Gets a boolean indicating if specific vertex data is present
  22126. * @param kind defines the vertex data kind to use
  22127. * @returns true is data kind is present
  22128. */
  22129. isVerticesDataPresent(kind: string): boolean;
  22130. /**
  22131. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22132. * @param kind defines the data kind (Position, normal, etc...)
  22133. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22135. * @returns a float array containing vertex data
  22136. */
  22137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22138. /**
  22139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22140. * @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.
  22141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22142. * @returns the indices array or an empty array if the mesh has no geometry
  22143. */
  22144. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22145. /**
  22146. * Set specific vertex data
  22147. * @param kind defines the data kind (Position, normal, etc...)
  22148. * @param data defines the vertex data to use
  22149. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22150. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22151. */
  22152. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22153. /**
  22154. * Update a specific associated vertex buffer
  22155. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22156. * - VertexBuffer.PositionKind
  22157. * - VertexBuffer.UVKind
  22158. * - VertexBuffer.UV2Kind
  22159. * - VertexBuffer.UV3Kind
  22160. * - VertexBuffer.UV4Kind
  22161. * - VertexBuffer.UV5Kind
  22162. * - VertexBuffer.UV6Kind
  22163. * - VertexBuffer.ColorKind
  22164. * - VertexBuffer.MatricesIndicesKind
  22165. * - VertexBuffer.MatricesIndicesExtraKind
  22166. * - VertexBuffer.MatricesWeightsKind
  22167. * - VertexBuffer.MatricesWeightsExtraKind
  22168. * @param data defines the data source
  22169. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22170. * @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)
  22171. */
  22172. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22173. /**
  22174. * Creates a new index buffer
  22175. * @param indices defines the indices to store in the index buffer
  22176. * @param totalVertices defines the total number of vertices (could be null)
  22177. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22178. */
  22179. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22180. }
  22181. /**
  22182. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22183. */
  22184. export class VertexData {
  22185. /**
  22186. * Mesh side orientation : usually the external or front surface
  22187. */
  22188. static readonly FRONTSIDE: number;
  22189. /**
  22190. * Mesh side orientation : usually the internal or back surface
  22191. */
  22192. static readonly BACKSIDE: number;
  22193. /**
  22194. * Mesh side orientation : both internal and external or front and back surfaces
  22195. */
  22196. static readonly DOUBLESIDE: number;
  22197. /**
  22198. * Mesh side orientation : by default, `FRONTSIDE`
  22199. */
  22200. static readonly DEFAULTSIDE: number;
  22201. /**
  22202. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22203. */
  22204. positions: Nullable<FloatArray>;
  22205. /**
  22206. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22207. */
  22208. normals: Nullable<FloatArray>;
  22209. /**
  22210. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22211. */
  22212. tangents: Nullable<FloatArray>;
  22213. /**
  22214. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22215. */
  22216. uvs: Nullable<FloatArray>;
  22217. /**
  22218. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22219. */
  22220. uvs2: Nullable<FloatArray>;
  22221. /**
  22222. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22223. */
  22224. uvs3: Nullable<FloatArray>;
  22225. /**
  22226. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22227. */
  22228. uvs4: Nullable<FloatArray>;
  22229. /**
  22230. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22231. */
  22232. uvs5: Nullable<FloatArray>;
  22233. /**
  22234. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22235. */
  22236. uvs6: Nullable<FloatArray>;
  22237. /**
  22238. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22239. */
  22240. colors: Nullable<FloatArray>;
  22241. /**
  22242. * 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).
  22243. */
  22244. matricesIndices: Nullable<FloatArray>;
  22245. /**
  22246. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22247. */
  22248. matricesWeights: Nullable<FloatArray>;
  22249. /**
  22250. * An array extending the number of possible indices
  22251. */
  22252. matricesIndicesExtra: Nullable<FloatArray>;
  22253. /**
  22254. * An array extending the number of possible weights when the number of indices is extended
  22255. */
  22256. matricesWeightsExtra: Nullable<FloatArray>;
  22257. /**
  22258. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22259. */
  22260. indices: Nullable<IndicesArray>;
  22261. /**
  22262. * Uses the passed data array to set the set the values for the specified kind of data
  22263. * @param data a linear array of floating numbers
  22264. * @param kind the type of data that is being set, eg positions, colors etc
  22265. */
  22266. set(data: FloatArray, kind: string): void;
  22267. /**
  22268. * Associates the vertexData to the passed Mesh.
  22269. * Sets it as updatable or not (default `false`)
  22270. * @param mesh the mesh the vertexData is applied to
  22271. * @param updatable when used and having the value true allows new data to update the vertexData
  22272. * @returns the VertexData
  22273. */
  22274. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22275. /**
  22276. * Associates the vertexData to the passed Geometry.
  22277. * Sets it as updatable or not (default `false`)
  22278. * @param geometry the geometry the vertexData is applied to
  22279. * @param updatable when used and having the value true allows new data to update the vertexData
  22280. * @returns VertexData
  22281. */
  22282. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22283. /**
  22284. * Updates the associated mesh
  22285. * @param mesh the mesh to be updated
  22286. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22287. * @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
  22288. * @returns VertexData
  22289. */
  22290. updateMesh(mesh: Mesh): VertexData;
  22291. /**
  22292. * Updates the associated geometry
  22293. * @param geometry the geometry to be updated
  22294. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22295. * @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
  22296. * @returns VertexData.
  22297. */
  22298. updateGeometry(geometry: Geometry): VertexData;
  22299. private _applyTo;
  22300. private _update;
  22301. /**
  22302. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22303. * @param matrix the transforming matrix
  22304. * @returns the VertexData
  22305. */
  22306. transform(matrix: Matrix): VertexData;
  22307. /**
  22308. * Merges the passed VertexData into the current one
  22309. * @param other the VertexData to be merged into the current one
  22310. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22311. * @returns the modified VertexData
  22312. */
  22313. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22314. private _mergeElement;
  22315. private _validate;
  22316. /**
  22317. * Serializes the VertexData
  22318. * @returns a serialized object
  22319. */
  22320. serialize(): any;
  22321. /**
  22322. * Extracts the vertexData from a mesh
  22323. * @param mesh the mesh from which to extract the VertexData
  22324. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22325. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22326. * @returns the object VertexData associated to the passed mesh
  22327. */
  22328. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22329. /**
  22330. * Extracts the vertexData from the geometry
  22331. * @param geometry the geometry from which to extract the VertexData
  22332. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22333. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22334. * @returns the object VertexData associated to the passed mesh
  22335. */
  22336. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22337. private static _ExtractFrom;
  22338. /**
  22339. * Creates the VertexData for a Ribbon
  22340. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22341. * * pathArray array of paths, each of which an array of successive Vector3
  22342. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22343. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22344. * * 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
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22349. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22350. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22351. * @returns the VertexData of the ribbon
  22352. */
  22353. static CreateRibbon(options: {
  22354. pathArray: Vector3[][];
  22355. closeArray?: boolean;
  22356. closePath?: boolean;
  22357. offset?: number;
  22358. sideOrientation?: number;
  22359. frontUVs?: Vector4;
  22360. backUVs?: Vector4;
  22361. invertUV?: boolean;
  22362. uvs?: Vector2[];
  22363. colors?: Color4[];
  22364. }): VertexData;
  22365. /**
  22366. * Creates the VertexData for a box
  22367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22368. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22369. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22370. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22371. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22372. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22373. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22375. * * 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)
  22376. * * 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)
  22377. * @returns the VertexData of the box
  22378. */
  22379. static CreateBox(options: {
  22380. size?: number;
  22381. width?: number;
  22382. height?: number;
  22383. depth?: number;
  22384. faceUV?: Vector4[];
  22385. faceColors?: Color4[];
  22386. sideOrientation?: number;
  22387. frontUVs?: Vector4;
  22388. backUVs?: Vector4;
  22389. }): VertexData;
  22390. /**
  22391. * Creates the VertexData for a tiled box
  22392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22393. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22394. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22395. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22397. * @returns the VertexData of the box
  22398. */
  22399. static CreateTiledBox(options: {
  22400. pattern?: number;
  22401. width?: number;
  22402. height?: number;
  22403. depth?: number;
  22404. tileSize?: number;
  22405. tileWidth?: number;
  22406. tileHeight?: number;
  22407. alignHorizontal?: number;
  22408. alignVertical?: number;
  22409. faceUV?: Vector4[];
  22410. faceColors?: Color4[];
  22411. sideOrientation?: number;
  22412. }): VertexData;
  22413. /**
  22414. * Creates the VertexData for a tiled plane
  22415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22416. * * pattern a limited pattern arrangement depending on the number
  22417. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22418. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22419. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * * 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)
  22422. * * 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)
  22423. * @returns the VertexData of the tiled plane
  22424. */
  22425. static CreateTiledPlane(options: {
  22426. pattern?: number;
  22427. tileSize?: number;
  22428. tileWidth?: number;
  22429. tileHeight?: number;
  22430. size?: number;
  22431. width?: number;
  22432. height?: number;
  22433. alignHorizontal?: number;
  22434. alignVertical?: number;
  22435. sideOrientation?: number;
  22436. frontUVs?: Vector4;
  22437. backUVs?: Vector4;
  22438. }): VertexData;
  22439. /**
  22440. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22441. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22442. * * segments sets the number of horizontal strips optional, default 32
  22443. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22444. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22445. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22446. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22447. * * 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
  22448. * * 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
  22449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * * 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)
  22451. * * 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)
  22452. * @returns the VertexData of the ellipsoid
  22453. */
  22454. static CreateSphere(options: {
  22455. segments?: number;
  22456. diameter?: number;
  22457. diameterX?: number;
  22458. diameterY?: number;
  22459. diameterZ?: number;
  22460. arc?: number;
  22461. slice?: number;
  22462. sideOrientation?: number;
  22463. frontUVs?: Vector4;
  22464. backUVs?: Vector4;
  22465. }): VertexData;
  22466. /**
  22467. * Creates the VertexData for a cylinder, cone or prism
  22468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22469. * * height sets the height (y direction) of the cylinder, optional, default 2
  22470. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22471. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22472. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22473. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22474. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22475. * * 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
  22476. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22477. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22478. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22479. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22481. * * 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)
  22482. * * 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)
  22483. * @returns the VertexData of the cylinder, cone or prism
  22484. */
  22485. static CreateCylinder(options: {
  22486. height?: number;
  22487. diameterTop?: number;
  22488. diameterBottom?: number;
  22489. diameter?: number;
  22490. tessellation?: number;
  22491. subdivisions?: number;
  22492. arc?: number;
  22493. faceColors?: Color4[];
  22494. faceUV?: Vector4[];
  22495. hasRings?: boolean;
  22496. enclose?: boolean;
  22497. sideOrientation?: number;
  22498. frontUVs?: Vector4;
  22499. backUVs?: Vector4;
  22500. }): VertexData;
  22501. /**
  22502. * Creates the VertexData for a torus
  22503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22504. * * diameter the diameter of the torus, optional default 1
  22505. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22506. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22508. * * 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)
  22509. * * 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)
  22510. * @returns the VertexData of the torus
  22511. */
  22512. static CreateTorus(options: {
  22513. diameter?: number;
  22514. thickness?: number;
  22515. tessellation?: number;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData of the LineSystem
  22522. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22523. * - lines an array of lines, each line being an array of successive Vector3
  22524. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22525. * @returns the VertexData of the LineSystem
  22526. */
  22527. static CreateLineSystem(options: {
  22528. lines: Vector3[][];
  22529. colors?: Nullable<Color4[][]>;
  22530. }): VertexData;
  22531. /**
  22532. * Create the VertexData for a DashedLines
  22533. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22534. * - points an array successive Vector3
  22535. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22536. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22537. * - dashNb the intended total number of dashes, optional, default 200
  22538. * @returns the VertexData for the DashedLines
  22539. */
  22540. static CreateDashedLines(options: {
  22541. points: Vector3[];
  22542. dashSize?: number;
  22543. gapSize?: number;
  22544. dashNb?: number;
  22545. }): VertexData;
  22546. /**
  22547. * Creates the VertexData for a Ground
  22548. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22549. * - width the width (x direction) of the ground, optional, default 1
  22550. * - height the height (z direction) of the ground, optional, default 1
  22551. * - subdivisions the number of subdivisions per side, optional, default 1
  22552. * @returns the VertexData of the Ground
  22553. */
  22554. static CreateGround(options: {
  22555. width?: number;
  22556. height?: number;
  22557. subdivisions?: number;
  22558. subdivisionsX?: number;
  22559. subdivisionsY?: number;
  22560. }): VertexData;
  22561. /**
  22562. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22563. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22564. * * xmin the ground minimum X coordinate, optional, default -1
  22565. * * zmin the ground minimum Z coordinate, optional, default -1
  22566. * * xmax the ground maximum X coordinate, optional, default 1
  22567. * * zmax the ground maximum Z coordinate, optional, default 1
  22568. * * 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}
  22569. * * 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}
  22570. * @returns the VertexData of the TiledGround
  22571. */
  22572. static CreateTiledGround(options: {
  22573. xmin: number;
  22574. zmin: number;
  22575. xmax: number;
  22576. zmax: number;
  22577. subdivisions?: {
  22578. w: number;
  22579. h: number;
  22580. };
  22581. precision?: {
  22582. w: number;
  22583. h: number;
  22584. };
  22585. }): VertexData;
  22586. /**
  22587. * Creates the VertexData of the Ground designed from a heightmap
  22588. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22589. * * width the width (x direction) of the ground
  22590. * * height the height (z direction) of the ground
  22591. * * subdivisions the number of subdivisions per side
  22592. * * minHeight the minimum altitude on the ground, optional, default 0
  22593. * * maxHeight the maximum altitude on the ground, optional default 1
  22594. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22595. * * buffer the array holding the image color data
  22596. * * bufferWidth the width of image
  22597. * * bufferHeight the height of image
  22598. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22599. * @returns the VertexData of the Ground designed from a heightmap
  22600. */
  22601. static CreateGroundFromHeightMap(options: {
  22602. width: number;
  22603. height: number;
  22604. subdivisions: number;
  22605. minHeight: number;
  22606. maxHeight: number;
  22607. colorFilter: Color3;
  22608. buffer: Uint8Array;
  22609. bufferWidth: number;
  22610. bufferHeight: number;
  22611. alphaFilter: number;
  22612. }): VertexData;
  22613. /**
  22614. * Creates the VertexData for a Plane
  22615. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22616. * * size sets the width and height of the plane to the value of size, optional default 1
  22617. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22618. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22620. * * 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)
  22621. * * 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)
  22622. * @returns the VertexData of the box
  22623. */
  22624. static CreatePlane(options: {
  22625. size?: number;
  22626. width?: number;
  22627. height?: number;
  22628. sideOrientation?: number;
  22629. frontUVs?: Vector4;
  22630. backUVs?: Vector4;
  22631. }): VertexData;
  22632. /**
  22633. * Creates the VertexData of the Disc or regular Polygon
  22634. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22635. * * radius the radius of the disc, optional default 0.5
  22636. * * tessellation the number of polygon sides, optional, default 64
  22637. * * 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
  22638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22639. * * 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)
  22640. * * 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)
  22641. * @returns the VertexData of the box
  22642. */
  22643. static CreateDisc(options: {
  22644. radius?: number;
  22645. tessellation?: number;
  22646. arc?: number;
  22647. sideOrientation?: number;
  22648. frontUVs?: Vector4;
  22649. backUVs?: Vector4;
  22650. }): VertexData;
  22651. /**
  22652. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22653. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22654. * @param polygon a mesh built from polygonTriangulation.build()
  22655. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22656. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22657. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22658. * @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)
  22659. * @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)
  22660. * @returns the VertexData of the Polygon
  22661. */
  22662. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22663. /**
  22664. * Creates the VertexData of the IcoSphere
  22665. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22666. * * radius the radius of the IcoSphere, optional default 1
  22667. * * radiusX allows stretching in the x direction, optional, default radius
  22668. * * radiusY allows stretching in the y direction, optional, default radius
  22669. * * radiusZ allows stretching in the z direction, optional, default radius
  22670. * * flat when true creates a flat shaded mesh, optional, default true
  22671. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22673. * * 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)
  22674. * * 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)
  22675. * @returns the VertexData of the IcoSphere
  22676. */
  22677. static CreateIcoSphere(options: {
  22678. radius?: number;
  22679. radiusX?: number;
  22680. radiusY?: number;
  22681. radiusZ?: number;
  22682. flat?: boolean;
  22683. subdivisions?: number;
  22684. sideOrientation?: number;
  22685. frontUVs?: Vector4;
  22686. backUVs?: Vector4;
  22687. }): VertexData;
  22688. /**
  22689. * Creates the VertexData for a Polyhedron
  22690. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22691. * * type provided types are:
  22692. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22693. * * 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)
  22694. * * size the size of the IcoSphere, optional default 1
  22695. * * sizeX allows stretching in the x direction, optional, default size
  22696. * * sizeY allows stretching in the y direction, optional, default size
  22697. * * sizeZ allows stretching in the z direction, optional, default size
  22698. * * 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
  22699. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22700. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22701. * * flat when true creates a flat shaded mesh, optional, default true
  22702. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22704. * * 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)
  22705. * * 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)
  22706. * @returns the VertexData of the Polyhedron
  22707. */
  22708. static CreatePolyhedron(options: {
  22709. type?: number;
  22710. size?: number;
  22711. sizeX?: number;
  22712. sizeY?: number;
  22713. sizeZ?: number;
  22714. custom?: any;
  22715. faceUV?: Vector4[];
  22716. faceColors?: Color4[];
  22717. flat?: boolean;
  22718. sideOrientation?: number;
  22719. frontUVs?: Vector4;
  22720. backUVs?: Vector4;
  22721. }): VertexData;
  22722. /**
  22723. * Creates the VertexData for a TorusKnot
  22724. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22725. * * radius the radius of the torus knot, optional, default 2
  22726. * * tube the thickness of the tube, optional, default 0.5
  22727. * * radialSegments the number of sides on each tube segments, optional, default 32
  22728. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22729. * * p the number of windings around the z axis, optional, default 2
  22730. * * q the number of windings around the x axis, optional, default 3
  22731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22732. * * 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)
  22733. * * 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)
  22734. * @returns the VertexData of the Torus Knot
  22735. */
  22736. static CreateTorusKnot(options: {
  22737. radius?: number;
  22738. tube?: number;
  22739. radialSegments?: number;
  22740. tubularSegments?: number;
  22741. p?: number;
  22742. q?: number;
  22743. sideOrientation?: number;
  22744. frontUVs?: Vector4;
  22745. backUVs?: Vector4;
  22746. }): VertexData;
  22747. /**
  22748. * Compute normals for given positions and indices
  22749. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22750. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22751. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22752. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22753. * * facetNormals : optional array of facet normals (vector3)
  22754. * * facetPositions : optional array of facet positions (vector3)
  22755. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22756. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22757. * * bInfo : optional bounding info, required for facetPartitioning computation
  22758. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22759. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22760. * * useRightHandedSystem: optional boolean to for right handed system computation
  22761. * * depthSort : optional boolean to enable the facet depth sort computation
  22762. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22763. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22764. */
  22765. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22766. facetNormals?: any;
  22767. facetPositions?: any;
  22768. facetPartitioning?: any;
  22769. ratio?: number;
  22770. bInfo?: any;
  22771. bbSize?: Vector3;
  22772. subDiv?: any;
  22773. useRightHandedSystem?: boolean;
  22774. depthSort?: boolean;
  22775. distanceTo?: Vector3;
  22776. depthSortedFacets?: any;
  22777. }): void;
  22778. /** @hidden */
  22779. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22780. /**
  22781. * Applies VertexData created from the imported parameters to the geometry
  22782. * @param parsedVertexData the parsed data from an imported file
  22783. * @param geometry the geometry to apply the VertexData to
  22784. */
  22785. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22786. }
  22787. }
  22788. declare module "babylonjs/Morph/morphTarget" {
  22789. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22790. import { Observable } from "babylonjs/Misc/observable";
  22791. import { Nullable, FloatArray } from "babylonjs/types";
  22792. import { Scene } from "babylonjs/scene";
  22793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22794. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22795. /**
  22796. * Defines a target to use with MorphTargetManager
  22797. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22798. */
  22799. export class MorphTarget implements IAnimatable {
  22800. /** defines the name of the target */
  22801. name: string;
  22802. /**
  22803. * Gets or sets the list of animations
  22804. */
  22805. animations: import("babylonjs/Animations/animation").Animation[];
  22806. private _scene;
  22807. private _positions;
  22808. private _normals;
  22809. private _tangents;
  22810. private _uvs;
  22811. private _influence;
  22812. private _uniqueId;
  22813. /**
  22814. * Observable raised when the influence changes
  22815. */
  22816. onInfluenceChanged: Observable<boolean>;
  22817. /** @hidden */
  22818. _onDataLayoutChanged: Observable<void>;
  22819. /**
  22820. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22821. */
  22822. influence: number;
  22823. /**
  22824. * Gets or sets the id of the morph Target
  22825. */
  22826. id: string;
  22827. private _animationPropertiesOverride;
  22828. /**
  22829. * Gets or sets the animation properties override
  22830. */
  22831. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22832. /**
  22833. * Creates a new MorphTarget
  22834. * @param name defines the name of the target
  22835. * @param influence defines the influence to use
  22836. * @param scene defines the scene the morphtarget belongs to
  22837. */
  22838. constructor(
  22839. /** defines the name of the target */
  22840. name: string, influence?: number, scene?: Nullable<Scene>);
  22841. /**
  22842. * Gets the unique ID of this manager
  22843. */
  22844. readonly uniqueId: number;
  22845. /**
  22846. * Gets a boolean defining if the target contains position data
  22847. */
  22848. readonly hasPositions: boolean;
  22849. /**
  22850. * Gets a boolean defining if the target contains normal data
  22851. */
  22852. readonly hasNormals: boolean;
  22853. /**
  22854. * Gets a boolean defining if the target contains tangent data
  22855. */
  22856. readonly hasTangents: boolean;
  22857. /**
  22858. * Gets a boolean defining if the target contains texture coordinates data
  22859. */
  22860. readonly hasUVs: boolean;
  22861. /**
  22862. * Affects position data to this target
  22863. * @param data defines the position data to use
  22864. */
  22865. setPositions(data: Nullable<FloatArray>): void;
  22866. /**
  22867. * Gets the position data stored in this target
  22868. * @returns a FloatArray containing the position data (or null if not present)
  22869. */
  22870. getPositions(): Nullable<FloatArray>;
  22871. /**
  22872. * Affects normal data to this target
  22873. * @param data defines the normal data to use
  22874. */
  22875. setNormals(data: Nullable<FloatArray>): void;
  22876. /**
  22877. * Gets the normal data stored in this target
  22878. * @returns a FloatArray containing the normal data (or null if not present)
  22879. */
  22880. getNormals(): Nullable<FloatArray>;
  22881. /**
  22882. * Affects tangent data to this target
  22883. * @param data defines the tangent data to use
  22884. */
  22885. setTangents(data: Nullable<FloatArray>): void;
  22886. /**
  22887. * Gets the tangent data stored in this target
  22888. * @returns a FloatArray containing the tangent data (or null if not present)
  22889. */
  22890. getTangents(): Nullable<FloatArray>;
  22891. /**
  22892. * Affects texture coordinates data to this target
  22893. * @param data defines the texture coordinates data to use
  22894. */
  22895. setUVs(data: Nullable<FloatArray>): void;
  22896. /**
  22897. * Gets the texture coordinates data stored in this target
  22898. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22899. */
  22900. getUVs(): Nullable<FloatArray>;
  22901. /**
  22902. * Clone the current target
  22903. * @returns a new MorphTarget
  22904. */
  22905. clone(): MorphTarget;
  22906. /**
  22907. * Serializes the current target into a Serialization object
  22908. * @returns the serialized object
  22909. */
  22910. serialize(): any;
  22911. /**
  22912. * Returns the string "MorphTarget"
  22913. * @returns "MorphTarget"
  22914. */
  22915. getClassName(): string;
  22916. /**
  22917. * Creates a new target from serialized data
  22918. * @param serializationObject defines the serialized data to use
  22919. * @returns a new MorphTarget
  22920. */
  22921. static Parse(serializationObject: any): MorphTarget;
  22922. /**
  22923. * Creates a MorphTarget from mesh data
  22924. * @param mesh defines the source mesh
  22925. * @param name defines the name to use for the new target
  22926. * @param influence defines the influence to attach to the target
  22927. * @returns a new MorphTarget
  22928. */
  22929. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22930. }
  22931. }
  22932. declare module "babylonjs/Morph/morphTargetManager" {
  22933. import { Nullable } from "babylonjs/types";
  22934. import { Scene } from "babylonjs/scene";
  22935. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22936. /**
  22937. * This class is used to deform meshes using morphing between different targets
  22938. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22939. */
  22940. export class MorphTargetManager {
  22941. private _targets;
  22942. private _targetInfluenceChangedObservers;
  22943. private _targetDataLayoutChangedObservers;
  22944. private _activeTargets;
  22945. private _scene;
  22946. private _influences;
  22947. private _supportsNormals;
  22948. private _supportsTangents;
  22949. private _supportsUVs;
  22950. private _vertexCount;
  22951. private _uniqueId;
  22952. private _tempInfluences;
  22953. /**
  22954. * Gets or sets a boolean indicating if normals must be morphed
  22955. */
  22956. enableNormalMorphing: boolean;
  22957. /**
  22958. * Gets or sets a boolean indicating if tangents must be morphed
  22959. */
  22960. enableTangentMorphing: boolean;
  22961. /**
  22962. * Gets or sets a boolean indicating if UV must be morphed
  22963. */
  22964. enableUVMorphing: boolean;
  22965. /**
  22966. * Creates a new MorphTargetManager
  22967. * @param scene defines the current scene
  22968. */
  22969. constructor(scene?: Nullable<Scene>);
  22970. /**
  22971. * Gets the unique ID of this manager
  22972. */
  22973. readonly uniqueId: number;
  22974. /**
  22975. * Gets the number of vertices handled by this manager
  22976. */
  22977. readonly vertexCount: number;
  22978. /**
  22979. * Gets a boolean indicating if this manager supports morphing of normals
  22980. */
  22981. readonly supportsNormals: boolean;
  22982. /**
  22983. * Gets a boolean indicating if this manager supports morphing of tangents
  22984. */
  22985. readonly supportsTangents: boolean;
  22986. /**
  22987. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22988. */
  22989. readonly supportsUVs: boolean;
  22990. /**
  22991. * Gets the number of targets stored in this manager
  22992. */
  22993. readonly numTargets: number;
  22994. /**
  22995. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22996. */
  22997. readonly numInfluencers: number;
  22998. /**
  22999. * Gets the list of influences (one per target)
  23000. */
  23001. readonly influences: Float32Array;
  23002. /**
  23003. * Gets the active target at specified index. An active target is a target with an influence > 0
  23004. * @param index defines the index to check
  23005. * @returns the requested target
  23006. */
  23007. getActiveTarget(index: number): MorphTarget;
  23008. /**
  23009. * Gets the target at specified index
  23010. * @param index defines the index to check
  23011. * @returns the requested target
  23012. */
  23013. getTarget(index: number): MorphTarget;
  23014. /**
  23015. * Add a new target to this manager
  23016. * @param target defines the target to add
  23017. */
  23018. addTarget(target: MorphTarget): void;
  23019. /**
  23020. * Removes a target from the manager
  23021. * @param target defines the target to remove
  23022. */
  23023. removeTarget(target: MorphTarget): void;
  23024. /**
  23025. * Clone the current manager
  23026. * @returns a new MorphTargetManager
  23027. */
  23028. clone(): MorphTargetManager;
  23029. /**
  23030. * Serializes the current manager into a Serialization object
  23031. * @returns the serialized object
  23032. */
  23033. serialize(): any;
  23034. private _syncActiveTargets;
  23035. /**
  23036. * Syncrhonize the targets with all the meshes using this morph target manager
  23037. */
  23038. synchronize(): void;
  23039. /**
  23040. * Creates a new MorphTargetManager from serialized data
  23041. * @param serializationObject defines the serialized data
  23042. * @param scene defines the hosting scene
  23043. * @returns the new MorphTargetManager
  23044. */
  23045. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23046. }
  23047. }
  23048. declare module "babylonjs/Meshes/meshLODLevel" {
  23049. import { Mesh } from "babylonjs/Meshes/mesh";
  23050. import { Nullable } from "babylonjs/types";
  23051. /**
  23052. * Class used to represent a specific level of detail of a mesh
  23053. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23054. */
  23055. export class MeshLODLevel {
  23056. /** Defines the distance where this level should start being displayed */
  23057. distance: number;
  23058. /** Defines the mesh to use to render this level */
  23059. mesh: Nullable<Mesh>;
  23060. /**
  23061. * Creates a new LOD level
  23062. * @param distance defines the distance where this level should star being displayed
  23063. * @param mesh defines the mesh to use to render this level
  23064. */
  23065. constructor(
  23066. /** Defines the distance where this level should start being displayed */
  23067. distance: number,
  23068. /** Defines the mesh to use to render this level */
  23069. mesh: Nullable<Mesh>);
  23070. }
  23071. }
  23072. declare module "babylonjs/Meshes/groundMesh" {
  23073. import { Scene } from "babylonjs/scene";
  23074. import { Vector3 } from "babylonjs/Maths/math.vector";
  23075. import { Mesh } from "babylonjs/Meshes/mesh";
  23076. /**
  23077. * Mesh representing the gorund
  23078. */
  23079. export class GroundMesh extends Mesh {
  23080. /** If octree should be generated */
  23081. generateOctree: boolean;
  23082. private _heightQuads;
  23083. /** @hidden */
  23084. _subdivisionsX: number;
  23085. /** @hidden */
  23086. _subdivisionsY: number;
  23087. /** @hidden */
  23088. _width: number;
  23089. /** @hidden */
  23090. _height: number;
  23091. /** @hidden */
  23092. _minX: number;
  23093. /** @hidden */
  23094. _maxX: number;
  23095. /** @hidden */
  23096. _minZ: number;
  23097. /** @hidden */
  23098. _maxZ: number;
  23099. constructor(name: string, scene: Scene);
  23100. /**
  23101. * "GroundMesh"
  23102. * @returns "GroundMesh"
  23103. */
  23104. getClassName(): string;
  23105. /**
  23106. * The minimum of x and y subdivisions
  23107. */
  23108. readonly subdivisions: number;
  23109. /**
  23110. * X subdivisions
  23111. */
  23112. readonly subdivisionsX: number;
  23113. /**
  23114. * Y subdivisions
  23115. */
  23116. readonly subdivisionsY: number;
  23117. /**
  23118. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23119. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23120. * @param chunksCount the number of subdivisions for x and y
  23121. * @param octreeBlocksSize (Default: 32)
  23122. */
  23123. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23124. /**
  23125. * Returns a height (y) value in the Worl system :
  23126. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23127. * @param x x coordinate
  23128. * @param z z coordinate
  23129. * @returns the ground y position if (x, z) are outside the ground surface.
  23130. */
  23131. getHeightAtCoordinates(x: number, z: number): number;
  23132. /**
  23133. * Returns a normalized vector (Vector3) orthogonal to the ground
  23134. * at the ground coordinates (x, z) expressed in the World system.
  23135. * @param x x coordinate
  23136. * @param z z coordinate
  23137. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23138. */
  23139. getNormalAtCoordinates(x: number, z: number): Vector3;
  23140. /**
  23141. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23142. * at the ground coordinates (x, z) expressed in the World system.
  23143. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23144. * @param x x coordinate
  23145. * @param z z coordinate
  23146. * @param ref vector to store the result
  23147. * @returns the GroundMesh.
  23148. */
  23149. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23150. /**
  23151. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23152. * if the ground has been updated.
  23153. * This can be used in the render loop.
  23154. * @returns the GroundMesh.
  23155. */
  23156. updateCoordinateHeights(): GroundMesh;
  23157. private _getFacetAt;
  23158. private _initHeightQuads;
  23159. private _computeHeightQuads;
  23160. /**
  23161. * Serializes this ground mesh
  23162. * @param serializationObject object to write serialization to
  23163. */
  23164. serialize(serializationObject: any): void;
  23165. /**
  23166. * Parses a serialized ground mesh
  23167. * @param parsedMesh the serialized mesh
  23168. * @param scene the scene to create the ground mesh in
  23169. * @returns the created ground mesh
  23170. */
  23171. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23172. }
  23173. }
  23174. declare module "babylonjs/Physics/physicsJoint" {
  23175. import { Vector3 } from "babylonjs/Maths/math.vector";
  23176. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23177. /**
  23178. * Interface for Physics-Joint data
  23179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23180. */
  23181. export interface PhysicsJointData {
  23182. /**
  23183. * The main pivot of the joint
  23184. */
  23185. mainPivot?: Vector3;
  23186. /**
  23187. * The connected pivot of the joint
  23188. */
  23189. connectedPivot?: Vector3;
  23190. /**
  23191. * The main axis of the joint
  23192. */
  23193. mainAxis?: Vector3;
  23194. /**
  23195. * The connected axis of the joint
  23196. */
  23197. connectedAxis?: Vector3;
  23198. /**
  23199. * The collision of the joint
  23200. */
  23201. collision?: boolean;
  23202. /**
  23203. * Native Oimo/Cannon/Energy data
  23204. */
  23205. nativeParams?: any;
  23206. }
  23207. /**
  23208. * This is a holder class for the physics joint created by the physics plugin
  23209. * It holds a set of functions to control the underlying joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export class PhysicsJoint {
  23213. /**
  23214. * The type of the physics joint
  23215. */
  23216. type: number;
  23217. /**
  23218. * The data for the physics joint
  23219. */
  23220. jointData: PhysicsJointData;
  23221. private _physicsJoint;
  23222. protected _physicsPlugin: IPhysicsEnginePlugin;
  23223. /**
  23224. * Initializes the physics joint
  23225. * @param type The type of the physics joint
  23226. * @param jointData The data for the physics joint
  23227. */
  23228. constructor(
  23229. /**
  23230. * The type of the physics joint
  23231. */
  23232. type: number,
  23233. /**
  23234. * The data for the physics joint
  23235. */
  23236. jointData: PhysicsJointData);
  23237. /**
  23238. * Gets the physics joint
  23239. */
  23240. /**
  23241. * Sets the physics joint
  23242. */
  23243. physicsJoint: any;
  23244. /**
  23245. * Sets the physics plugin
  23246. */
  23247. physicsPlugin: IPhysicsEnginePlugin;
  23248. /**
  23249. * Execute a function that is physics-plugin specific.
  23250. * @param {Function} func the function that will be executed.
  23251. * It accepts two parameters: the physics world and the physics joint
  23252. */
  23253. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23254. /**
  23255. * Distance-Joint type
  23256. */
  23257. static DistanceJoint: number;
  23258. /**
  23259. * Hinge-Joint type
  23260. */
  23261. static HingeJoint: number;
  23262. /**
  23263. * Ball-and-Socket joint type
  23264. */
  23265. static BallAndSocketJoint: number;
  23266. /**
  23267. * Wheel-Joint type
  23268. */
  23269. static WheelJoint: number;
  23270. /**
  23271. * Slider-Joint type
  23272. */
  23273. static SliderJoint: number;
  23274. /**
  23275. * Prismatic-Joint type
  23276. */
  23277. static PrismaticJoint: number;
  23278. /**
  23279. * Universal-Joint type
  23280. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23281. */
  23282. static UniversalJoint: number;
  23283. /**
  23284. * Hinge-Joint 2 type
  23285. */
  23286. static Hinge2Joint: number;
  23287. /**
  23288. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23289. */
  23290. static PointToPointJoint: number;
  23291. /**
  23292. * Spring-Joint type
  23293. */
  23294. static SpringJoint: number;
  23295. /**
  23296. * Lock-Joint type
  23297. */
  23298. static LockJoint: number;
  23299. }
  23300. /**
  23301. * A class representing a physics distance joint
  23302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23303. */
  23304. export class DistanceJoint extends PhysicsJoint {
  23305. /**
  23306. *
  23307. * @param jointData The data for the Distance-Joint
  23308. */
  23309. constructor(jointData: DistanceJointData);
  23310. /**
  23311. * Update the predefined distance.
  23312. * @param maxDistance The maximum preferred distance
  23313. * @param minDistance The minimum preferred distance
  23314. */
  23315. updateDistance(maxDistance: number, minDistance?: number): void;
  23316. }
  23317. /**
  23318. * Represents a Motor-Enabled Joint
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23322. /**
  23323. * Initializes the Motor-Enabled Joint
  23324. * @param type The type of the joint
  23325. * @param jointData The physica joint data for the joint
  23326. */
  23327. constructor(type: number, jointData: PhysicsJointData);
  23328. /**
  23329. * Set the motor values.
  23330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23331. * @param force the force to apply
  23332. * @param maxForce max force for this motor.
  23333. */
  23334. setMotor(force?: number, maxForce?: number): void;
  23335. /**
  23336. * Set the motor's limits.
  23337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23338. * @param upperLimit The upper limit of the motor
  23339. * @param lowerLimit The lower limit of the motor
  23340. */
  23341. setLimit(upperLimit: number, lowerLimit?: number): void;
  23342. }
  23343. /**
  23344. * This class represents a single physics Hinge-Joint
  23345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23346. */
  23347. export class HingeJoint extends MotorEnabledJoint {
  23348. /**
  23349. * Initializes the Hinge-Joint
  23350. * @param jointData The joint data for the Hinge-Joint
  23351. */
  23352. constructor(jointData: PhysicsJointData);
  23353. /**
  23354. * Set the motor values.
  23355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23356. * @param {number} force the force to apply
  23357. * @param {number} maxForce max force for this motor.
  23358. */
  23359. setMotor(force?: number, maxForce?: number): void;
  23360. /**
  23361. * Set the motor's limits.
  23362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23363. * @param upperLimit The upper limit of the motor
  23364. * @param lowerLimit The lower limit of the motor
  23365. */
  23366. setLimit(upperLimit: number, lowerLimit?: number): void;
  23367. }
  23368. /**
  23369. * This class represents a dual hinge physics joint (same as wheel joint)
  23370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23371. */
  23372. export class Hinge2Joint extends MotorEnabledJoint {
  23373. /**
  23374. * Initializes the Hinge2-Joint
  23375. * @param jointData The joint data for the Hinge2-Joint
  23376. */
  23377. constructor(jointData: PhysicsJointData);
  23378. /**
  23379. * Set the motor values.
  23380. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23381. * @param {number} targetSpeed the speed the motor is to reach
  23382. * @param {number} maxForce max force for this motor.
  23383. * @param {motorIndex} the motor's index, 0 or 1.
  23384. */
  23385. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23386. /**
  23387. * Set the motor limits.
  23388. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23389. * @param {number} upperLimit the upper limit
  23390. * @param {number} lowerLimit lower limit
  23391. * @param {motorIndex} the motor's index, 0 or 1.
  23392. */
  23393. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23394. }
  23395. /**
  23396. * Interface for a motor enabled joint
  23397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23398. */
  23399. export interface IMotorEnabledJoint {
  23400. /**
  23401. * Physics joint
  23402. */
  23403. physicsJoint: any;
  23404. /**
  23405. * Sets the motor of the motor-enabled joint
  23406. * @param force The force of the motor
  23407. * @param maxForce The maximum force of the motor
  23408. * @param motorIndex The index of the motor
  23409. */
  23410. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23411. /**
  23412. * Sets the limit of the motor
  23413. * @param upperLimit The upper limit of the motor
  23414. * @param lowerLimit The lower limit of the motor
  23415. * @param motorIndex The index of the motor
  23416. */
  23417. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23418. }
  23419. /**
  23420. * Joint data for a Distance-Joint
  23421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23422. */
  23423. export interface DistanceJointData extends PhysicsJointData {
  23424. /**
  23425. * Max distance the 2 joint objects can be apart
  23426. */
  23427. maxDistance: number;
  23428. }
  23429. /**
  23430. * Joint data from a spring joint
  23431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23432. */
  23433. export interface SpringJointData extends PhysicsJointData {
  23434. /**
  23435. * Length of the spring
  23436. */
  23437. length: number;
  23438. /**
  23439. * Stiffness of the spring
  23440. */
  23441. stiffness: number;
  23442. /**
  23443. * Damping of the spring
  23444. */
  23445. damping: number;
  23446. /** this callback will be called when applying the force to the impostors. */
  23447. forceApplicationCallback: () => void;
  23448. }
  23449. }
  23450. declare module "babylonjs/Physics/physicsRaycastResult" {
  23451. import { Vector3 } from "babylonjs/Maths/math.vector";
  23452. /**
  23453. * Holds the data for the raycast result
  23454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23455. */
  23456. export class PhysicsRaycastResult {
  23457. private _hasHit;
  23458. private _hitDistance;
  23459. private _hitNormalWorld;
  23460. private _hitPointWorld;
  23461. private _rayFromWorld;
  23462. private _rayToWorld;
  23463. /**
  23464. * Gets if there was a hit
  23465. */
  23466. readonly hasHit: boolean;
  23467. /**
  23468. * Gets the distance from the hit
  23469. */
  23470. readonly hitDistance: number;
  23471. /**
  23472. * Gets the hit normal/direction in the world
  23473. */
  23474. readonly hitNormalWorld: Vector3;
  23475. /**
  23476. * Gets the hit point in the world
  23477. */
  23478. readonly hitPointWorld: Vector3;
  23479. /**
  23480. * Gets the ray "start point" of the ray in the world
  23481. */
  23482. readonly rayFromWorld: Vector3;
  23483. /**
  23484. * Gets the ray "end point" of the ray in the world
  23485. */
  23486. readonly rayToWorld: Vector3;
  23487. /**
  23488. * Sets the hit data (normal & point in world space)
  23489. * @param hitNormalWorld defines the normal in world space
  23490. * @param hitPointWorld defines the point in world space
  23491. */
  23492. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23493. /**
  23494. * Sets the distance from the start point to the hit point
  23495. * @param distance
  23496. */
  23497. setHitDistance(distance: number): void;
  23498. /**
  23499. * Calculates the distance manually
  23500. */
  23501. calculateHitDistance(): void;
  23502. /**
  23503. * Resets all the values to default
  23504. * @param from The from point on world space
  23505. * @param to The to point on world space
  23506. */
  23507. reset(from?: Vector3, to?: Vector3): void;
  23508. }
  23509. /**
  23510. * Interface for the size containing width and height
  23511. */
  23512. interface IXYZ {
  23513. /**
  23514. * X
  23515. */
  23516. x: number;
  23517. /**
  23518. * Y
  23519. */
  23520. y: number;
  23521. /**
  23522. * Z
  23523. */
  23524. z: number;
  23525. }
  23526. }
  23527. declare module "babylonjs/Physics/IPhysicsEngine" {
  23528. import { Nullable } from "babylonjs/types";
  23529. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23531. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23532. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23533. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23534. /**
  23535. * Interface used to describe a physics joint
  23536. */
  23537. export interface PhysicsImpostorJoint {
  23538. /** Defines the main impostor to which the joint is linked */
  23539. mainImpostor: PhysicsImpostor;
  23540. /** Defines the impostor that is connected to the main impostor using this joint */
  23541. connectedImpostor: PhysicsImpostor;
  23542. /** Defines the joint itself */
  23543. joint: PhysicsJoint;
  23544. }
  23545. /** @hidden */
  23546. export interface IPhysicsEnginePlugin {
  23547. world: any;
  23548. name: string;
  23549. setGravity(gravity: Vector3): void;
  23550. setTimeStep(timeStep: number): void;
  23551. getTimeStep(): number;
  23552. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23553. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23554. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23555. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23556. removePhysicsBody(impostor: PhysicsImpostor): void;
  23557. generateJoint(joint: PhysicsImpostorJoint): void;
  23558. removeJoint(joint: PhysicsImpostorJoint): void;
  23559. isSupported(): boolean;
  23560. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23561. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23562. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23563. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23564. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23565. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23566. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23567. getBodyMass(impostor: PhysicsImpostor): number;
  23568. getBodyFriction(impostor: PhysicsImpostor): number;
  23569. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23570. getBodyRestitution(impostor: PhysicsImpostor): number;
  23571. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23572. getBodyPressure?(impostor: PhysicsImpostor): number;
  23573. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23574. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23575. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23576. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23577. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23578. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23579. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23580. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23581. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23582. sleepBody(impostor: PhysicsImpostor): void;
  23583. wakeUpBody(impostor: PhysicsImpostor): void;
  23584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23585. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23586. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23587. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23588. getRadius(impostor: PhysicsImpostor): number;
  23589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23590. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23591. dispose(): void;
  23592. }
  23593. /**
  23594. * Interface used to define a physics engine
  23595. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23596. */
  23597. export interface IPhysicsEngine {
  23598. /**
  23599. * Gets the gravity vector used by the simulation
  23600. */
  23601. gravity: Vector3;
  23602. /**
  23603. * Sets the gravity vector used by the simulation
  23604. * @param gravity defines the gravity vector to use
  23605. */
  23606. setGravity(gravity: Vector3): void;
  23607. /**
  23608. * Set the time step of the physics engine.
  23609. * Default is 1/60.
  23610. * To slow it down, enter 1/600 for example.
  23611. * To speed it up, 1/30
  23612. * @param newTimeStep the new timestep to apply to this world.
  23613. */
  23614. setTimeStep(newTimeStep: number): void;
  23615. /**
  23616. * Get the time step of the physics engine.
  23617. * @returns the current time step
  23618. */
  23619. getTimeStep(): number;
  23620. /**
  23621. * Release all resources
  23622. */
  23623. dispose(): void;
  23624. /**
  23625. * Gets the name of the current physics plugin
  23626. * @returns the name of the plugin
  23627. */
  23628. getPhysicsPluginName(): string;
  23629. /**
  23630. * Adding a new impostor for the impostor tracking.
  23631. * This will be done by the impostor itself.
  23632. * @param impostor the impostor to add
  23633. */
  23634. addImpostor(impostor: PhysicsImpostor): void;
  23635. /**
  23636. * Remove an impostor from the engine.
  23637. * This impostor and its mesh will not longer be updated by the physics engine.
  23638. * @param impostor the impostor to remove
  23639. */
  23640. removeImpostor(impostor: PhysicsImpostor): void;
  23641. /**
  23642. * Add a joint to the physics engine
  23643. * @param mainImpostor defines the main impostor to which the joint is added.
  23644. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23645. * @param joint defines the joint that will connect both impostors.
  23646. */
  23647. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23648. /**
  23649. * Removes a joint from the simulation
  23650. * @param mainImpostor defines the impostor used with the joint
  23651. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23652. * @param joint defines the joint to remove
  23653. */
  23654. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23655. /**
  23656. * Gets the current plugin used to run the simulation
  23657. * @returns current plugin
  23658. */
  23659. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23660. /**
  23661. * Gets the list of physic impostors
  23662. * @returns an array of PhysicsImpostor
  23663. */
  23664. getImpostors(): Array<PhysicsImpostor>;
  23665. /**
  23666. * Gets the impostor for a physics enabled object
  23667. * @param object defines the object impersonated by the impostor
  23668. * @returns the PhysicsImpostor or null if not found
  23669. */
  23670. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23671. /**
  23672. * Gets the impostor for a physics body object
  23673. * @param body defines physics body used by the impostor
  23674. * @returns the PhysicsImpostor or null if not found
  23675. */
  23676. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23677. /**
  23678. * Does a raycast in the physics world
  23679. * @param from when should the ray start?
  23680. * @param to when should the ray end?
  23681. * @returns PhysicsRaycastResult
  23682. */
  23683. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23684. /**
  23685. * Called by the scene. No need to call it.
  23686. * @param delta defines the timespam between frames
  23687. */
  23688. _step(delta: number): void;
  23689. }
  23690. }
  23691. declare module "babylonjs/Physics/physicsImpostor" {
  23692. import { Nullable, IndicesArray } from "babylonjs/types";
  23693. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23694. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23696. import { Scene } from "babylonjs/scene";
  23697. import { Bone } from "babylonjs/Bones/bone";
  23698. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23699. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23700. import { Space } from "babylonjs/Maths/math.axis";
  23701. /**
  23702. * The interface for the physics imposter parameters
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export interface PhysicsImpostorParameters {
  23706. /**
  23707. * The mass of the physics imposter
  23708. */
  23709. mass: number;
  23710. /**
  23711. * The friction of the physics imposter
  23712. */
  23713. friction?: number;
  23714. /**
  23715. * The coefficient of restitution of the physics imposter
  23716. */
  23717. restitution?: number;
  23718. /**
  23719. * The native options of the physics imposter
  23720. */
  23721. nativeOptions?: any;
  23722. /**
  23723. * Specifies if the parent should be ignored
  23724. */
  23725. ignoreParent?: boolean;
  23726. /**
  23727. * Specifies if bi-directional transformations should be disabled
  23728. */
  23729. disableBidirectionalTransformation?: boolean;
  23730. /**
  23731. * The pressure inside the physics imposter, soft object only
  23732. */
  23733. pressure?: number;
  23734. /**
  23735. * The stiffness the physics imposter, soft object only
  23736. */
  23737. stiffness?: number;
  23738. /**
  23739. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23740. */
  23741. velocityIterations?: number;
  23742. /**
  23743. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23744. */
  23745. positionIterations?: number;
  23746. /**
  23747. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23748. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23749. * Add to fix multiple points
  23750. */
  23751. fixedPoints?: number;
  23752. /**
  23753. * The collision margin around a soft object
  23754. */
  23755. margin?: number;
  23756. /**
  23757. * The collision margin around a soft object
  23758. */
  23759. damping?: number;
  23760. /**
  23761. * The path for a rope based on an extrusion
  23762. */
  23763. path?: any;
  23764. /**
  23765. * The shape of an extrusion used for a rope based on an extrusion
  23766. */
  23767. shape?: any;
  23768. }
  23769. /**
  23770. * Interface for a physics-enabled object
  23771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23772. */
  23773. export interface IPhysicsEnabledObject {
  23774. /**
  23775. * The position of the physics-enabled object
  23776. */
  23777. position: Vector3;
  23778. /**
  23779. * The rotation of the physics-enabled object
  23780. */
  23781. rotationQuaternion: Nullable<Quaternion>;
  23782. /**
  23783. * The scale of the physics-enabled object
  23784. */
  23785. scaling: Vector3;
  23786. /**
  23787. * The rotation of the physics-enabled object
  23788. */
  23789. rotation?: Vector3;
  23790. /**
  23791. * The parent of the physics-enabled object
  23792. */
  23793. parent?: any;
  23794. /**
  23795. * The bounding info of the physics-enabled object
  23796. * @returns The bounding info of the physics-enabled object
  23797. */
  23798. getBoundingInfo(): BoundingInfo;
  23799. /**
  23800. * Computes the world matrix
  23801. * @param force Specifies if the world matrix should be computed by force
  23802. * @returns A world matrix
  23803. */
  23804. computeWorldMatrix(force: boolean): Matrix;
  23805. /**
  23806. * Gets the world matrix
  23807. * @returns A world matrix
  23808. */
  23809. getWorldMatrix?(): Matrix;
  23810. /**
  23811. * Gets the child meshes
  23812. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23813. * @returns An array of abstract meshes
  23814. */
  23815. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23816. /**
  23817. * Gets the vertex data
  23818. * @param kind The type of vertex data
  23819. * @returns A nullable array of numbers, or a float32 array
  23820. */
  23821. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23822. /**
  23823. * Gets the indices from the mesh
  23824. * @returns A nullable array of index arrays
  23825. */
  23826. getIndices?(): Nullable<IndicesArray>;
  23827. /**
  23828. * Gets the scene from the mesh
  23829. * @returns the indices array or null
  23830. */
  23831. getScene?(): Scene;
  23832. /**
  23833. * Gets the absolute position from the mesh
  23834. * @returns the absolute position
  23835. */
  23836. getAbsolutePosition(): Vector3;
  23837. /**
  23838. * Gets the absolute pivot point from the mesh
  23839. * @returns the absolute pivot point
  23840. */
  23841. getAbsolutePivotPoint(): Vector3;
  23842. /**
  23843. * Rotates the mesh
  23844. * @param axis The axis of rotation
  23845. * @param amount The amount of rotation
  23846. * @param space The space of the rotation
  23847. * @returns The rotation transform node
  23848. */
  23849. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23850. /**
  23851. * Translates the mesh
  23852. * @param axis The axis of translation
  23853. * @param distance The distance of translation
  23854. * @param space The space of the translation
  23855. * @returns The transform node
  23856. */
  23857. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23858. /**
  23859. * Sets the absolute position of the mesh
  23860. * @param absolutePosition The absolute position of the mesh
  23861. * @returns The transform node
  23862. */
  23863. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23864. /**
  23865. * Gets the class name of the mesh
  23866. * @returns The class name
  23867. */
  23868. getClassName(): string;
  23869. }
  23870. /**
  23871. * Represents a physics imposter
  23872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23873. */
  23874. export class PhysicsImpostor {
  23875. /**
  23876. * The physics-enabled object used as the physics imposter
  23877. */
  23878. object: IPhysicsEnabledObject;
  23879. /**
  23880. * The type of the physics imposter
  23881. */
  23882. type: number;
  23883. private _options;
  23884. private _scene?;
  23885. /**
  23886. * The default object size of the imposter
  23887. */
  23888. static DEFAULT_OBJECT_SIZE: Vector3;
  23889. /**
  23890. * The identity quaternion of the imposter
  23891. */
  23892. static IDENTITY_QUATERNION: Quaternion;
  23893. /** @hidden */
  23894. _pluginData: any;
  23895. private _physicsEngine;
  23896. private _physicsBody;
  23897. private _bodyUpdateRequired;
  23898. private _onBeforePhysicsStepCallbacks;
  23899. private _onAfterPhysicsStepCallbacks;
  23900. /** @hidden */
  23901. _onPhysicsCollideCallbacks: Array<{
  23902. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23903. otherImpostors: Array<PhysicsImpostor>;
  23904. }>;
  23905. private _deltaPosition;
  23906. private _deltaRotation;
  23907. private _deltaRotationConjugated;
  23908. /** @hidden */
  23909. _isFromLine: boolean;
  23910. private _parent;
  23911. private _isDisposed;
  23912. private static _tmpVecs;
  23913. private static _tmpQuat;
  23914. /**
  23915. * Specifies if the physics imposter is disposed
  23916. */
  23917. readonly isDisposed: boolean;
  23918. /**
  23919. * Gets the mass of the physics imposter
  23920. */
  23921. mass: number;
  23922. /**
  23923. * Gets the coefficient of friction
  23924. */
  23925. /**
  23926. * Sets the coefficient of friction
  23927. */
  23928. friction: number;
  23929. /**
  23930. * Gets the coefficient of restitution
  23931. */
  23932. /**
  23933. * Sets the coefficient of restitution
  23934. */
  23935. restitution: number;
  23936. /**
  23937. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23938. */
  23939. /**
  23940. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23941. */
  23942. pressure: number;
  23943. /**
  23944. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23945. */
  23946. /**
  23947. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23948. */
  23949. stiffness: number;
  23950. /**
  23951. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23952. */
  23953. /**
  23954. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23955. */
  23956. velocityIterations: number;
  23957. /**
  23958. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23959. */
  23960. /**
  23961. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23962. */
  23963. positionIterations: number;
  23964. /**
  23965. * The unique id of the physics imposter
  23966. * set by the physics engine when adding this impostor to the array
  23967. */
  23968. uniqueId: number;
  23969. /**
  23970. * @hidden
  23971. */
  23972. soft: boolean;
  23973. /**
  23974. * @hidden
  23975. */
  23976. segments: number;
  23977. private _joints;
  23978. /**
  23979. * Initializes the physics imposter
  23980. * @param object The physics-enabled object used as the physics imposter
  23981. * @param type The type of the physics imposter
  23982. * @param _options The options for the physics imposter
  23983. * @param _scene The Babylon scene
  23984. */
  23985. constructor(
  23986. /**
  23987. * The physics-enabled object used as the physics imposter
  23988. */
  23989. object: IPhysicsEnabledObject,
  23990. /**
  23991. * The type of the physics imposter
  23992. */
  23993. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23994. /**
  23995. * This function will completly initialize this impostor.
  23996. * It will create a new body - but only if this mesh has no parent.
  23997. * If it has, this impostor will not be used other than to define the impostor
  23998. * of the child mesh.
  23999. * @hidden
  24000. */
  24001. _init(): void;
  24002. private _getPhysicsParent;
  24003. /**
  24004. * Should a new body be generated.
  24005. * @returns boolean specifying if body initialization is required
  24006. */
  24007. isBodyInitRequired(): boolean;
  24008. /**
  24009. * Sets the updated scaling
  24010. * @param updated Specifies if the scaling is updated
  24011. */
  24012. setScalingUpdated(): void;
  24013. /**
  24014. * Force a regeneration of this or the parent's impostor's body.
  24015. * Use under cautious - This will remove all joints already implemented.
  24016. */
  24017. forceUpdate(): void;
  24018. /**
  24019. * Gets the body that holds this impostor. Either its own, or its parent.
  24020. */
  24021. /**
  24022. * Set the physics body. Used mainly by the physics engine/plugin
  24023. */
  24024. physicsBody: any;
  24025. /**
  24026. * Get the parent of the physics imposter
  24027. * @returns Physics imposter or null
  24028. */
  24029. /**
  24030. * Sets the parent of the physics imposter
  24031. */
  24032. parent: Nullable<PhysicsImpostor>;
  24033. /**
  24034. * Resets the update flags
  24035. */
  24036. resetUpdateFlags(): void;
  24037. /**
  24038. * Gets the object extend size
  24039. * @returns the object extend size
  24040. */
  24041. getObjectExtendSize(): Vector3;
  24042. /**
  24043. * Gets the object center
  24044. * @returns The object center
  24045. */
  24046. getObjectCenter(): Vector3;
  24047. /**
  24048. * Get a specific parametes from the options parameter
  24049. * @param paramName The object parameter name
  24050. * @returns The object parameter
  24051. */
  24052. getParam(paramName: string): any;
  24053. /**
  24054. * Sets a specific parameter in the options given to the physics plugin
  24055. * @param paramName The parameter name
  24056. * @param value The value of the parameter
  24057. */
  24058. setParam(paramName: string, value: number): void;
  24059. /**
  24060. * Specifically change the body's mass option. Won't recreate the physics body object
  24061. * @param mass The mass of the physics imposter
  24062. */
  24063. setMass(mass: number): void;
  24064. /**
  24065. * Gets the linear velocity
  24066. * @returns linear velocity or null
  24067. */
  24068. getLinearVelocity(): Nullable<Vector3>;
  24069. /**
  24070. * Sets the linear velocity
  24071. * @param velocity linear velocity or null
  24072. */
  24073. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24074. /**
  24075. * Gets the angular velocity
  24076. * @returns angular velocity or null
  24077. */
  24078. getAngularVelocity(): Nullable<Vector3>;
  24079. /**
  24080. * Sets the angular velocity
  24081. * @param velocity The velocity or null
  24082. */
  24083. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24084. /**
  24085. * Execute a function with the physics plugin native code
  24086. * Provide a function the will have two variables - the world object and the physics body object
  24087. * @param func The function to execute with the physics plugin native code
  24088. */
  24089. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24090. /**
  24091. * Register a function that will be executed before the physics world is stepping forward
  24092. * @param func The function to execute before the physics world is stepped forward
  24093. */
  24094. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24095. /**
  24096. * Unregister a function that will be executed before the physics world is stepping forward
  24097. * @param func The function to execute before the physics world is stepped forward
  24098. */
  24099. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24100. /**
  24101. * Register a function that will be executed after the physics step
  24102. * @param func The function to execute after physics step
  24103. */
  24104. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24105. /**
  24106. * Unregisters a function that will be executed after the physics step
  24107. * @param func The function to execute after physics step
  24108. */
  24109. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24110. /**
  24111. * register a function that will be executed when this impostor collides against a different body
  24112. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24113. * @param func Callback that is executed on collision
  24114. */
  24115. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24116. /**
  24117. * Unregisters the physics imposter on contact
  24118. * @param collideAgainst The physics object to collide against
  24119. * @param func Callback to execute on collision
  24120. */
  24121. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24122. private _tmpQuat;
  24123. private _tmpQuat2;
  24124. /**
  24125. * Get the parent rotation
  24126. * @returns The parent rotation
  24127. */
  24128. getParentsRotation(): Quaternion;
  24129. /**
  24130. * this function is executed by the physics engine.
  24131. */
  24132. beforeStep: () => void;
  24133. /**
  24134. * this function is executed by the physics engine
  24135. */
  24136. afterStep: () => void;
  24137. /**
  24138. * Legacy collision detection event support
  24139. */
  24140. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24141. /**
  24142. * event and body object due to cannon's event-based architecture.
  24143. */
  24144. onCollide: (e: {
  24145. body: any;
  24146. }) => void;
  24147. /**
  24148. * Apply a force
  24149. * @param force The force to apply
  24150. * @param contactPoint The contact point for the force
  24151. * @returns The physics imposter
  24152. */
  24153. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24154. /**
  24155. * Apply an impulse
  24156. * @param force The impulse force
  24157. * @param contactPoint The contact point for the impulse force
  24158. * @returns The physics imposter
  24159. */
  24160. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24161. /**
  24162. * A help function to create a joint
  24163. * @param otherImpostor A physics imposter used to create a joint
  24164. * @param jointType The type of joint
  24165. * @param jointData The data for the joint
  24166. * @returns The physics imposter
  24167. */
  24168. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24169. /**
  24170. * Add a joint to this impostor with a different impostor
  24171. * @param otherImpostor A physics imposter used to add a joint
  24172. * @param joint The joint to add
  24173. * @returns The physics imposter
  24174. */
  24175. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24176. /**
  24177. * Add an anchor to a cloth impostor
  24178. * @param otherImpostor rigid impostor to anchor to
  24179. * @param width ratio across width from 0 to 1
  24180. * @param height ratio up height from 0 to 1
  24181. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24182. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24183. * @returns impostor the soft imposter
  24184. */
  24185. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24186. /**
  24187. * Add a hook to a rope impostor
  24188. * @param otherImpostor rigid impostor to anchor to
  24189. * @param length ratio across rope from 0 to 1
  24190. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24191. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24192. * @returns impostor the rope imposter
  24193. */
  24194. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24195. /**
  24196. * Will keep this body still, in a sleep mode.
  24197. * @returns the physics imposter
  24198. */
  24199. sleep(): PhysicsImpostor;
  24200. /**
  24201. * Wake the body up.
  24202. * @returns The physics imposter
  24203. */
  24204. wakeUp(): PhysicsImpostor;
  24205. /**
  24206. * Clones the physics imposter
  24207. * @param newObject The physics imposter clones to this physics-enabled object
  24208. * @returns A nullable physics imposter
  24209. */
  24210. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24211. /**
  24212. * Disposes the physics imposter
  24213. */
  24214. dispose(): void;
  24215. /**
  24216. * Sets the delta position
  24217. * @param position The delta position amount
  24218. */
  24219. setDeltaPosition(position: Vector3): void;
  24220. /**
  24221. * Sets the delta rotation
  24222. * @param rotation The delta rotation amount
  24223. */
  24224. setDeltaRotation(rotation: Quaternion): void;
  24225. /**
  24226. * Gets the box size of the physics imposter and stores the result in the input parameter
  24227. * @param result Stores the box size
  24228. * @returns The physics imposter
  24229. */
  24230. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24231. /**
  24232. * Gets the radius of the physics imposter
  24233. * @returns Radius of the physics imposter
  24234. */
  24235. getRadius(): number;
  24236. /**
  24237. * Sync a bone with this impostor
  24238. * @param bone The bone to sync to the impostor.
  24239. * @param boneMesh The mesh that the bone is influencing.
  24240. * @param jointPivot The pivot of the joint / bone in local space.
  24241. * @param distToJoint Optional distance from the impostor to the joint.
  24242. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24243. */
  24244. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24245. /**
  24246. * Sync impostor to a bone
  24247. * @param bone The bone that the impostor will be synced to.
  24248. * @param boneMesh The mesh that the bone is influencing.
  24249. * @param jointPivot The pivot of the joint / bone in local space.
  24250. * @param distToJoint Optional distance from the impostor to the joint.
  24251. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24252. * @param boneAxis Optional vector3 axis the bone is aligned with
  24253. */
  24254. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24255. /**
  24256. * No-Imposter type
  24257. */
  24258. static NoImpostor: number;
  24259. /**
  24260. * Sphere-Imposter type
  24261. */
  24262. static SphereImpostor: number;
  24263. /**
  24264. * Box-Imposter type
  24265. */
  24266. static BoxImpostor: number;
  24267. /**
  24268. * Plane-Imposter type
  24269. */
  24270. static PlaneImpostor: number;
  24271. /**
  24272. * Mesh-imposter type
  24273. */
  24274. static MeshImpostor: number;
  24275. /**
  24276. * Capsule-Impostor type (Ammo.js plugin only)
  24277. */
  24278. static CapsuleImpostor: number;
  24279. /**
  24280. * Cylinder-Imposter type
  24281. */
  24282. static CylinderImpostor: number;
  24283. /**
  24284. * Particle-Imposter type
  24285. */
  24286. static ParticleImpostor: number;
  24287. /**
  24288. * Heightmap-Imposter type
  24289. */
  24290. static HeightmapImpostor: number;
  24291. /**
  24292. * ConvexHull-Impostor type (Ammo.js plugin only)
  24293. */
  24294. static ConvexHullImpostor: number;
  24295. /**
  24296. * Rope-Imposter type
  24297. */
  24298. static RopeImpostor: number;
  24299. /**
  24300. * Cloth-Imposter type
  24301. */
  24302. static ClothImpostor: number;
  24303. /**
  24304. * Softbody-Imposter type
  24305. */
  24306. static SoftbodyImpostor: number;
  24307. }
  24308. }
  24309. declare module "babylonjs/Meshes/mesh" {
  24310. import { Observable } from "babylonjs/Misc/observable";
  24311. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24312. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24313. import { Camera } from "babylonjs/Cameras/camera";
  24314. import { Scene } from "babylonjs/scene";
  24315. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24316. import { Color4 } from "babylonjs/Maths/math.color";
  24317. import { Engine } from "babylonjs/Engines/engine";
  24318. import { Node } from "babylonjs/node";
  24319. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24320. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24321. import { Buffer } from "babylonjs/Meshes/buffer";
  24322. import { Geometry } from "babylonjs/Meshes/geometry";
  24323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24325. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24326. import { Effect } from "babylonjs/Materials/effect";
  24327. import { Material } from "babylonjs/Materials/material";
  24328. import { Skeleton } from "babylonjs/Bones/skeleton";
  24329. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24330. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24331. import { Path3D } from "babylonjs/Maths/math.path";
  24332. import { Plane } from "babylonjs/Maths/math.plane";
  24333. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24334. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24335. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24336. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24337. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24338. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24339. /**
  24340. * @hidden
  24341. **/
  24342. export class _CreationDataStorage {
  24343. closePath?: boolean;
  24344. closeArray?: boolean;
  24345. idx: number[];
  24346. dashSize: number;
  24347. gapSize: number;
  24348. path3D: Path3D;
  24349. pathArray: Vector3[][];
  24350. arc: number;
  24351. radius: number;
  24352. cap: number;
  24353. tessellation: number;
  24354. }
  24355. /**
  24356. * @hidden
  24357. **/
  24358. class _InstanceDataStorage {
  24359. visibleInstances: any;
  24360. batchCache: _InstancesBatch;
  24361. instancesBufferSize: number;
  24362. instancesBuffer: Nullable<Buffer>;
  24363. instancesData: Float32Array;
  24364. overridenInstanceCount: number;
  24365. isFrozen: boolean;
  24366. previousBatch: Nullable<_InstancesBatch>;
  24367. hardwareInstancedRendering: boolean;
  24368. sideOrientation: number;
  24369. }
  24370. /**
  24371. * @hidden
  24372. **/
  24373. export class _InstancesBatch {
  24374. mustReturn: boolean;
  24375. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24376. renderSelf: boolean[];
  24377. hardwareInstancedRendering: boolean[];
  24378. }
  24379. /**
  24380. * Class used to represent renderable models
  24381. */
  24382. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24383. /**
  24384. * Mesh side orientation : usually the external or front surface
  24385. */
  24386. static readonly FRONTSIDE: number;
  24387. /**
  24388. * Mesh side orientation : usually the internal or back surface
  24389. */
  24390. static readonly BACKSIDE: number;
  24391. /**
  24392. * Mesh side orientation : both internal and external or front and back surfaces
  24393. */
  24394. static readonly DOUBLESIDE: number;
  24395. /**
  24396. * Mesh side orientation : by default, `FRONTSIDE`
  24397. */
  24398. static readonly DEFAULTSIDE: number;
  24399. /**
  24400. * Mesh cap setting : no cap
  24401. */
  24402. static readonly NO_CAP: number;
  24403. /**
  24404. * Mesh cap setting : one cap at the beginning of the mesh
  24405. */
  24406. static readonly CAP_START: number;
  24407. /**
  24408. * Mesh cap setting : one cap at the end of the mesh
  24409. */
  24410. static readonly CAP_END: number;
  24411. /**
  24412. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24413. */
  24414. static readonly CAP_ALL: number;
  24415. /**
  24416. * Mesh pattern setting : no flip or rotate
  24417. */
  24418. static readonly NO_FLIP: number;
  24419. /**
  24420. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24421. */
  24422. static readonly FLIP_TILE: number;
  24423. /**
  24424. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24425. */
  24426. static readonly ROTATE_TILE: number;
  24427. /**
  24428. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24429. */
  24430. static readonly FLIP_ROW: number;
  24431. /**
  24432. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24433. */
  24434. static readonly ROTATE_ROW: number;
  24435. /**
  24436. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24437. */
  24438. static readonly FLIP_N_ROTATE_TILE: number;
  24439. /**
  24440. * Mesh pattern setting : rotate pattern and rotate
  24441. */
  24442. static readonly FLIP_N_ROTATE_ROW: number;
  24443. /**
  24444. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24445. */
  24446. static readonly CENTER: number;
  24447. /**
  24448. * Mesh tile positioning : part tiles on left
  24449. */
  24450. static readonly LEFT: number;
  24451. /**
  24452. * Mesh tile positioning : part tiles on right
  24453. */
  24454. static readonly RIGHT: number;
  24455. /**
  24456. * Mesh tile positioning : part tiles on top
  24457. */
  24458. static readonly TOP: number;
  24459. /**
  24460. * Mesh tile positioning : part tiles on bottom
  24461. */
  24462. static readonly BOTTOM: number;
  24463. /**
  24464. * Gets the default side orientation.
  24465. * @param orientation the orientation to value to attempt to get
  24466. * @returns the default orientation
  24467. * @hidden
  24468. */
  24469. static _GetDefaultSideOrientation(orientation?: number): number;
  24470. private _internalMeshDataInfo;
  24471. /**
  24472. * An event triggered before rendering the mesh
  24473. */
  24474. readonly onBeforeRenderObservable: Observable<Mesh>;
  24475. /**
  24476. * An event triggered before binding the mesh
  24477. */
  24478. readonly onBeforeBindObservable: Observable<Mesh>;
  24479. /**
  24480. * An event triggered after rendering the mesh
  24481. */
  24482. readonly onAfterRenderObservable: Observable<Mesh>;
  24483. /**
  24484. * An event triggered before drawing the mesh
  24485. */
  24486. readonly onBeforeDrawObservable: Observable<Mesh>;
  24487. private _onBeforeDrawObserver;
  24488. /**
  24489. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24490. */
  24491. onBeforeDraw: () => void;
  24492. readonly hasInstances: boolean;
  24493. /**
  24494. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24495. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24496. */
  24497. delayLoadState: number;
  24498. /**
  24499. * Gets the list of instances created from this mesh
  24500. * it is not supposed to be modified manually.
  24501. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24502. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24503. */
  24504. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24505. /**
  24506. * Gets the file containing delay loading data for this mesh
  24507. */
  24508. delayLoadingFile: string;
  24509. /** @hidden */
  24510. _binaryInfo: any;
  24511. /**
  24512. * User defined function used to change how LOD level selection is done
  24513. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24514. */
  24515. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24516. /**
  24517. * Gets or sets the morph target manager
  24518. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24519. */
  24520. morphTargetManager: Nullable<MorphTargetManager>;
  24521. /** @hidden */
  24522. _creationDataStorage: Nullable<_CreationDataStorage>;
  24523. /** @hidden */
  24524. _geometry: Nullable<Geometry>;
  24525. /** @hidden */
  24526. _delayInfo: Array<string>;
  24527. /** @hidden */
  24528. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24529. /** @hidden */
  24530. _instanceDataStorage: _InstanceDataStorage;
  24531. private _effectiveMaterial;
  24532. /** @hidden */
  24533. _shouldGenerateFlatShading: boolean;
  24534. /** @hidden */
  24535. _originalBuilderSideOrientation: number;
  24536. /**
  24537. * Use this property to change the original side orientation defined at construction time
  24538. */
  24539. overrideMaterialSideOrientation: Nullable<number>;
  24540. /**
  24541. * Gets the source mesh (the one used to clone this one from)
  24542. */
  24543. readonly source: Nullable<Mesh>;
  24544. /**
  24545. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24546. */
  24547. isUnIndexed: boolean;
  24548. /**
  24549. * @constructor
  24550. * @param name The value used by scene.getMeshByName() to do a lookup.
  24551. * @param scene The scene to add this mesh to.
  24552. * @param parent The parent of this mesh, if it has one
  24553. * @param source An optional Mesh from which geometry is shared, cloned.
  24554. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24555. * When false, achieved by calling a clone(), also passing False.
  24556. * This will make creation of children, recursive.
  24557. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24558. */
  24559. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24560. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24561. doNotInstantiate: boolean;
  24562. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24563. /**
  24564. * Gets the class name
  24565. * @returns the string "Mesh".
  24566. */
  24567. getClassName(): string;
  24568. /** @hidden */
  24569. readonly _isMesh: boolean;
  24570. /**
  24571. * Returns a description of this mesh
  24572. * @param fullDetails define if full details about this mesh must be used
  24573. * @returns a descriptive string representing this mesh
  24574. */
  24575. toString(fullDetails?: boolean): string;
  24576. /** @hidden */
  24577. _unBindEffect(): void;
  24578. /**
  24579. * Gets a boolean indicating if this mesh has LOD
  24580. */
  24581. readonly hasLODLevels: boolean;
  24582. /**
  24583. * Gets the list of MeshLODLevel associated with the current mesh
  24584. * @returns an array of MeshLODLevel
  24585. */
  24586. getLODLevels(): MeshLODLevel[];
  24587. private _sortLODLevels;
  24588. /**
  24589. * Add a mesh as LOD level triggered at the given distance.
  24590. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24591. * @param distance The distance from the center of the object to show this level
  24592. * @param mesh The mesh to be added as LOD level (can be null)
  24593. * @return This mesh (for chaining)
  24594. */
  24595. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24596. /**
  24597. * Returns the LOD level mesh at the passed distance or null if not found.
  24598. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24599. * @param distance The distance from the center of the object to show this level
  24600. * @returns a Mesh or `null`
  24601. */
  24602. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24603. /**
  24604. * Remove a mesh from the LOD array
  24605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24606. * @param mesh defines the mesh to be removed
  24607. * @return This mesh (for chaining)
  24608. */
  24609. removeLODLevel(mesh: Mesh): Mesh;
  24610. /**
  24611. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24613. * @param camera defines the camera to use to compute distance
  24614. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24615. * @return This mesh (for chaining)
  24616. */
  24617. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24618. /**
  24619. * Gets the mesh internal Geometry object
  24620. */
  24621. readonly geometry: Nullable<Geometry>;
  24622. /**
  24623. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24624. * @returns the total number of vertices
  24625. */
  24626. getTotalVertices(): number;
  24627. /**
  24628. * Returns the content of an associated vertex buffer
  24629. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24630. * - VertexBuffer.PositionKind
  24631. * - VertexBuffer.UVKind
  24632. * - VertexBuffer.UV2Kind
  24633. * - VertexBuffer.UV3Kind
  24634. * - VertexBuffer.UV4Kind
  24635. * - VertexBuffer.UV5Kind
  24636. * - VertexBuffer.UV6Kind
  24637. * - VertexBuffer.ColorKind
  24638. * - VertexBuffer.MatricesIndicesKind
  24639. * - VertexBuffer.MatricesIndicesExtraKind
  24640. * - VertexBuffer.MatricesWeightsKind
  24641. * - VertexBuffer.MatricesWeightsExtraKind
  24642. * @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
  24643. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24644. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24645. */
  24646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24647. /**
  24648. * Returns the mesh VertexBuffer object from the requested `kind`
  24649. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24650. * - VertexBuffer.PositionKind
  24651. * - VertexBuffer.NormalKind
  24652. * - VertexBuffer.UVKind
  24653. * - VertexBuffer.UV2Kind
  24654. * - VertexBuffer.UV3Kind
  24655. * - VertexBuffer.UV4Kind
  24656. * - VertexBuffer.UV5Kind
  24657. * - VertexBuffer.UV6Kind
  24658. * - VertexBuffer.ColorKind
  24659. * - VertexBuffer.MatricesIndicesKind
  24660. * - VertexBuffer.MatricesIndicesExtraKind
  24661. * - VertexBuffer.MatricesWeightsKind
  24662. * - VertexBuffer.MatricesWeightsExtraKind
  24663. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24664. */
  24665. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24666. /**
  24667. * Tests if a specific vertex buffer is associated with this mesh
  24668. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24669. * - VertexBuffer.PositionKind
  24670. * - VertexBuffer.NormalKind
  24671. * - VertexBuffer.UVKind
  24672. * - VertexBuffer.UV2Kind
  24673. * - VertexBuffer.UV3Kind
  24674. * - VertexBuffer.UV4Kind
  24675. * - VertexBuffer.UV5Kind
  24676. * - VertexBuffer.UV6Kind
  24677. * - VertexBuffer.ColorKind
  24678. * - VertexBuffer.MatricesIndicesKind
  24679. * - VertexBuffer.MatricesIndicesExtraKind
  24680. * - VertexBuffer.MatricesWeightsKind
  24681. * - VertexBuffer.MatricesWeightsExtraKind
  24682. * @returns a boolean
  24683. */
  24684. isVerticesDataPresent(kind: string): boolean;
  24685. /**
  24686. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24687. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24688. * - VertexBuffer.PositionKind
  24689. * - VertexBuffer.UVKind
  24690. * - VertexBuffer.UV2Kind
  24691. * - VertexBuffer.UV3Kind
  24692. * - VertexBuffer.UV4Kind
  24693. * - VertexBuffer.UV5Kind
  24694. * - VertexBuffer.UV6Kind
  24695. * - VertexBuffer.ColorKind
  24696. * - VertexBuffer.MatricesIndicesKind
  24697. * - VertexBuffer.MatricesIndicesExtraKind
  24698. * - VertexBuffer.MatricesWeightsKind
  24699. * - VertexBuffer.MatricesWeightsExtraKind
  24700. * @returns a boolean
  24701. */
  24702. isVertexBufferUpdatable(kind: string): boolean;
  24703. /**
  24704. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24705. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24706. * - VertexBuffer.PositionKind
  24707. * - VertexBuffer.NormalKind
  24708. * - VertexBuffer.UVKind
  24709. * - VertexBuffer.UV2Kind
  24710. * - VertexBuffer.UV3Kind
  24711. * - VertexBuffer.UV4Kind
  24712. * - VertexBuffer.UV5Kind
  24713. * - VertexBuffer.UV6Kind
  24714. * - VertexBuffer.ColorKind
  24715. * - VertexBuffer.MatricesIndicesKind
  24716. * - VertexBuffer.MatricesIndicesExtraKind
  24717. * - VertexBuffer.MatricesWeightsKind
  24718. * - VertexBuffer.MatricesWeightsExtraKind
  24719. * @returns an array of strings
  24720. */
  24721. getVerticesDataKinds(): string[];
  24722. /**
  24723. * Returns a positive integer : the total number of indices in this mesh geometry.
  24724. * @returns the numner of indices or zero if the mesh has no geometry.
  24725. */
  24726. getTotalIndices(): number;
  24727. /**
  24728. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24729. * @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.
  24730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24731. * @returns the indices array or an empty array if the mesh has no geometry
  24732. */
  24733. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24734. readonly isBlocked: boolean;
  24735. /**
  24736. * Determine if the current mesh is ready to be rendered
  24737. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24738. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24739. * @returns true if all associated assets are ready (material, textures, shaders)
  24740. */
  24741. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24742. /**
  24743. * 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.
  24744. */
  24745. readonly areNormalsFrozen: boolean;
  24746. /**
  24747. * 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.
  24748. * @returns the current mesh
  24749. */
  24750. freezeNormals(): Mesh;
  24751. /**
  24752. * 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
  24753. * @returns the current mesh
  24754. */
  24755. unfreezeNormals(): Mesh;
  24756. /**
  24757. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24758. */
  24759. overridenInstanceCount: number;
  24760. /** @hidden */
  24761. _preActivate(): Mesh;
  24762. /** @hidden */
  24763. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24764. /** @hidden */
  24765. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24766. /**
  24767. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24768. * This means the mesh underlying bounding box and sphere are recomputed.
  24769. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24770. * @returns the current mesh
  24771. */
  24772. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24773. /** @hidden */
  24774. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24775. /**
  24776. * This function will subdivide the mesh into multiple submeshes
  24777. * @param count defines the expected number of submeshes
  24778. */
  24779. subdivide(count: number): void;
  24780. /**
  24781. * Copy a FloatArray into a specific associated vertex buffer
  24782. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24783. * - VertexBuffer.PositionKind
  24784. * - VertexBuffer.UVKind
  24785. * - VertexBuffer.UV2Kind
  24786. * - VertexBuffer.UV3Kind
  24787. * - VertexBuffer.UV4Kind
  24788. * - VertexBuffer.UV5Kind
  24789. * - VertexBuffer.UV6Kind
  24790. * - VertexBuffer.ColorKind
  24791. * - VertexBuffer.MatricesIndicesKind
  24792. * - VertexBuffer.MatricesIndicesExtraKind
  24793. * - VertexBuffer.MatricesWeightsKind
  24794. * - VertexBuffer.MatricesWeightsExtraKind
  24795. * @param data defines the data source
  24796. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24797. * @param stride defines the data stride size (can be null)
  24798. * @returns the current mesh
  24799. */
  24800. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24801. /**
  24802. * Delete a vertex buffer associated with this mesh
  24803. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. */
  24817. removeVerticesData(kind: string): void;
  24818. /**
  24819. * Flags an associated vertex buffer as updatable
  24820. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24821. * - VertexBuffer.PositionKind
  24822. * - VertexBuffer.UVKind
  24823. * - VertexBuffer.UV2Kind
  24824. * - VertexBuffer.UV3Kind
  24825. * - VertexBuffer.UV4Kind
  24826. * - VertexBuffer.UV5Kind
  24827. * - VertexBuffer.UV6Kind
  24828. * - VertexBuffer.ColorKind
  24829. * - VertexBuffer.MatricesIndicesKind
  24830. * - VertexBuffer.MatricesIndicesExtraKind
  24831. * - VertexBuffer.MatricesWeightsKind
  24832. * - VertexBuffer.MatricesWeightsExtraKind
  24833. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24834. */
  24835. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24836. /**
  24837. * Sets the mesh global Vertex Buffer
  24838. * @param buffer defines the buffer to use
  24839. * @returns the current mesh
  24840. */
  24841. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24842. /**
  24843. * Update a specific associated vertex buffer
  24844. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24845. * - VertexBuffer.PositionKind
  24846. * - VertexBuffer.UVKind
  24847. * - VertexBuffer.UV2Kind
  24848. * - VertexBuffer.UV3Kind
  24849. * - VertexBuffer.UV4Kind
  24850. * - VertexBuffer.UV5Kind
  24851. * - VertexBuffer.UV6Kind
  24852. * - VertexBuffer.ColorKind
  24853. * - VertexBuffer.MatricesIndicesKind
  24854. * - VertexBuffer.MatricesIndicesExtraKind
  24855. * - VertexBuffer.MatricesWeightsKind
  24856. * - VertexBuffer.MatricesWeightsExtraKind
  24857. * @param data defines the data source
  24858. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24859. * @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)
  24860. * @returns the current mesh
  24861. */
  24862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24863. /**
  24864. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24865. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24866. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24867. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24868. * @returns the current mesh
  24869. */
  24870. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24871. /**
  24872. * Creates a un-shared specific occurence of the geometry for the mesh.
  24873. * @returns the current mesh
  24874. */
  24875. makeGeometryUnique(): Mesh;
  24876. /**
  24877. * Set the index buffer of this mesh
  24878. * @param indices defines the source data
  24879. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24880. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24881. * @returns the current mesh
  24882. */
  24883. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24884. /**
  24885. * Update the current index buffer
  24886. * @param indices defines the source data
  24887. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24888. * @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)
  24889. * @returns the current mesh
  24890. */
  24891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24892. /**
  24893. * Invert the geometry to move from a right handed system to a left handed one.
  24894. * @returns the current mesh
  24895. */
  24896. toLeftHanded(): Mesh;
  24897. /** @hidden */
  24898. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24899. /** @hidden */
  24900. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24901. /**
  24902. * Registers for this mesh a javascript function called just before the rendering process
  24903. * @param func defines the function to call before rendering this mesh
  24904. * @returns the current mesh
  24905. */
  24906. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24907. /**
  24908. * Disposes a previously registered javascript function called before the rendering
  24909. * @param func defines the function to remove
  24910. * @returns the current mesh
  24911. */
  24912. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24913. /**
  24914. * Registers for this mesh a javascript function called just after the rendering is complete
  24915. * @param func defines the function to call after rendering this mesh
  24916. * @returns the current mesh
  24917. */
  24918. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24919. /**
  24920. * Disposes a previously registered javascript function called after the rendering.
  24921. * @param func defines the function to remove
  24922. * @returns the current mesh
  24923. */
  24924. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24925. /** @hidden */
  24926. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24927. /** @hidden */
  24928. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24929. /** @hidden */
  24930. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24931. /** @hidden */
  24932. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24933. /** @hidden */
  24934. _rebuild(): void;
  24935. /** @hidden */
  24936. _freeze(): void;
  24937. /** @hidden */
  24938. _unFreeze(): void;
  24939. /**
  24940. * 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
  24941. * @param subMesh defines the subMesh to render
  24942. * @param enableAlphaMode defines if alpha mode can be changed
  24943. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24944. * @returns the current mesh
  24945. */
  24946. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24947. private _onBeforeDraw;
  24948. /**
  24949. * Renormalize the mesh and patch it up if there are no weights
  24950. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24951. * However in the case of zero weights then we set just a single influence to 1.
  24952. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24953. */
  24954. cleanMatrixWeights(): void;
  24955. private normalizeSkinFourWeights;
  24956. private normalizeSkinWeightsAndExtra;
  24957. /**
  24958. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24959. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24960. * the user know there was an issue with importing the mesh
  24961. * @returns a validation object with skinned, valid and report string
  24962. */
  24963. validateSkinning(): {
  24964. skinned: boolean;
  24965. valid: boolean;
  24966. report: string;
  24967. };
  24968. /** @hidden */
  24969. _checkDelayState(): Mesh;
  24970. private _queueLoad;
  24971. /**
  24972. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24973. * A mesh is in the frustum if its bounding box intersects the frustum
  24974. * @param frustumPlanes defines the frustum to test
  24975. * @returns true if the mesh is in the frustum planes
  24976. */
  24977. isInFrustum(frustumPlanes: Plane[]): boolean;
  24978. /**
  24979. * Sets the mesh material by the material or multiMaterial `id` property
  24980. * @param id is a string identifying the material or the multiMaterial
  24981. * @returns the current mesh
  24982. */
  24983. setMaterialByID(id: string): Mesh;
  24984. /**
  24985. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24986. * @returns an array of IAnimatable
  24987. */
  24988. getAnimatables(): IAnimatable[];
  24989. /**
  24990. * Modifies the mesh geometry according to the passed transformation matrix.
  24991. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24992. * The mesh normals are modified using the same transformation.
  24993. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24994. * @param transform defines the transform matrix to use
  24995. * @see http://doc.babylonjs.com/resources/baking_transformations
  24996. * @returns the current mesh
  24997. */
  24998. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24999. /**
  25000. * Modifies the mesh geometry according to its own current World Matrix.
  25001. * The mesh World Matrix is then reset.
  25002. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25003. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25004. * @see http://doc.babylonjs.com/resources/baking_transformations
  25005. * @returns the current mesh
  25006. */
  25007. bakeCurrentTransformIntoVertices(): Mesh;
  25008. /** @hidden */
  25009. readonly _positions: Nullable<Vector3[]>;
  25010. /** @hidden */
  25011. _resetPointsArrayCache(): Mesh;
  25012. /** @hidden */
  25013. _generatePointsArray(): boolean;
  25014. /**
  25015. * Returns a new Mesh object generated from the current mesh properties.
  25016. * This method must not get confused with createInstance()
  25017. * @param name is a string, the name given to the new mesh
  25018. * @param newParent can be any Node object (default `null`)
  25019. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25020. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25021. * @returns a new mesh
  25022. */
  25023. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25024. /**
  25025. * Releases resources associated with this mesh.
  25026. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25027. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25028. */
  25029. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25030. /** @hidden */
  25031. _disposeInstanceSpecificData(): void;
  25032. /**
  25033. * Modifies the mesh geometry according to a displacement map.
  25034. * 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.
  25035. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25036. * @param url is a string, the URL from the image file is to be downloaded.
  25037. * @param minHeight is the lower limit of the displacement.
  25038. * @param maxHeight is the upper limit of the displacement.
  25039. * @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.
  25040. * @param uvOffset is an optional vector2 used to offset UV.
  25041. * @param uvScale is an optional vector2 used to scale UV.
  25042. * @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.
  25043. * @returns the Mesh.
  25044. */
  25045. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25046. /**
  25047. * Modifies the mesh geometry according to a displacementMap buffer.
  25048. * 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.
  25049. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25050. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25051. * @param heightMapWidth is the width of the buffer image.
  25052. * @param heightMapHeight is the height of the buffer image.
  25053. * @param minHeight is the lower limit of the displacement.
  25054. * @param maxHeight is the upper limit of the displacement.
  25055. * @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.
  25056. * @param uvOffset is an optional vector2 used to offset UV.
  25057. * @param uvScale is an optional vector2 used to scale UV.
  25058. * @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.
  25059. * @returns the Mesh.
  25060. */
  25061. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25062. /**
  25063. * Modify the mesh to get a flat shading rendering.
  25064. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25065. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25066. * @returns current mesh
  25067. */
  25068. convertToFlatShadedMesh(): Mesh;
  25069. /**
  25070. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25071. * In other words, more vertices, no more indices and a single bigger VBO.
  25072. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25073. * @returns current mesh
  25074. */
  25075. convertToUnIndexedMesh(): Mesh;
  25076. /**
  25077. * Inverses facet orientations.
  25078. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25079. * @param flipNormals will also inverts the normals
  25080. * @returns current mesh
  25081. */
  25082. flipFaces(flipNormals?: boolean): Mesh;
  25083. /**
  25084. * Increase the number of facets and hence vertices in a mesh
  25085. * Vertex normals are interpolated from existing vertex normals
  25086. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25087. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25088. */
  25089. increaseVertices(numberPerEdge: number): void;
  25090. /**
  25091. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25092. * This will undo any application of covertToFlatShadedMesh
  25093. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25094. */
  25095. forceSharedVertices(): void;
  25096. /** @hidden */
  25097. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25098. /** @hidden */
  25099. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25100. /**
  25101. * Creates a new InstancedMesh object from the mesh model.
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25103. * @param name defines the name of the new instance
  25104. * @returns a new InstancedMesh
  25105. */
  25106. createInstance(name: string): InstancedMesh;
  25107. /**
  25108. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25109. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25110. * @returns the current mesh
  25111. */
  25112. synchronizeInstances(): Mesh;
  25113. /**
  25114. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25115. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25116. * This should be used together with the simplification to avoid disappearing triangles.
  25117. * @param successCallback an optional success callback to be called after the optimization finished.
  25118. * @returns the current mesh
  25119. */
  25120. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25121. /**
  25122. * Serialize current mesh
  25123. * @param serializationObject defines the object which will receive the serialization data
  25124. */
  25125. serialize(serializationObject: any): void;
  25126. /** @hidden */
  25127. _syncGeometryWithMorphTargetManager(): void;
  25128. /** @hidden */
  25129. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25130. /**
  25131. * Returns a new Mesh object parsed from the source provided.
  25132. * @param parsedMesh is the source
  25133. * @param scene defines the hosting scene
  25134. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25135. * @returns a new Mesh
  25136. */
  25137. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25138. /**
  25139. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25140. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25141. * @param name defines the name of the mesh to create
  25142. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25143. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25144. * @param closePath creates a seam between the first and the last points of each path of the path array
  25145. * @param offset is taken in account only if the `pathArray` is containing a single path
  25146. * @param scene defines the hosting scene
  25147. * @param updatable defines if the mesh must be flagged as updatable
  25148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25149. * @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)
  25150. * @returns a new Mesh
  25151. */
  25152. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25153. /**
  25154. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25155. * @param name defines the name of the mesh to create
  25156. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25157. * @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
  25158. * @param scene defines the hosting scene
  25159. * @param updatable defines if the mesh must be flagged as updatable
  25160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25161. * @returns a new Mesh
  25162. */
  25163. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25164. /**
  25165. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25166. * @param name defines the name of the mesh to create
  25167. * @param size sets the size (float) of each box side (default 1)
  25168. * @param scene defines the hosting scene
  25169. * @param updatable defines if the mesh must be flagged as updatable
  25170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25171. * @returns a new Mesh
  25172. */
  25173. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25174. /**
  25175. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25176. * @param name defines the name of the mesh to create
  25177. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25178. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25179. * @param scene defines the hosting scene
  25180. * @param updatable defines if the mesh must be flagged as updatable
  25181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25182. * @returns a new Mesh
  25183. */
  25184. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25185. /**
  25186. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25187. * @param name defines the name of the mesh to create
  25188. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25189. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25190. * @param scene defines the hosting scene
  25191. * @returns a new Mesh
  25192. */
  25193. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25194. /**
  25195. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25196. * @param name defines the name of the mesh to create
  25197. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25198. * @param diameterTop set the top cap diameter (floats, default 1)
  25199. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25200. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25201. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25202. * @param scene defines the hosting scene
  25203. * @param updatable defines if the mesh must be flagged as updatable
  25204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25205. * @returns a new Mesh
  25206. */
  25207. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25208. /**
  25209. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25210. * @param name defines the name of the mesh to create
  25211. * @param diameter sets the diameter size (float) of the torus (default 1)
  25212. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25213. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25214. * @param scene defines the hosting scene
  25215. * @param updatable defines if the mesh must be flagged as updatable
  25216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25217. * @returns a new Mesh
  25218. */
  25219. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25220. /**
  25221. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25222. * @param name defines the name of the mesh to create
  25223. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25224. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25225. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25226. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25227. * @param p the number of windings on X axis (positive integers, default 2)
  25228. * @param q the number of windings on Y axis (positive integers, default 3)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25235. /**
  25236. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25237. * @param name defines the name of the mesh to create
  25238. * @param points is an array successive Vector3
  25239. * @param scene defines the hosting scene
  25240. * @param updatable defines if the mesh must be flagged as updatable
  25241. * @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).
  25242. * @returns a new Mesh
  25243. */
  25244. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25245. /**
  25246. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25247. * @param name defines the name of the mesh to create
  25248. * @param points is an array successive Vector3
  25249. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25250. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25251. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25252. * @param scene defines the hosting scene
  25253. * @param updatable defines if the mesh must be flagged as updatable
  25254. * @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)
  25255. * @returns a new Mesh
  25256. */
  25257. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25258. /**
  25259. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25260. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25261. * 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.
  25262. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25263. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25264. * Remember you can only change the shape positions, not their number when updating a polygon.
  25265. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25266. * @param name defines the name of the mesh to create
  25267. * @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
  25268. * @param scene defines the hosting scene
  25269. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25272. * @param earcutInjection can be used to inject your own earcut reference
  25273. * @returns a new Mesh
  25274. */
  25275. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25276. /**
  25277. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25278. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25279. * @param name defines the name of the mesh to create
  25280. * @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
  25281. * @param depth defines the height of extrusion
  25282. * @param scene defines the hosting scene
  25283. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25284. * @param updatable defines if the mesh must be flagged as updatable
  25285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25286. * @param earcutInjection can be used to inject your own earcut reference
  25287. * @returns a new Mesh
  25288. */
  25289. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25290. /**
  25291. * Creates an extruded shape mesh.
  25292. * 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
  25293. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25294. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25295. * @param name defines the name of the mesh to create
  25296. * @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
  25297. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25298. * @param scale is the value to scale the shape
  25299. * @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
  25300. * @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
  25301. * @param scene defines the hosting scene
  25302. * @param updatable defines if the mesh must be flagged as updatable
  25303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25304. * @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)
  25305. * @returns a new Mesh
  25306. */
  25307. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25308. /**
  25309. * Creates an custom extruded shape mesh.
  25310. * The custom extrusion is a parametric shape.
  25311. * It has no predefined shape. Its final shape will depend on the input parameters.
  25312. * Please consider using the same method from the MeshBuilder class instead
  25313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25314. * @param name defines the name of the mesh to create
  25315. * @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
  25316. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25317. * @param scaleFunction is a custom Javascript function called on each path point
  25318. * @param rotationFunction is a custom Javascript function called on each path point
  25319. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25320. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25321. * @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
  25322. * @param scene defines the hosting scene
  25323. * @param updatable defines if the mesh must be flagged as updatable
  25324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25325. * @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)
  25326. * @returns a new Mesh
  25327. */
  25328. 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;
  25329. /**
  25330. * Creates lathe mesh.
  25331. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25332. * Please consider using the same method from the MeshBuilder class instead
  25333. * @param name defines the name of the mesh to create
  25334. * @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
  25335. * @param radius is the radius value of the lathe
  25336. * @param tessellation is the side number of the lathe.
  25337. * @param scene defines the hosting scene
  25338. * @param updatable defines if the mesh must be flagged as updatable
  25339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25340. * @returns a new Mesh
  25341. */
  25342. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25343. /**
  25344. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25345. * @param name defines the name of the mesh to create
  25346. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25347. * @param scene defines the hosting scene
  25348. * @param updatable defines if the mesh must be flagged as updatable
  25349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25350. * @returns a new Mesh
  25351. */
  25352. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25353. /**
  25354. * Creates a ground mesh.
  25355. * Please consider using the same method from the MeshBuilder class instead
  25356. * @param name defines the name of the mesh to create
  25357. * @param width set the width of the ground
  25358. * @param height set the height of the ground
  25359. * @param subdivisions sets the number of subdivisions per side
  25360. * @param scene defines the hosting scene
  25361. * @param updatable defines if the mesh must be flagged as updatable
  25362. * @returns a new Mesh
  25363. */
  25364. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25365. /**
  25366. * Creates a tiled ground mesh.
  25367. * Please consider using the same method from the MeshBuilder class instead
  25368. * @param name defines the name of the mesh to create
  25369. * @param xmin set the ground minimum X coordinate
  25370. * @param zmin set the ground minimum Y coordinate
  25371. * @param xmax set the ground maximum X coordinate
  25372. * @param zmax set the ground maximum Z coordinate
  25373. * @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
  25374. * @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
  25375. * @param scene defines the hosting scene
  25376. * @param updatable defines if the mesh must be flagged as updatable
  25377. * @returns a new Mesh
  25378. */
  25379. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25380. w: number;
  25381. h: number;
  25382. }, precision: {
  25383. w: number;
  25384. h: number;
  25385. }, scene: Scene, updatable?: boolean): Mesh;
  25386. /**
  25387. * Creates a ground mesh from a height map.
  25388. * Please consider using the same method from the MeshBuilder class instead
  25389. * @see http://doc.babylonjs.com/babylon101/height_map
  25390. * @param name defines the name of the mesh to create
  25391. * @param url sets the URL of the height map image resource
  25392. * @param width set the ground width size
  25393. * @param height set the ground height size
  25394. * @param subdivisions sets the number of subdivision per side
  25395. * @param minHeight is the minimum altitude on the ground
  25396. * @param maxHeight is the maximum altitude on the ground
  25397. * @param scene defines the hosting scene
  25398. * @param updatable defines if the mesh must be flagged as updatable
  25399. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25400. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25401. * @returns a new Mesh
  25402. */
  25403. 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;
  25404. /**
  25405. * Creates a tube mesh.
  25406. * The tube is a parametric shape.
  25407. * It has no predefined shape. Its final shape will depend on the input parameters.
  25408. * Please consider using the same method from the MeshBuilder class instead
  25409. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25410. * @param name defines the name of the mesh to create
  25411. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25412. * @param radius sets the tube radius size
  25413. * @param tessellation is the number of sides on the tubular surface
  25414. * @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
  25415. * @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
  25416. * @param scene defines the hosting scene
  25417. * @param updatable defines if the mesh must be flagged as updatable
  25418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25419. * @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)
  25420. * @returns a new Mesh
  25421. */
  25422. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25423. (i: number, distance: number): number;
  25424. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25425. /**
  25426. * Creates a polyhedron mesh.
  25427. * Please consider using the same method from the MeshBuilder class instead.
  25428. * * 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
  25429. * * The parameter `size` (positive float, default 1) sets the polygon size
  25430. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25431. * * 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`
  25432. * * 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
  25433. * * 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)`)
  25434. * * 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
  25435. * * 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
  25436. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * * If you create a double-sided mesh, you can choose what parts of 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
  25438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25439. * @param name defines the name of the mesh to create
  25440. * @param options defines the options used to create the mesh
  25441. * @param scene defines the hosting scene
  25442. * @returns a new Mesh
  25443. */
  25444. static CreatePolyhedron(name: string, options: {
  25445. type?: number;
  25446. size?: number;
  25447. sizeX?: number;
  25448. sizeY?: number;
  25449. sizeZ?: number;
  25450. custom?: any;
  25451. faceUV?: Vector4[];
  25452. faceColors?: Color4[];
  25453. updatable?: boolean;
  25454. sideOrientation?: number;
  25455. }, scene: Scene): Mesh;
  25456. /**
  25457. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25458. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25459. * * 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`)
  25460. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25461. * * 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
  25462. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25463. * * If you create a double-sided mesh, you can choose what parts of 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
  25464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25465. * @param name defines the name of the mesh
  25466. * @param options defines the options used to create the mesh
  25467. * @param scene defines the hosting scene
  25468. * @returns a new Mesh
  25469. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25470. */
  25471. static CreateIcoSphere(name: string, options: {
  25472. radius?: number;
  25473. flat?: boolean;
  25474. subdivisions?: number;
  25475. sideOrientation?: number;
  25476. updatable?: boolean;
  25477. }, scene: Scene): Mesh;
  25478. /**
  25479. * Creates a decal mesh.
  25480. * Please consider using the same method from the MeshBuilder class instead.
  25481. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25482. * @param name defines the name of the mesh
  25483. * @param sourceMesh defines the mesh receiving the decal
  25484. * @param position sets the position of the decal in world coordinates
  25485. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25486. * @param size sets the decal scaling
  25487. * @param angle sets the angle to rotate the decal
  25488. * @returns a new Mesh
  25489. */
  25490. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25491. /**
  25492. * Prepare internal position array for software CPU skinning
  25493. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25494. */
  25495. setPositionsForCPUSkinning(): Float32Array;
  25496. /**
  25497. * Prepare internal normal array for software CPU skinning
  25498. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25499. */
  25500. setNormalsForCPUSkinning(): Float32Array;
  25501. /**
  25502. * Updates the vertex buffer by applying transformation from the bones
  25503. * @param skeleton defines the skeleton to apply to current mesh
  25504. * @returns the current mesh
  25505. */
  25506. applySkeleton(skeleton: Skeleton): Mesh;
  25507. /**
  25508. * 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
  25509. * @param meshes defines the list of meshes to scan
  25510. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25511. */
  25512. static MinMax(meshes: AbstractMesh[]): {
  25513. min: Vector3;
  25514. max: Vector3;
  25515. };
  25516. /**
  25517. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25518. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25519. * @returns a vector3
  25520. */
  25521. static Center(meshesOrMinMaxVector: {
  25522. min: Vector3;
  25523. max: Vector3;
  25524. } | AbstractMesh[]): Vector3;
  25525. /**
  25526. * Merge the array of meshes into a single mesh for performance reasons.
  25527. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25528. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25529. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25530. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25531. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25532. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25533. * @returns a new mesh
  25534. */
  25535. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25536. /** @hidden */
  25537. addInstance(instance: InstancedMesh): void;
  25538. /** @hidden */
  25539. removeInstance(instance: InstancedMesh): void;
  25540. }
  25541. }
  25542. declare module "babylonjs/Cameras/camera" {
  25543. import { SmartArray } from "babylonjs/Misc/smartArray";
  25544. import { Observable } from "babylonjs/Misc/observable";
  25545. import { Nullable } from "babylonjs/types";
  25546. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25547. import { Scene } from "babylonjs/scene";
  25548. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25549. import { Node } from "babylonjs/node";
  25550. import { Mesh } from "babylonjs/Meshes/mesh";
  25551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25552. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25553. import { Viewport } from "babylonjs/Maths/math.viewport";
  25554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25556. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25557. import { Ray } from "babylonjs/Culling/ray";
  25558. /**
  25559. * This is the base class of all the camera used in the application.
  25560. * @see http://doc.babylonjs.com/features/cameras
  25561. */
  25562. export class Camera extends Node {
  25563. /** @hidden */
  25564. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25565. /**
  25566. * This is the default projection mode used by the cameras.
  25567. * It helps recreating a feeling of perspective and better appreciate depth.
  25568. * This is the best way to simulate real life cameras.
  25569. */
  25570. static readonly PERSPECTIVE_CAMERA: number;
  25571. /**
  25572. * This helps creating camera with an orthographic mode.
  25573. * 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.
  25574. */
  25575. static readonly ORTHOGRAPHIC_CAMERA: number;
  25576. /**
  25577. * This is the default FOV mode for perspective cameras.
  25578. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25579. */
  25580. static readonly FOVMODE_VERTICAL_FIXED: number;
  25581. /**
  25582. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25583. */
  25584. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25585. /**
  25586. * This specifies ther is no need for a camera rig.
  25587. * Basically only one eye is rendered corresponding to the camera.
  25588. */
  25589. static readonly RIG_MODE_NONE: number;
  25590. /**
  25591. * Simulates a camera Rig with one blue eye and one red eye.
  25592. * This can be use with 3d blue and red glasses.
  25593. */
  25594. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25595. /**
  25596. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25597. */
  25598. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25599. /**
  25600. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25601. */
  25602. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25603. /**
  25604. * Defines that both eyes of the camera will be rendered over under each other.
  25605. */
  25606. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25607. /**
  25608. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25609. */
  25610. static readonly RIG_MODE_VR: number;
  25611. /**
  25612. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25613. */
  25614. static readonly RIG_MODE_WEBVR: number;
  25615. /**
  25616. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25617. */
  25618. static readonly RIG_MODE_CUSTOM: number;
  25619. /**
  25620. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25621. */
  25622. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25623. /**
  25624. * Define the input manager associated with the camera.
  25625. */
  25626. inputs: CameraInputsManager<Camera>;
  25627. /** @hidden */
  25628. _position: Vector3;
  25629. /**
  25630. * Define the current local position of the camera in the scene
  25631. */
  25632. position: Vector3;
  25633. /**
  25634. * The vector the camera should consider as up.
  25635. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25636. */
  25637. upVector: Vector3;
  25638. /**
  25639. * Define the current limit on the left side for an orthographic camera
  25640. * In scene unit
  25641. */
  25642. orthoLeft: Nullable<number>;
  25643. /**
  25644. * Define the current limit on the right side for an orthographic camera
  25645. * In scene unit
  25646. */
  25647. orthoRight: Nullable<number>;
  25648. /**
  25649. * Define the current limit on the bottom side for an orthographic camera
  25650. * In scene unit
  25651. */
  25652. orthoBottom: Nullable<number>;
  25653. /**
  25654. * Define the current limit on the top side for an orthographic camera
  25655. * In scene unit
  25656. */
  25657. orthoTop: Nullable<number>;
  25658. /**
  25659. * Field Of View is set in Radians. (default is 0.8)
  25660. */
  25661. fov: number;
  25662. /**
  25663. * Define the minimum distance the camera can see from.
  25664. * This is important to note that the depth buffer are not infinite and the closer it starts
  25665. * the more your scene might encounter depth fighting issue.
  25666. */
  25667. minZ: number;
  25668. /**
  25669. * Define the maximum distance the camera can see to.
  25670. * This is important to note that the depth buffer are not infinite and the further it end
  25671. * the more your scene might encounter depth fighting issue.
  25672. */
  25673. maxZ: number;
  25674. /**
  25675. * Define the default inertia of the camera.
  25676. * This helps giving a smooth feeling to the camera movement.
  25677. */
  25678. inertia: number;
  25679. /**
  25680. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25681. */
  25682. mode: number;
  25683. /**
  25684. * Define wether the camera is intermediate.
  25685. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25686. */
  25687. isIntermediate: boolean;
  25688. /**
  25689. * Define the viewport of the camera.
  25690. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25691. */
  25692. viewport: Viewport;
  25693. /**
  25694. * Restricts the camera to viewing objects with the same layerMask.
  25695. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25696. */
  25697. layerMask: number;
  25698. /**
  25699. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25700. */
  25701. fovMode: number;
  25702. /**
  25703. * Rig mode of the camera.
  25704. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25705. * This is normally controlled byt the camera themselves as internal use.
  25706. */
  25707. cameraRigMode: number;
  25708. /**
  25709. * Defines the distance between both "eyes" in case of a RIG
  25710. */
  25711. interaxialDistance: number;
  25712. /**
  25713. * Defines if stereoscopic rendering is done side by side or over under.
  25714. */
  25715. isStereoscopicSideBySide: boolean;
  25716. /**
  25717. * 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
  25718. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25719. * else in the scene. (Eg. security camera)
  25720. *
  25721. * 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)
  25722. */
  25723. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25724. /**
  25725. * When set, the camera will render to this render target instead of the default canvas
  25726. *
  25727. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25728. */
  25729. outputRenderTarget: Nullable<RenderTargetTexture>;
  25730. /**
  25731. * Observable triggered when the camera view matrix has changed.
  25732. */
  25733. onViewMatrixChangedObservable: Observable<Camera>;
  25734. /**
  25735. * Observable triggered when the camera Projection matrix has changed.
  25736. */
  25737. onProjectionMatrixChangedObservable: Observable<Camera>;
  25738. /**
  25739. * Observable triggered when the inputs have been processed.
  25740. */
  25741. onAfterCheckInputsObservable: Observable<Camera>;
  25742. /**
  25743. * Observable triggered when reset has been called and applied to the camera.
  25744. */
  25745. onRestoreStateObservable: Observable<Camera>;
  25746. /** @hidden */
  25747. _cameraRigParams: any;
  25748. /** @hidden */
  25749. _rigCameras: Camera[];
  25750. /** @hidden */
  25751. _rigPostProcess: Nullable<PostProcess>;
  25752. protected _webvrViewMatrix: Matrix;
  25753. /** @hidden */
  25754. _skipRendering: boolean;
  25755. /** @hidden */
  25756. _projectionMatrix: Matrix;
  25757. /** @hidden */
  25758. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25759. /** @hidden */
  25760. _activeMeshes: SmartArray<AbstractMesh>;
  25761. protected _globalPosition: Vector3;
  25762. /** @hidden */
  25763. _computedViewMatrix: Matrix;
  25764. private _doNotComputeProjectionMatrix;
  25765. private _transformMatrix;
  25766. private _frustumPlanes;
  25767. private _refreshFrustumPlanes;
  25768. private _storedFov;
  25769. private _stateStored;
  25770. /**
  25771. * Instantiates a new camera object.
  25772. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25773. * @see http://doc.babylonjs.com/features/cameras
  25774. * @param name Defines the name of the camera in the scene
  25775. * @param position Defines the position of the camera
  25776. * @param scene Defines the scene the camera belongs too
  25777. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25778. */
  25779. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25780. /**
  25781. * Store current camera state (fov, position, etc..)
  25782. * @returns the camera
  25783. */
  25784. storeState(): Camera;
  25785. /**
  25786. * Restores the camera state values if it has been stored. You must call storeState() first
  25787. */
  25788. protected _restoreStateValues(): boolean;
  25789. /**
  25790. * Restored camera state. You must call storeState() first.
  25791. * @returns true if restored and false otherwise
  25792. */
  25793. restoreState(): boolean;
  25794. /**
  25795. * Gets the class name of the camera.
  25796. * @returns the class name
  25797. */
  25798. getClassName(): string;
  25799. /** @hidden */
  25800. readonly _isCamera: boolean;
  25801. /**
  25802. * Gets a string representation of the camera useful for debug purpose.
  25803. * @param fullDetails Defines that a more verboe level of logging is required
  25804. * @returns the string representation
  25805. */
  25806. toString(fullDetails?: boolean): string;
  25807. /**
  25808. * Gets the current world space position of the camera.
  25809. */
  25810. readonly globalPosition: Vector3;
  25811. /**
  25812. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25813. * @returns the active meshe list
  25814. */
  25815. getActiveMeshes(): SmartArray<AbstractMesh>;
  25816. /**
  25817. * Check wether a mesh is part of the current active mesh list of the camera
  25818. * @param mesh Defines the mesh to check
  25819. * @returns true if active, false otherwise
  25820. */
  25821. isActiveMesh(mesh: Mesh): boolean;
  25822. /**
  25823. * Is this camera ready to be used/rendered
  25824. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25825. * @return true if the camera is ready
  25826. */
  25827. isReady(completeCheck?: boolean): boolean;
  25828. /** @hidden */
  25829. _initCache(): void;
  25830. /** @hidden */
  25831. _updateCache(ignoreParentClass?: boolean): void;
  25832. /** @hidden */
  25833. _isSynchronized(): boolean;
  25834. /** @hidden */
  25835. _isSynchronizedViewMatrix(): boolean;
  25836. /** @hidden */
  25837. _isSynchronizedProjectionMatrix(): boolean;
  25838. /**
  25839. * Attach the input controls to a specific dom element to get the input from.
  25840. * @param element Defines the element the controls should be listened from
  25841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25842. */
  25843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25844. /**
  25845. * Detach the current controls from the specified dom element.
  25846. * @param element Defines the element to stop listening the inputs from
  25847. */
  25848. detachControl(element: HTMLElement): void;
  25849. /**
  25850. * Update the camera state according to the different inputs gathered during the frame.
  25851. */
  25852. update(): void;
  25853. /** @hidden */
  25854. _checkInputs(): void;
  25855. /** @hidden */
  25856. readonly rigCameras: Camera[];
  25857. /**
  25858. * Gets the post process used by the rig cameras
  25859. */
  25860. readonly rigPostProcess: Nullable<PostProcess>;
  25861. /**
  25862. * Internal, gets the first post proces.
  25863. * @returns the first post process to be run on this camera.
  25864. */
  25865. _getFirstPostProcess(): Nullable<PostProcess>;
  25866. private _cascadePostProcessesToRigCams;
  25867. /**
  25868. * Attach a post process to the camera.
  25869. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25870. * @param postProcess The post process to attach to the camera
  25871. * @param insertAt The position of the post process in case several of them are in use in the scene
  25872. * @returns the position the post process has been inserted at
  25873. */
  25874. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25875. /**
  25876. * Detach a post process to the camera.
  25877. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25878. * @param postProcess The post process to detach from the camera
  25879. */
  25880. detachPostProcess(postProcess: PostProcess): void;
  25881. /**
  25882. * Gets the current world matrix of the camera
  25883. */
  25884. getWorldMatrix(): Matrix;
  25885. /** @hidden */
  25886. _getViewMatrix(): Matrix;
  25887. /**
  25888. * Gets the current view matrix of the camera.
  25889. * @param force forces the camera to recompute the matrix without looking at the cached state
  25890. * @returns the view matrix
  25891. */
  25892. getViewMatrix(force?: boolean): Matrix;
  25893. /**
  25894. * Freeze the projection matrix.
  25895. * It will prevent the cache check of the camera projection compute and can speed up perf
  25896. * if no parameter of the camera are meant to change
  25897. * @param projection Defines manually a projection if necessary
  25898. */
  25899. freezeProjectionMatrix(projection?: Matrix): void;
  25900. /**
  25901. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25902. */
  25903. unfreezeProjectionMatrix(): void;
  25904. /**
  25905. * Gets the current projection matrix of the camera.
  25906. * @param force forces the camera to recompute the matrix without looking at the cached state
  25907. * @returns the projection matrix
  25908. */
  25909. getProjectionMatrix(force?: boolean): Matrix;
  25910. /**
  25911. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25912. * @returns a Matrix
  25913. */
  25914. getTransformationMatrix(): Matrix;
  25915. private _updateFrustumPlanes;
  25916. /**
  25917. * Checks if a cullable object (mesh...) is in the camera frustum
  25918. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25919. * @param target The object to check
  25920. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25921. * @returns true if the object is in frustum otherwise false
  25922. */
  25923. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25924. /**
  25925. * Checks if a cullable object (mesh...) is in the camera frustum
  25926. * Unlike isInFrustum this cheks the full bounding box
  25927. * @param target The object to check
  25928. * @returns true if the object is in frustum otherwise false
  25929. */
  25930. isCompletelyInFrustum(target: ICullable): boolean;
  25931. /**
  25932. * Gets a ray in the forward direction from the camera.
  25933. * @param length Defines the length of the ray to create
  25934. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25935. * @param origin Defines the start point of the ray which defaults to the camera position
  25936. * @returns the forward ray
  25937. */
  25938. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25939. /**
  25940. * Releases resources associated with this node.
  25941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25943. */
  25944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25945. /** @hidden */
  25946. _isLeftCamera: boolean;
  25947. /**
  25948. * Gets the left camera of a rig setup in case of Rigged Camera
  25949. */
  25950. readonly isLeftCamera: boolean;
  25951. /** @hidden */
  25952. _isRightCamera: boolean;
  25953. /**
  25954. * Gets the right camera of a rig setup in case of Rigged Camera
  25955. */
  25956. readonly isRightCamera: boolean;
  25957. /**
  25958. * Gets the left camera of a rig setup in case of Rigged Camera
  25959. */
  25960. readonly leftCamera: Nullable<FreeCamera>;
  25961. /**
  25962. * Gets the right camera of a rig setup in case of Rigged Camera
  25963. */
  25964. readonly rightCamera: Nullable<FreeCamera>;
  25965. /**
  25966. * Gets the left camera target of a rig setup in case of Rigged Camera
  25967. * @returns the target position
  25968. */
  25969. getLeftTarget(): Nullable<Vector3>;
  25970. /**
  25971. * Gets the right camera target of a rig setup in case of Rigged Camera
  25972. * @returns the target position
  25973. */
  25974. getRightTarget(): Nullable<Vector3>;
  25975. /**
  25976. * @hidden
  25977. */
  25978. setCameraRigMode(mode: number, rigParams: any): void;
  25979. /** @hidden */
  25980. static _setStereoscopicRigMode(camera: Camera): void;
  25981. /** @hidden */
  25982. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25983. /** @hidden */
  25984. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25985. /** @hidden */
  25986. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25987. /** @hidden */
  25988. _getVRProjectionMatrix(): Matrix;
  25989. protected _updateCameraRotationMatrix(): void;
  25990. protected _updateWebVRCameraRotationMatrix(): void;
  25991. /**
  25992. * This function MUST be overwritten by the different WebVR cameras available.
  25993. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25994. * @hidden
  25995. */
  25996. _getWebVRProjectionMatrix(): Matrix;
  25997. /**
  25998. * This function MUST be overwritten by the different WebVR cameras available.
  25999. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26000. * @hidden
  26001. */
  26002. _getWebVRViewMatrix(): Matrix;
  26003. /** @hidden */
  26004. setCameraRigParameter(name: string, value: any): void;
  26005. /**
  26006. * needs to be overridden by children so sub has required properties to be copied
  26007. * @hidden
  26008. */
  26009. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26010. /**
  26011. * May need to be overridden by children
  26012. * @hidden
  26013. */
  26014. _updateRigCameras(): void;
  26015. /** @hidden */
  26016. _setupInputs(): void;
  26017. /**
  26018. * Serialiaze the camera setup to a json represention
  26019. * @returns the JSON representation
  26020. */
  26021. serialize(): any;
  26022. /**
  26023. * Clones the current camera.
  26024. * @param name The cloned camera name
  26025. * @returns the cloned camera
  26026. */
  26027. clone(name: string): Camera;
  26028. /**
  26029. * Gets the direction of the camera relative to a given local axis.
  26030. * @param localAxis Defines the reference axis to provide a relative direction.
  26031. * @return the direction
  26032. */
  26033. getDirection(localAxis: Vector3): Vector3;
  26034. /**
  26035. * Returns the current camera absolute rotation
  26036. */
  26037. readonly absoluteRotation: Quaternion;
  26038. /**
  26039. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26040. * @param localAxis Defines the reference axis to provide a relative direction.
  26041. * @param result Defines the vector to store the result in
  26042. */
  26043. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26044. /**
  26045. * Gets a camera constructor for a given camera type
  26046. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26047. * @param name The name of the camera the result will be able to instantiate
  26048. * @param scene The scene the result will construct the camera in
  26049. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26050. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26051. * @returns a factory method to construc the camera
  26052. */
  26053. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26054. /**
  26055. * Compute the world matrix of the camera.
  26056. * @returns the camera world matrix
  26057. */
  26058. computeWorldMatrix(): Matrix;
  26059. /**
  26060. * Parse a JSON and creates the camera from the parsed information
  26061. * @param parsedCamera The JSON to parse
  26062. * @param scene The scene to instantiate the camera in
  26063. * @returns the newly constructed camera
  26064. */
  26065. static Parse(parsedCamera: any, scene: Scene): Camera;
  26066. }
  26067. }
  26068. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26069. import { Nullable } from "babylonjs/types";
  26070. import { Scene } from "babylonjs/scene";
  26071. import { Vector4 } from "babylonjs/Maths/math.vector";
  26072. import { Mesh } from "babylonjs/Meshes/mesh";
  26073. /**
  26074. * Class containing static functions to help procedurally build meshes
  26075. */
  26076. export class DiscBuilder {
  26077. /**
  26078. * Creates a plane polygonal mesh. By default, this is a disc
  26079. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26080. * * 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
  26081. * * 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
  26082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26085. * @param name defines the name of the mesh
  26086. * @param options defines the options used to create the mesh
  26087. * @param scene defines the hosting scene
  26088. * @returns the plane polygonal mesh
  26089. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26090. */
  26091. static CreateDisc(name: string, options: {
  26092. radius?: number;
  26093. tessellation?: number;
  26094. arc?: number;
  26095. updatable?: boolean;
  26096. sideOrientation?: number;
  26097. frontUVs?: Vector4;
  26098. backUVs?: Vector4;
  26099. }, scene?: Nullable<Scene>): Mesh;
  26100. }
  26101. }
  26102. declare module "babylonjs/Particles/solidParticleSystem" {
  26103. import { Nullable } from "babylonjs/types";
  26104. import { Vector3 } from "babylonjs/Maths/math.vector";
  26105. import { Mesh } from "babylonjs/Meshes/mesh";
  26106. import { Scene, IDisposable } from "babylonjs/scene";
  26107. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26108. /**
  26109. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26110. *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.
  26111. * The SPS is also a particle system. It provides some methods to manage the particles.
  26112. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26113. *
  26114. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26115. */
  26116. export class SolidParticleSystem implements IDisposable {
  26117. /**
  26118. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26119. * Example : var p = SPS.particles[i];
  26120. */
  26121. particles: SolidParticle[];
  26122. /**
  26123. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26124. */
  26125. nbParticles: number;
  26126. /**
  26127. * If the particles must ever face the camera (default false). Useful for planar particles.
  26128. */
  26129. billboard: boolean;
  26130. /**
  26131. * Recompute normals when adding a shape
  26132. */
  26133. recomputeNormals: boolean;
  26134. /**
  26135. * This a counter ofr your own usage. It's not set by any SPS functions.
  26136. */
  26137. counter: number;
  26138. /**
  26139. * The SPS name. This name is also given to the underlying mesh.
  26140. */
  26141. name: string;
  26142. /**
  26143. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26144. */
  26145. mesh: Mesh;
  26146. /**
  26147. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26148. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26149. */
  26150. vars: any;
  26151. /**
  26152. * This array is populated when the SPS is set as 'pickable'.
  26153. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26154. * Each element of this array is an object `{idx: int, faceId: int}`.
  26155. * `idx` is the picked particle index in the `SPS.particles` array
  26156. * `faceId` is the picked face index counted within this particle.
  26157. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26158. */
  26159. pickedParticles: {
  26160. idx: number;
  26161. faceId: number;
  26162. }[];
  26163. /**
  26164. * This array is populated when `enableDepthSort` is set to true.
  26165. * Each element of this array is an instance of the class DepthSortedParticle.
  26166. */
  26167. depthSortedParticles: DepthSortedParticle[];
  26168. /**
  26169. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26170. * @hidden
  26171. */
  26172. _bSphereOnly: boolean;
  26173. /**
  26174. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26175. * @hidden
  26176. */
  26177. _bSphereRadiusFactor: number;
  26178. private _scene;
  26179. private _positions;
  26180. private _indices;
  26181. private _normals;
  26182. private _colors;
  26183. private _uvs;
  26184. private _indices32;
  26185. private _positions32;
  26186. private _normals32;
  26187. private _fixedNormal32;
  26188. private _colors32;
  26189. private _uvs32;
  26190. private _index;
  26191. private _updatable;
  26192. private _pickable;
  26193. private _isVisibilityBoxLocked;
  26194. private _alwaysVisible;
  26195. private _depthSort;
  26196. private _expandable;
  26197. private _shapeCounter;
  26198. private _copy;
  26199. private _color;
  26200. private _computeParticleColor;
  26201. private _computeParticleTexture;
  26202. private _computeParticleRotation;
  26203. private _computeParticleVertex;
  26204. private _computeBoundingBox;
  26205. private _depthSortParticles;
  26206. private _camera;
  26207. private _mustUnrotateFixedNormals;
  26208. private _particlesIntersect;
  26209. private _needs32Bits;
  26210. private _isNotBuilt;
  26211. private _lastParticleId;
  26212. private _idxOfId;
  26213. /**
  26214. * Creates a SPS (Solid Particle System) object.
  26215. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26216. * @param scene (Scene) is the scene in which the SPS is added.
  26217. * @param options defines the options of the sps e.g.
  26218. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26219. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26220. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26221. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26222. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26223. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26224. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26225. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26226. */
  26227. constructor(name: string, scene: Scene, options?: {
  26228. updatable?: boolean;
  26229. isPickable?: boolean;
  26230. enableDepthSort?: boolean;
  26231. particleIntersection?: boolean;
  26232. boundingSphereOnly?: boolean;
  26233. bSphereRadiusFactor?: number;
  26234. expandable?: boolean;
  26235. });
  26236. /**
  26237. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26238. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26239. * @returns the created mesh
  26240. */
  26241. buildMesh(): Mesh;
  26242. /**
  26243. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26244. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26245. * Thus the particles generated from `digest()` have their property `position` set yet.
  26246. * @param mesh ( Mesh ) is the mesh to be digested
  26247. * @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
  26248. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26249. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26250. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26251. * @returns the current SPS
  26252. */
  26253. digest(mesh: Mesh, options?: {
  26254. facetNb?: number;
  26255. number?: number;
  26256. delta?: number;
  26257. storage?: [];
  26258. }): SolidParticleSystem;
  26259. /**
  26260. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26261. * @hidden
  26262. */
  26263. private _unrotateFixedNormals;
  26264. /**
  26265. * Resets the temporary working copy particle
  26266. * @hidden
  26267. */
  26268. private _resetCopy;
  26269. /**
  26270. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26271. * @param p the current index in the positions array to be updated
  26272. * @param shape a Vector3 array, the shape geometry
  26273. * @param positions the positions array to be updated
  26274. * @param meshInd the shape indices array
  26275. * @param indices the indices array to be updated
  26276. * @param meshUV the shape uv array
  26277. * @param uvs the uv array to be updated
  26278. * @param meshCol the shape color array
  26279. * @param colors the color array to be updated
  26280. * @param meshNor the shape normals array
  26281. * @param normals the normals array to be updated
  26282. * @param idx the particle index
  26283. * @param idxInShape the particle index in its shape
  26284. * @param options the addShape() method passed options
  26285. * @hidden
  26286. */
  26287. private _meshBuilder;
  26288. /**
  26289. * Returns a shape Vector3 array from positions float array
  26290. * @param positions float array
  26291. * @returns a vector3 array
  26292. * @hidden
  26293. */
  26294. private _posToShape;
  26295. /**
  26296. * Returns a shapeUV array from a float uvs (array deep copy)
  26297. * @param uvs as a float array
  26298. * @returns a shapeUV array
  26299. * @hidden
  26300. */
  26301. private _uvsToShapeUV;
  26302. /**
  26303. * Adds a new particle object in the particles array
  26304. * @param idx particle index in particles array
  26305. * @param id particle id
  26306. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26307. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26308. * @param model particle ModelShape object
  26309. * @param shapeId model shape identifier
  26310. * @param idxInShape index of the particle in the current model
  26311. * @param bInfo model bounding info object
  26312. * @param storage target storage array, if any
  26313. * @hidden
  26314. */
  26315. private _addParticle;
  26316. /**
  26317. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26318. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26319. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26320. * @param nb (positive integer) the number of particles to be created from this model
  26321. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26322. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26323. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26324. * @returns the number of shapes in the system
  26325. */
  26326. addShape(mesh: Mesh, nb: number, options?: {
  26327. positionFunction?: any;
  26328. vertexFunction?: any;
  26329. storage?: [];
  26330. }): number;
  26331. /**
  26332. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26333. * @hidden
  26334. */
  26335. private _rebuildParticle;
  26336. /**
  26337. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26338. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26339. * @returns the SPS.
  26340. */
  26341. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26342. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26343. * Returns an array with the removed particles.
  26344. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26345. * The SPS can't be empty so at least one particle needs to remain in place.
  26346. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26347. * @param start index of the first particle to remove
  26348. * @param end index of the last particle to remove (included)
  26349. * @returns an array populated with the removed particles
  26350. */
  26351. removeParticles(start: number, end: number): SolidParticle[];
  26352. /**
  26353. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26354. * @param solidParticleArray an array populated with Solid Particles objects
  26355. * @returns the SPS
  26356. */
  26357. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26358. /**
  26359. * Creates a new particle and modifies the SPS mesh geometry :
  26360. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26361. * - calls _addParticle() to populate the particle array
  26362. * factorized code from addShape() and insertParticlesFromArray()
  26363. * @param idx particle index in the particles array
  26364. * @param i particle index in its shape
  26365. * @param modelShape particle ModelShape object
  26366. * @param shape shape vertex array
  26367. * @param meshInd shape indices array
  26368. * @param meshUV shape uv array
  26369. * @param meshCol shape color array
  26370. * @param meshNor shape normals array
  26371. * @param bbInfo shape bounding info
  26372. * @param storage target particle storage
  26373. * @options addShape() passed options
  26374. * @hidden
  26375. */
  26376. private _insertNewParticle;
  26377. /**
  26378. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26379. * This method calls `updateParticle()` for each particle of the SPS.
  26380. * For an animated SPS, it is usually called within the render loop.
  26381. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26382. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26383. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26384. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26385. * @returns the SPS.
  26386. */
  26387. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26388. /**
  26389. * Disposes the SPS.
  26390. */
  26391. dispose(): void;
  26392. /**
  26393. * Returns a SolidParticle object from its identifier : particle.id
  26394. * @param id (integer) the particle Id
  26395. * @returns the searched particle or null if not found in the SPS.
  26396. */
  26397. getParticleById(id: number): Nullable<SolidParticle>;
  26398. /**
  26399. * Returns a new array populated with the particles having the passed shapeId.
  26400. * @param shapeId (integer) the shape identifier
  26401. * @returns a new solid particle array
  26402. */
  26403. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26404. /**
  26405. * Populates the passed array "ref" with the particles having the passed shapeId.
  26406. * @param shapeId the shape identifier
  26407. * @returns the SPS
  26408. * @param ref
  26409. */
  26410. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26411. /**
  26412. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26413. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26414. * @returns the SPS.
  26415. */
  26416. refreshVisibleSize(): SolidParticleSystem;
  26417. /**
  26418. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26419. * @param size the size (float) of the visibility box
  26420. * note : this doesn't lock the SPS mesh bounding box.
  26421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26422. */
  26423. setVisibilityBox(size: number): void;
  26424. /**
  26425. * Gets whether the SPS as always visible or not
  26426. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26427. */
  26428. /**
  26429. * Sets the SPS as always visible or not
  26430. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26431. */
  26432. isAlwaysVisible: boolean;
  26433. /**
  26434. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26435. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26436. */
  26437. /**
  26438. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26439. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26440. */
  26441. isVisibilityBoxLocked: boolean;
  26442. /**
  26443. * Tells to `setParticles()` to compute the particle rotations or not.
  26444. * Default value : true. The SPS is faster when it's set to false.
  26445. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26446. */
  26447. /**
  26448. * Gets if `setParticles()` computes the particle rotations or not.
  26449. * Default value : true. The SPS is faster when it's set to false.
  26450. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26451. */
  26452. computeParticleRotation: boolean;
  26453. /**
  26454. * Tells to `setParticles()` to compute the particle colors or not.
  26455. * Default value : true. The SPS is faster when it's set to false.
  26456. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26457. */
  26458. /**
  26459. * Gets if `setParticles()` computes the particle colors or not.
  26460. * Default value : true. The SPS is faster when it's set to false.
  26461. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26462. */
  26463. computeParticleColor: boolean;
  26464. /**
  26465. * Gets if `setParticles()` computes the particle textures or not.
  26466. * Default value : true. The SPS is faster when it's set to false.
  26467. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26468. */
  26469. computeParticleTexture: boolean;
  26470. /**
  26471. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26472. * Default value : false. The SPS is faster when it's set to false.
  26473. * Note : the particle custom vertex positions aren't stored values.
  26474. */
  26475. /**
  26476. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26477. * Default value : false. The SPS is faster when it's set to false.
  26478. * Note : the particle custom vertex positions aren't stored values.
  26479. */
  26480. computeParticleVertex: boolean;
  26481. /**
  26482. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26483. */
  26484. /**
  26485. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26486. */
  26487. computeBoundingBox: boolean;
  26488. /**
  26489. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26490. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26491. * Default : `true`
  26492. */
  26493. /**
  26494. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26495. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26496. * Default : `true`
  26497. */
  26498. depthSortParticles: boolean;
  26499. /**
  26500. * Gets if the SPS is created as expandable at construction time.
  26501. * Default : `false`
  26502. */
  26503. readonly expandable: boolean;
  26504. /**
  26505. * This function does nothing. It may be overwritten to set all the particle first values.
  26506. * The SPS doesn't call this function, you may have to call it by your own.
  26507. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26508. */
  26509. initParticles(): void;
  26510. /**
  26511. * This function does nothing. It may be overwritten to recycle a particle.
  26512. * The SPS doesn't call this function, you may have to call it by your own.
  26513. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26514. * @param particle The particle to recycle
  26515. * @returns the recycled particle
  26516. */
  26517. recycleParticle(particle: SolidParticle): SolidParticle;
  26518. /**
  26519. * Updates a particle : this function should be overwritten by the user.
  26520. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26521. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26522. * @example : just set a particle position or velocity and recycle conditions
  26523. * @param particle The particle to update
  26524. * @returns the updated particle
  26525. */
  26526. updateParticle(particle: SolidParticle): SolidParticle;
  26527. /**
  26528. * Updates a vertex of a particle : it can be overwritten by the user.
  26529. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26530. * @param particle the current particle
  26531. * @param vertex the current index of the current particle
  26532. * @param pt the index of the current vertex in the particle shape
  26533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26534. * @example : just set a vertex particle position
  26535. * @returns the updated vertex
  26536. */
  26537. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26538. /**
  26539. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26540. * This does nothing and may be overwritten by the user.
  26541. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26542. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26543. * @param update the boolean update value actually passed to setParticles()
  26544. */
  26545. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26546. /**
  26547. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26548. * This will be passed three parameters.
  26549. * This does nothing and may be overwritten by the user.
  26550. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26551. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26552. * @param update the boolean update value actually passed to setParticles()
  26553. */
  26554. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26555. }
  26556. }
  26557. declare module "babylonjs/Particles/solidParticle" {
  26558. import { Nullable } from "babylonjs/types";
  26559. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26560. import { Color4 } from "babylonjs/Maths/math.color";
  26561. import { Mesh } from "babylonjs/Meshes/mesh";
  26562. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26563. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26564. import { Plane } from "babylonjs/Maths/math.plane";
  26565. /**
  26566. * Represents one particle of a solid particle system.
  26567. */
  26568. export class SolidParticle {
  26569. /**
  26570. * particle global index
  26571. */
  26572. idx: number;
  26573. /**
  26574. * particle identifier
  26575. */
  26576. id: number;
  26577. /**
  26578. * The color of the particle
  26579. */
  26580. color: Nullable<Color4>;
  26581. /**
  26582. * The world space position of the particle.
  26583. */
  26584. position: Vector3;
  26585. /**
  26586. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26587. */
  26588. rotation: Vector3;
  26589. /**
  26590. * The world space rotation quaternion of the particle.
  26591. */
  26592. rotationQuaternion: Nullable<Quaternion>;
  26593. /**
  26594. * The scaling of the particle.
  26595. */
  26596. scaling: Vector3;
  26597. /**
  26598. * The uvs of the particle.
  26599. */
  26600. uvs: Vector4;
  26601. /**
  26602. * The current speed of the particle.
  26603. */
  26604. velocity: Vector3;
  26605. /**
  26606. * The pivot point in the particle local space.
  26607. */
  26608. pivot: Vector3;
  26609. /**
  26610. * Must the particle be translated from its pivot point in its local space ?
  26611. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26612. * Default : false
  26613. */
  26614. translateFromPivot: boolean;
  26615. /**
  26616. * Is the particle active or not ?
  26617. */
  26618. alive: boolean;
  26619. /**
  26620. * Is the particle visible or not ?
  26621. */
  26622. isVisible: boolean;
  26623. /**
  26624. * Index of this particle in the global "positions" array (Internal use)
  26625. * @hidden
  26626. */
  26627. _pos: number;
  26628. /**
  26629. * @hidden Index of this particle in the global "indices" array (Internal use)
  26630. */
  26631. _ind: number;
  26632. /**
  26633. * @hidden ModelShape of this particle (Internal use)
  26634. */
  26635. _model: ModelShape;
  26636. /**
  26637. * ModelShape id of this particle
  26638. */
  26639. shapeId: number;
  26640. /**
  26641. * Index of the particle in its shape id
  26642. */
  26643. idxInShape: number;
  26644. /**
  26645. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26646. */
  26647. _modelBoundingInfo: BoundingInfo;
  26648. /**
  26649. * @hidden Particle BoundingInfo object (Internal use)
  26650. */
  26651. _boundingInfo: BoundingInfo;
  26652. /**
  26653. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26654. */
  26655. _sps: SolidParticleSystem;
  26656. /**
  26657. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26658. */
  26659. _stillInvisible: boolean;
  26660. /**
  26661. * @hidden Last computed particle rotation matrix
  26662. */
  26663. _rotationMatrix: number[];
  26664. /**
  26665. * Parent particle Id, if any.
  26666. * Default null.
  26667. */
  26668. parentId: Nullable<number>;
  26669. /**
  26670. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26671. * The possible values are :
  26672. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26673. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26674. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26675. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26676. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26677. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26678. * */
  26679. cullingStrategy: number;
  26680. /**
  26681. * @hidden Internal global position in the SPS.
  26682. */
  26683. _globalPosition: Vector3;
  26684. /**
  26685. * Creates a Solid Particle object.
  26686. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26687. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26688. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26689. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26690. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26691. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26692. * @param shapeId (integer) is the model shape identifier in the SPS.
  26693. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26694. * @param sps defines the sps it is associated to
  26695. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26696. */
  26697. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26698. /**
  26699. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26700. * @param target the particle target
  26701. * @returns the current particle
  26702. */
  26703. copyToRef(target: SolidParticle): SolidParticle;
  26704. /**
  26705. * Legacy support, changed scale to scaling
  26706. */
  26707. /**
  26708. * Legacy support, changed scale to scaling
  26709. */
  26710. scale: Vector3;
  26711. /**
  26712. * Legacy support, changed quaternion to rotationQuaternion
  26713. */
  26714. /**
  26715. * Legacy support, changed quaternion to rotationQuaternion
  26716. */
  26717. quaternion: Nullable<Quaternion>;
  26718. /**
  26719. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26720. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26721. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26722. * @returns true if it intersects
  26723. */
  26724. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26725. /**
  26726. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26727. * A particle is in the frustum if its bounding box intersects the frustum
  26728. * @param frustumPlanes defines the frustum to test
  26729. * @returns true if the particle is in the frustum planes
  26730. */
  26731. isInFrustum(frustumPlanes: Plane[]): boolean;
  26732. /**
  26733. * get the rotation matrix of the particle
  26734. * @hidden
  26735. */
  26736. getRotationMatrix(m: Matrix): void;
  26737. }
  26738. /**
  26739. * Represents the shape of the model used by one particle of a solid particle system.
  26740. * SPS internal tool, don't use it manually.
  26741. */
  26742. export class ModelShape {
  26743. /**
  26744. * The shape id
  26745. * @hidden
  26746. */
  26747. shapeID: number;
  26748. /**
  26749. * flat array of model positions (internal use)
  26750. * @hidden
  26751. */
  26752. _shape: Vector3[];
  26753. /**
  26754. * flat array of model UVs (internal use)
  26755. * @hidden
  26756. */
  26757. _shapeUV: number[];
  26758. /**
  26759. * color array of the model
  26760. * @hidden
  26761. */
  26762. _shapeColors: number[];
  26763. /**
  26764. * indices array of the model
  26765. * @hidden
  26766. */
  26767. _indices: number[];
  26768. /**
  26769. * normals array of the model
  26770. * @hidden
  26771. */
  26772. _normals: number[];
  26773. /**
  26774. * length of the shape in the model indices array (internal use)
  26775. * @hidden
  26776. */
  26777. _indicesLength: number;
  26778. /**
  26779. * Custom position function (internal use)
  26780. * @hidden
  26781. */
  26782. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26783. /**
  26784. * Custom vertex function (internal use)
  26785. * @hidden
  26786. */
  26787. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26788. /**
  26789. * 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.
  26790. * SPS internal tool, don't use it manually.
  26791. * @hidden
  26792. */
  26793. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26794. }
  26795. /**
  26796. * Represents a Depth Sorted Particle in the solid particle system.
  26797. */
  26798. export class DepthSortedParticle {
  26799. /**
  26800. * Index of the particle in the "indices" array
  26801. */
  26802. ind: number;
  26803. /**
  26804. * Length of the particle shape in the "indices" array
  26805. */
  26806. indicesLength: number;
  26807. /**
  26808. * Squared distance from the particle to the camera
  26809. */
  26810. sqDistance: number;
  26811. }
  26812. }
  26813. declare module "babylonjs/Collisions/meshCollisionData" {
  26814. import { Collider } from "babylonjs/Collisions/collider";
  26815. import { Vector3 } from "babylonjs/Maths/math.vector";
  26816. import { Nullable } from "babylonjs/types";
  26817. import { Observer } from "babylonjs/Misc/observable";
  26818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26819. /**
  26820. * @hidden
  26821. */
  26822. export class _MeshCollisionData {
  26823. _checkCollisions: boolean;
  26824. _collisionMask: number;
  26825. _collisionGroup: number;
  26826. _collider: Nullable<Collider>;
  26827. _oldPositionForCollisions: Vector3;
  26828. _diffPositionForCollisions: Vector3;
  26829. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26830. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26831. }
  26832. }
  26833. declare module "babylonjs/Meshes/abstractMesh" {
  26834. import { Observable } from "babylonjs/Misc/observable";
  26835. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26836. import { Camera } from "babylonjs/Cameras/camera";
  26837. import { Scene, IDisposable } from "babylonjs/scene";
  26838. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26839. import { Node } from "babylonjs/node";
  26840. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26841. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26843. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26844. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26845. import { Material } from "babylonjs/Materials/material";
  26846. import { Light } from "babylonjs/Lights/light";
  26847. import { Skeleton } from "babylonjs/Bones/skeleton";
  26848. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26849. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26850. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26851. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26852. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26853. import { Plane } from "babylonjs/Maths/math.plane";
  26854. import { Ray } from "babylonjs/Culling/ray";
  26855. import { Collider } from "babylonjs/Collisions/collider";
  26856. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26857. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26858. /** @hidden */
  26859. class _FacetDataStorage {
  26860. facetPositions: Vector3[];
  26861. facetNormals: Vector3[];
  26862. facetPartitioning: number[][];
  26863. facetNb: number;
  26864. partitioningSubdivisions: number;
  26865. partitioningBBoxRatio: number;
  26866. facetDataEnabled: boolean;
  26867. facetParameters: any;
  26868. bbSize: Vector3;
  26869. subDiv: {
  26870. max: number;
  26871. X: number;
  26872. Y: number;
  26873. Z: number;
  26874. };
  26875. facetDepthSort: boolean;
  26876. facetDepthSortEnabled: boolean;
  26877. depthSortedIndices: IndicesArray;
  26878. depthSortedFacets: {
  26879. ind: number;
  26880. sqDistance: number;
  26881. }[];
  26882. facetDepthSortFunction: (f1: {
  26883. ind: number;
  26884. sqDistance: number;
  26885. }, f2: {
  26886. ind: number;
  26887. sqDistance: number;
  26888. }) => number;
  26889. facetDepthSortFrom: Vector3;
  26890. facetDepthSortOrigin: Vector3;
  26891. invertedMatrix: Matrix;
  26892. }
  26893. /**
  26894. * @hidden
  26895. **/
  26896. class _InternalAbstractMeshDataInfo {
  26897. _hasVertexAlpha: boolean;
  26898. _useVertexColors: boolean;
  26899. _numBoneInfluencers: number;
  26900. _applyFog: boolean;
  26901. _receiveShadows: boolean;
  26902. _facetData: _FacetDataStorage;
  26903. _visibility: number;
  26904. _skeleton: Nullable<Skeleton>;
  26905. _layerMask: number;
  26906. _computeBonesUsingShaders: boolean;
  26907. _isActive: boolean;
  26908. _onlyForInstances: boolean;
  26909. _isActiveIntermediate: boolean;
  26910. _onlyForInstancesIntermediate: boolean;
  26911. _actAsRegularMesh: boolean;
  26912. }
  26913. /**
  26914. * Class used to store all common mesh properties
  26915. */
  26916. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26917. /** No occlusion */
  26918. static OCCLUSION_TYPE_NONE: number;
  26919. /** Occlusion set to optimisitic */
  26920. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26921. /** Occlusion set to strict */
  26922. static OCCLUSION_TYPE_STRICT: number;
  26923. /** Use an accurante occlusion algorithm */
  26924. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26925. /** Use a conservative occlusion algorithm */
  26926. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26927. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26928. * Test order :
  26929. * Is the bounding sphere outside the frustum ?
  26930. * If not, are the bounding box vertices outside the frustum ?
  26931. * It not, then the cullable object is in the frustum.
  26932. */
  26933. static readonly CULLINGSTRATEGY_STANDARD: number;
  26934. /** Culling strategy : Bounding Sphere Only.
  26935. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26936. * It's also less accurate than the standard because some not visible objects can still be selected.
  26937. * Test : is the bounding sphere outside the frustum ?
  26938. * If not, then the cullable object is in the frustum.
  26939. */
  26940. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26941. /** Culling strategy : Optimistic Inclusion.
  26942. * This in an inclusion test first, then the standard exclusion test.
  26943. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26944. * 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.
  26945. * Anyway, it's as accurate as the standard strategy.
  26946. * Test :
  26947. * Is the cullable object bounding sphere center in the frustum ?
  26948. * If not, apply the default culling strategy.
  26949. */
  26950. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26951. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26952. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26953. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26954. * 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.
  26955. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26956. * Test :
  26957. * Is the cullable object bounding sphere center in the frustum ?
  26958. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26959. */
  26960. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26961. /**
  26962. * No billboard
  26963. */
  26964. static readonly BILLBOARDMODE_NONE: number;
  26965. /** Billboard on X axis */
  26966. static readonly BILLBOARDMODE_X: number;
  26967. /** Billboard on Y axis */
  26968. static readonly BILLBOARDMODE_Y: number;
  26969. /** Billboard on Z axis */
  26970. static readonly BILLBOARDMODE_Z: number;
  26971. /** Billboard on all axes */
  26972. static readonly BILLBOARDMODE_ALL: number;
  26973. /** Billboard on using position instead of orientation */
  26974. static readonly BILLBOARDMODE_USE_POSITION: number;
  26975. /** @hidden */
  26976. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26977. /**
  26978. * The culling strategy to use to check whether the mesh must be rendered or not.
  26979. * This value can be changed at any time and will be used on the next render mesh selection.
  26980. * The possible values are :
  26981. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26982. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26983. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26984. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26985. * Please read each static variable documentation to get details about the culling process.
  26986. * */
  26987. cullingStrategy: number;
  26988. /**
  26989. * Gets the number of facets in the mesh
  26990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26991. */
  26992. readonly facetNb: number;
  26993. /**
  26994. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26996. */
  26997. partitioningSubdivisions: number;
  26998. /**
  26999. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27000. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27002. */
  27003. partitioningBBoxRatio: number;
  27004. /**
  27005. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27006. * Works only for updatable meshes.
  27007. * Doesn't work with multi-materials
  27008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27009. */
  27010. mustDepthSortFacets: boolean;
  27011. /**
  27012. * The location (Vector3) where the facet depth sort must be computed from.
  27013. * By default, the active camera position.
  27014. * Used only when facet depth sort is enabled
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27016. */
  27017. facetDepthSortFrom: Vector3;
  27018. /**
  27019. * gets a boolean indicating if facetData is enabled
  27020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27021. */
  27022. readonly isFacetDataEnabled: boolean;
  27023. /** @hidden */
  27024. _updateNonUniformScalingState(value: boolean): boolean;
  27025. /**
  27026. * An event triggered when this mesh collides with another one
  27027. */
  27028. onCollideObservable: Observable<AbstractMesh>;
  27029. /** Set a function to call when this mesh collides with another one */
  27030. onCollide: () => void;
  27031. /**
  27032. * An event triggered when the collision's position changes
  27033. */
  27034. onCollisionPositionChangeObservable: Observable<Vector3>;
  27035. /** Set a function to call when the collision's position changes */
  27036. onCollisionPositionChange: () => void;
  27037. /**
  27038. * An event triggered when material is changed
  27039. */
  27040. onMaterialChangedObservable: Observable<AbstractMesh>;
  27041. /**
  27042. * Gets or sets the orientation for POV movement & rotation
  27043. */
  27044. definedFacingForward: boolean;
  27045. /** @hidden */
  27046. _occlusionQuery: Nullable<WebGLQuery>;
  27047. /** @hidden */
  27048. _renderingGroup: Nullable<RenderingGroup>;
  27049. /**
  27050. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27051. */
  27052. /**
  27053. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27054. */
  27055. visibility: number;
  27056. /** Gets or sets the alpha index used to sort transparent meshes
  27057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27058. */
  27059. alphaIndex: number;
  27060. /**
  27061. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27062. */
  27063. isVisible: boolean;
  27064. /**
  27065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27066. */
  27067. isPickable: boolean;
  27068. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27069. showSubMeshesBoundingBox: boolean;
  27070. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27071. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27072. */
  27073. isBlocker: boolean;
  27074. /**
  27075. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27076. */
  27077. enablePointerMoveEvents: boolean;
  27078. /**
  27079. * Specifies the rendering group id for this mesh (0 by default)
  27080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27081. */
  27082. renderingGroupId: number;
  27083. private _material;
  27084. /** Gets or sets current material */
  27085. material: Nullable<Material>;
  27086. /**
  27087. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27088. * @see http://doc.babylonjs.com/babylon101/shadows
  27089. */
  27090. receiveShadows: boolean;
  27091. /** Defines color to use when rendering outline */
  27092. outlineColor: Color3;
  27093. /** Define width to use when rendering outline */
  27094. outlineWidth: number;
  27095. /** Defines color to use when rendering overlay */
  27096. overlayColor: Color3;
  27097. /** Defines alpha to use when rendering overlay */
  27098. overlayAlpha: number;
  27099. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27100. hasVertexAlpha: boolean;
  27101. /** 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) */
  27102. useVertexColors: boolean;
  27103. /**
  27104. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27105. */
  27106. computeBonesUsingShaders: boolean;
  27107. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27108. numBoneInfluencers: number;
  27109. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27110. applyFog: boolean;
  27111. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27112. useOctreeForRenderingSelection: boolean;
  27113. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27114. useOctreeForPicking: boolean;
  27115. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27116. useOctreeForCollisions: boolean;
  27117. /**
  27118. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27119. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27120. */
  27121. layerMask: number;
  27122. /**
  27123. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27124. */
  27125. alwaysSelectAsActiveMesh: boolean;
  27126. /**
  27127. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27128. */
  27129. doNotSyncBoundingInfo: boolean;
  27130. /**
  27131. * Gets or sets the current action manager
  27132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27133. */
  27134. actionManager: Nullable<AbstractActionManager>;
  27135. private _meshCollisionData;
  27136. /**
  27137. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27139. */
  27140. ellipsoid: Vector3;
  27141. /**
  27142. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27144. */
  27145. ellipsoidOffset: Vector3;
  27146. /**
  27147. * Gets or sets a collision mask used to mask collisions (default is -1).
  27148. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27149. */
  27150. collisionMask: number;
  27151. /**
  27152. * Gets or sets the current collision group mask (-1 by default).
  27153. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27154. */
  27155. collisionGroup: number;
  27156. /**
  27157. * Defines edge width used when edgesRenderer is enabled
  27158. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27159. */
  27160. edgesWidth: number;
  27161. /**
  27162. * Defines edge color used when edgesRenderer is enabled
  27163. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27164. */
  27165. edgesColor: Color4;
  27166. /** @hidden */
  27167. _edgesRenderer: Nullable<IEdgesRenderer>;
  27168. /** @hidden */
  27169. _masterMesh: Nullable<AbstractMesh>;
  27170. /** @hidden */
  27171. _boundingInfo: Nullable<BoundingInfo>;
  27172. /** @hidden */
  27173. _renderId: number;
  27174. /**
  27175. * Gets or sets the list of subMeshes
  27176. * @see http://doc.babylonjs.com/how_to/multi_materials
  27177. */
  27178. subMeshes: SubMesh[];
  27179. /** @hidden */
  27180. _intersectionsInProgress: AbstractMesh[];
  27181. /** @hidden */
  27182. _unIndexed: boolean;
  27183. /** @hidden */
  27184. _lightSources: Light[];
  27185. /** Gets the list of lights affecting that mesh */
  27186. readonly lightSources: Light[];
  27187. /** @hidden */
  27188. readonly _positions: Nullable<Vector3[]>;
  27189. /** @hidden */
  27190. _waitingData: {
  27191. lods: Nullable<any>;
  27192. actions: Nullable<any>;
  27193. freezeWorldMatrix: Nullable<boolean>;
  27194. };
  27195. /** @hidden */
  27196. _bonesTransformMatrices: Nullable<Float32Array>;
  27197. /** @hidden */
  27198. _transformMatrixTexture: Nullable<RawTexture>;
  27199. /**
  27200. * Gets or sets a skeleton to apply skining transformations
  27201. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27202. */
  27203. skeleton: Nullable<Skeleton>;
  27204. /**
  27205. * An event triggered when the mesh is rebuilt.
  27206. */
  27207. onRebuildObservable: Observable<AbstractMesh>;
  27208. /**
  27209. * Creates a new AbstractMesh
  27210. * @param name defines the name of the mesh
  27211. * @param scene defines the hosting scene
  27212. */
  27213. constructor(name: string, scene?: Nullable<Scene>);
  27214. /**
  27215. * Returns the string "AbstractMesh"
  27216. * @returns "AbstractMesh"
  27217. */
  27218. getClassName(): string;
  27219. /**
  27220. * Gets a string representation of the current mesh
  27221. * @param fullDetails defines a boolean indicating if full details must be included
  27222. * @returns a string representation of the current mesh
  27223. */
  27224. toString(fullDetails?: boolean): string;
  27225. /**
  27226. * @hidden
  27227. */
  27228. protected _getEffectiveParent(): Nullable<Node>;
  27229. /** @hidden */
  27230. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27231. /** @hidden */
  27232. _rebuild(): void;
  27233. /** @hidden */
  27234. _resyncLightSources(): void;
  27235. /** @hidden */
  27236. _resyncLighSource(light: Light): void;
  27237. /** @hidden */
  27238. _unBindEffect(): void;
  27239. /** @hidden */
  27240. _removeLightSource(light: Light, dispose: boolean): void;
  27241. private _markSubMeshesAsDirty;
  27242. /** @hidden */
  27243. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27244. /** @hidden */
  27245. _markSubMeshesAsAttributesDirty(): void;
  27246. /** @hidden */
  27247. _markSubMeshesAsMiscDirty(): void;
  27248. /**
  27249. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27250. */
  27251. scaling: Vector3;
  27252. /**
  27253. * Returns true if the mesh is blocked. Implemented by child classes
  27254. */
  27255. readonly isBlocked: boolean;
  27256. /**
  27257. * Returns the mesh itself by default. Implemented by child classes
  27258. * @param camera defines the camera to use to pick the right LOD level
  27259. * @returns the currentAbstractMesh
  27260. */
  27261. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27262. /**
  27263. * Returns 0 by default. Implemented by child classes
  27264. * @returns an integer
  27265. */
  27266. getTotalVertices(): number;
  27267. /**
  27268. * Returns a positive integer : the total number of indices in this mesh geometry.
  27269. * @returns the numner of indices or zero if the mesh has no geometry.
  27270. */
  27271. getTotalIndices(): number;
  27272. /**
  27273. * Returns null by default. Implemented by child classes
  27274. * @returns null
  27275. */
  27276. getIndices(): Nullable<IndicesArray>;
  27277. /**
  27278. * Returns the array of the requested vertex data kind. Implemented by child classes
  27279. * @param kind defines the vertex data kind to use
  27280. * @returns null
  27281. */
  27282. getVerticesData(kind: string): Nullable<FloatArray>;
  27283. /**
  27284. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27285. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27286. * Note that a new underlying VertexBuffer object is created each call.
  27287. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27288. * @param kind defines vertex data kind:
  27289. * * VertexBuffer.PositionKind
  27290. * * VertexBuffer.UVKind
  27291. * * VertexBuffer.UV2Kind
  27292. * * VertexBuffer.UV3Kind
  27293. * * VertexBuffer.UV4Kind
  27294. * * VertexBuffer.UV5Kind
  27295. * * VertexBuffer.UV6Kind
  27296. * * VertexBuffer.ColorKind
  27297. * * VertexBuffer.MatricesIndicesKind
  27298. * * VertexBuffer.MatricesIndicesExtraKind
  27299. * * VertexBuffer.MatricesWeightsKind
  27300. * * VertexBuffer.MatricesWeightsExtraKind
  27301. * @param data defines the data source
  27302. * @param updatable defines if the data must be flagged as updatable (or static)
  27303. * @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
  27304. * @returns the current mesh
  27305. */
  27306. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27307. /**
  27308. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27309. * If the mesh has no geometry, it is simply returned as it is.
  27310. * @param kind defines vertex data kind:
  27311. * * VertexBuffer.PositionKind
  27312. * * VertexBuffer.UVKind
  27313. * * VertexBuffer.UV2Kind
  27314. * * VertexBuffer.UV3Kind
  27315. * * VertexBuffer.UV4Kind
  27316. * * VertexBuffer.UV5Kind
  27317. * * VertexBuffer.UV6Kind
  27318. * * VertexBuffer.ColorKind
  27319. * * VertexBuffer.MatricesIndicesKind
  27320. * * VertexBuffer.MatricesIndicesExtraKind
  27321. * * VertexBuffer.MatricesWeightsKind
  27322. * * VertexBuffer.MatricesWeightsExtraKind
  27323. * @param data defines the data source
  27324. * @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
  27325. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27326. * @returns the current mesh
  27327. */
  27328. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27329. /**
  27330. * Sets the mesh indices,
  27331. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27332. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27333. * @param totalVertices Defines the total number of vertices
  27334. * @returns the current mesh
  27335. */
  27336. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27337. /**
  27338. * Gets a boolean indicating if specific vertex data is present
  27339. * @param kind defines the vertex data kind to use
  27340. * @returns true is data kind is present
  27341. */
  27342. isVerticesDataPresent(kind: string): boolean;
  27343. /**
  27344. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27345. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27346. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27347. * @returns a BoundingInfo
  27348. */
  27349. getBoundingInfo(): BoundingInfo;
  27350. /**
  27351. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27352. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27353. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27354. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27355. * @returns the current mesh
  27356. */
  27357. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27358. /**
  27359. * Overwrite the current bounding info
  27360. * @param boundingInfo defines the new bounding info
  27361. * @returns the current mesh
  27362. */
  27363. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27364. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27365. readonly useBones: boolean;
  27366. /** @hidden */
  27367. _preActivate(): void;
  27368. /** @hidden */
  27369. _preActivateForIntermediateRendering(renderId: number): void;
  27370. /** @hidden */
  27371. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27372. /** @hidden */
  27373. _postActivate(): void;
  27374. /** @hidden */
  27375. _freeze(): void;
  27376. /** @hidden */
  27377. _unFreeze(): void;
  27378. /**
  27379. * Gets the current world matrix
  27380. * @returns a Matrix
  27381. */
  27382. getWorldMatrix(): Matrix;
  27383. /** @hidden */
  27384. _getWorldMatrixDeterminant(): number;
  27385. /**
  27386. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27387. */
  27388. readonly isAnInstance: boolean;
  27389. /**
  27390. * Gets a boolean indicating if this mesh has instances
  27391. */
  27392. readonly hasInstances: boolean;
  27393. /**
  27394. * Perform relative position change from the point of view of behind the front of the mesh.
  27395. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27396. * Supports definition of mesh facing forward or backward
  27397. * @param amountRight defines the distance on the right axis
  27398. * @param amountUp defines the distance on the up axis
  27399. * @param amountForward defines the distance on the forward axis
  27400. * @returns the current mesh
  27401. */
  27402. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27403. /**
  27404. * Calculate relative position change from the point of view of behind the front of the mesh.
  27405. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27406. * Supports definition of mesh facing forward or backward
  27407. * @param amountRight defines the distance on the right axis
  27408. * @param amountUp defines the distance on the up axis
  27409. * @param amountForward defines the distance on the forward axis
  27410. * @returns the new displacement vector
  27411. */
  27412. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27413. /**
  27414. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27415. * Supports definition of mesh facing forward or backward
  27416. * @param flipBack defines the flip
  27417. * @param twirlClockwise defines the twirl
  27418. * @param tiltRight defines the tilt
  27419. * @returns the current mesh
  27420. */
  27421. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27422. /**
  27423. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27424. * Supports definition of mesh facing forward or backward.
  27425. * @param flipBack defines the flip
  27426. * @param twirlClockwise defines the twirl
  27427. * @param tiltRight defines the tilt
  27428. * @returns the new rotation vector
  27429. */
  27430. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27431. /**
  27432. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27433. * This means the mesh underlying bounding box and sphere are recomputed.
  27434. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27435. * @returns the current mesh
  27436. */
  27437. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27438. /** @hidden */
  27439. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27440. /** @hidden */
  27441. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27442. /** @hidden */
  27443. _updateBoundingInfo(): AbstractMesh;
  27444. /** @hidden */
  27445. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27446. /** @hidden */
  27447. protected _afterComputeWorldMatrix(): void;
  27448. /** @hidden */
  27449. readonly _effectiveMesh: AbstractMesh;
  27450. /**
  27451. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27452. * A mesh is in the frustum if its bounding box intersects the frustum
  27453. * @param frustumPlanes defines the frustum to test
  27454. * @returns true if the mesh is in the frustum planes
  27455. */
  27456. isInFrustum(frustumPlanes: Plane[]): boolean;
  27457. /**
  27458. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27459. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27460. * @param frustumPlanes defines the frustum to test
  27461. * @returns true if the mesh is completely in the frustum planes
  27462. */
  27463. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27464. /**
  27465. * True if the mesh intersects another mesh or a SolidParticle object
  27466. * @param mesh defines a target mesh or SolidParticle to test
  27467. * @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)
  27468. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27469. * @returns true if there is an intersection
  27470. */
  27471. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27472. /**
  27473. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27474. * @param point defines the point to test
  27475. * @returns true if there is an intersection
  27476. */
  27477. intersectsPoint(point: Vector3): boolean;
  27478. /**
  27479. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27481. */
  27482. checkCollisions: boolean;
  27483. /**
  27484. * Gets Collider object used to compute collisions (not physics)
  27485. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27486. */
  27487. readonly collider: Nullable<Collider>;
  27488. /**
  27489. * Move the mesh using collision engine
  27490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27491. * @param displacement defines the requested displacement vector
  27492. * @returns the current mesh
  27493. */
  27494. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27495. private _onCollisionPositionChange;
  27496. /** @hidden */
  27497. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27498. /** @hidden */
  27499. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27500. /** @hidden */
  27501. _checkCollision(collider: Collider): AbstractMesh;
  27502. /** @hidden */
  27503. _generatePointsArray(): boolean;
  27504. /**
  27505. * Checks if the passed Ray intersects with the mesh
  27506. * @param ray defines the ray to use
  27507. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27509. * @returns the picking info
  27510. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27511. */
  27512. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27513. /**
  27514. * Clones the current mesh
  27515. * @param name defines the mesh name
  27516. * @param newParent defines the new mesh parent
  27517. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27518. * @returns the new mesh
  27519. */
  27520. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27521. /**
  27522. * Disposes all the submeshes of the current meshnp
  27523. * @returns the current mesh
  27524. */
  27525. releaseSubMeshes(): AbstractMesh;
  27526. /**
  27527. * Releases resources associated with this abstract mesh.
  27528. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27529. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27530. */
  27531. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27532. /**
  27533. * Adds the passed mesh as a child to the current mesh
  27534. * @param mesh defines the child mesh
  27535. * @returns the current mesh
  27536. */
  27537. addChild(mesh: AbstractMesh): AbstractMesh;
  27538. /**
  27539. * Removes the passed mesh from the current mesh children list
  27540. * @param mesh defines the child mesh
  27541. * @returns the current mesh
  27542. */
  27543. removeChild(mesh: AbstractMesh): AbstractMesh;
  27544. /** @hidden */
  27545. private _initFacetData;
  27546. /**
  27547. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27548. * This method can be called within the render loop.
  27549. * 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
  27550. * @returns the current mesh
  27551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27552. */
  27553. updateFacetData(): AbstractMesh;
  27554. /**
  27555. * Returns the facetLocalNormals array.
  27556. * The normals are expressed in the mesh local spac
  27557. * @returns an array of Vector3
  27558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27559. */
  27560. getFacetLocalNormals(): Vector3[];
  27561. /**
  27562. * Returns the facetLocalPositions array.
  27563. * The facet positions are expressed in the mesh local space
  27564. * @returns an array of Vector3
  27565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27566. */
  27567. getFacetLocalPositions(): Vector3[];
  27568. /**
  27569. * Returns the facetLocalPartioning array
  27570. * @returns an array of array of numbers
  27571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27572. */
  27573. getFacetLocalPartitioning(): number[][];
  27574. /**
  27575. * Returns the i-th facet position in the world system.
  27576. * This method allocates a new Vector3 per call
  27577. * @param i defines the facet index
  27578. * @returns a new Vector3
  27579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27580. */
  27581. getFacetPosition(i: number): Vector3;
  27582. /**
  27583. * Sets the reference Vector3 with the i-th facet position in the world system
  27584. * @param i defines the facet index
  27585. * @param ref defines the target vector
  27586. * @returns the current mesh
  27587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27588. */
  27589. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27590. /**
  27591. * Returns the i-th facet normal in the world system.
  27592. * This method allocates a new Vector3 per call
  27593. * @param i defines the facet index
  27594. * @returns a new Vector3
  27595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27596. */
  27597. getFacetNormal(i: number): Vector3;
  27598. /**
  27599. * Sets the reference Vector3 with the i-th facet normal in the world system
  27600. * @param i defines the facet index
  27601. * @param ref defines the target vector
  27602. * @returns the current mesh
  27603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27604. */
  27605. getFacetNormalToRef(i: number, ref: Vector3): this;
  27606. /**
  27607. * 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)
  27608. * @param x defines x coordinate
  27609. * @param y defines y coordinate
  27610. * @param z defines z coordinate
  27611. * @returns the array of facet indexes
  27612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27613. */
  27614. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27615. /**
  27616. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27617. * @param projected sets as the (x,y,z) world projection on the facet
  27618. * @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
  27619. * @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
  27620. * @param x defines x coordinate
  27621. * @param y defines y coordinate
  27622. * @param z defines z coordinate
  27623. * @returns the face index if found (or null instead)
  27624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27625. */
  27626. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27627. /**
  27628. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27629. * @param projected sets as the (x,y,z) local projection on the facet
  27630. * @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
  27631. * @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
  27632. * @param x defines x coordinate
  27633. * @param y defines y coordinate
  27634. * @param z defines z coordinate
  27635. * @returns the face index if found (or null instead)
  27636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27637. */
  27638. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27639. /**
  27640. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27641. * @returns the parameters
  27642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27643. */
  27644. getFacetDataParameters(): any;
  27645. /**
  27646. * Disables the feature FacetData and frees the related memory
  27647. * @returns the current mesh
  27648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27649. */
  27650. disableFacetData(): AbstractMesh;
  27651. /**
  27652. * Updates the AbstractMesh indices array
  27653. * @param indices defines the data source
  27654. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27655. * @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)
  27656. * @returns the current mesh
  27657. */
  27658. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27659. /**
  27660. * Creates new normals data for the mesh
  27661. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27662. * @returns the current mesh
  27663. */
  27664. createNormals(updatable: boolean): AbstractMesh;
  27665. /**
  27666. * Align the mesh with a normal
  27667. * @param normal defines the normal to use
  27668. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27669. * @returns the current mesh
  27670. */
  27671. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27672. /** @hidden */
  27673. _checkOcclusionQuery(): boolean;
  27674. /**
  27675. * Disables the mesh edge rendering mode
  27676. * @returns the currentAbstractMesh
  27677. */
  27678. disableEdgesRendering(): AbstractMesh;
  27679. /**
  27680. * Enables the edge rendering mode on the mesh.
  27681. * This mode makes the mesh edges visible
  27682. * @param epsilon defines the maximal distance between two angles to detect a face
  27683. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27684. * @returns the currentAbstractMesh
  27685. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27686. */
  27687. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27688. }
  27689. }
  27690. declare module "babylonjs/Actions/actionEvent" {
  27691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27692. import { Nullable } from "babylonjs/types";
  27693. import { Sprite } from "babylonjs/Sprites/sprite";
  27694. import { Scene } from "babylonjs/scene";
  27695. import { Vector2 } from "babylonjs/Maths/math.vector";
  27696. /**
  27697. * Interface used to define ActionEvent
  27698. */
  27699. export interface IActionEvent {
  27700. /** The mesh or sprite that triggered the action */
  27701. source: any;
  27702. /** The X mouse cursor position at the time of the event */
  27703. pointerX: number;
  27704. /** The Y mouse cursor position at the time of the event */
  27705. pointerY: number;
  27706. /** The mesh that is currently pointed at (can be null) */
  27707. meshUnderPointer: Nullable<AbstractMesh>;
  27708. /** the original (browser) event that triggered the ActionEvent */
  27709. sourceEvent?: any;
  27710. /** additional data for the event */
  27711. additionalData?: any;
  27712. }
  27713. /**
  27714. * ActionEvent is the event being sent when an action is triggered.
  27715. */
  27716. export class ActionEvent implements IActionEvent {
  27717. /** The mesh or sprite that triggered the action */
  27718. source: any;
  27719. /** The X mouse cursor position at the time of the event */
  27720. pointerX: number;
  27721. /** The Y mouse cursor position at the time of the event */
  27722. pointerY: number;
  27723. /** The mesh that is currently pointed at (can be null) */
  27724. meshUnderPointer: Nullable<AbstractMesh>;
  27725. /** the original (browser) event that triggered the ActionEvent */
  27726. sourceEvent?: any;
  27727. /** additional data for the event */
  27728. additionalData?: any;
  27729. /**
  27730. * Creates a new ActionEvent
  27731. * @param source The mesh or sprite that triggered the action
  27732. * @param pointerX The X mouse cursor position at the time of the event
  27733. * @param pointerY The Y mouse cursor position at the time of the event
  27734. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27735. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27736. * @param additionalData additional data for the event
  27737. */
  27738. constructor(
  27739. /** The mesh or sprite that triggered the action */
  27740. source: any,
  27741. /** The X mouse cursor position at the time of the event */
  27742. pointerX: number,
  27743. /** The Y mouse cursor position at the time of the event */
  27744. pointerY: number,
  27745. /** The mesh that is currently pointed at (can be null) */
  27746. meshUnderPointer: Nullable<AbstractMesh>,
  27747. /** the original (browser) event that triggered the ActionEvent */
  27748. sourceEvent?: any,
  27749. /** additional data for the event */
  27750. additionalData?: any);
  27751. /**
  27752. * Helper function to auto-create an ActionEvent from a source mesh.
  27753. * @param source The source mesh that triggered the event
  27754. * @param evt The original (browser) event
  27755. * @param additionalData additional data for the event
  27756. * @returns the new ActionEvent
  27757. */
  27758. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27759. /**
  27760. * Helper function to auto-create an ActionEvent from a source sprite
  27761. * @param source The source sprite that triggered the event
  27762. * @param scene Scene associated with the sprite
  27763. * @param evt The original (browser) event
  27764. * @param additionalData additional data for the event
  27765. * @returns the new ActionEvent
  27766. */
  27767. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27768. /**
  27769. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27770. * @param scene the scene where the event occurred
  27771. * @param evt The original (browser) event
  27772. * @returns the new ActionEvent
  27773. */
  27774. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27775. /**
  27776. * Helper function to auto-create an ActionEvent from a primitive
  27777. * @param prim defines the target primitive
  27778. * @param pointerPos defines the pointer position
  27779. * @param evt The original (browser) event
  27780. * @param additionalData additional data for the event
  27781. * @returns the new ActionEvent
  27782. */
  27783. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27784. }
  27785. }
  27786. declare module "babylonjs/Actions/abstractActionManager" {
  27787. import { IDisposable } from "babylonjs/scene";
  27788. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27789. import { IAction } from "babylonjs/Actions/action";
  27790. import { Nullable } from "babylonjs/types";
  27791. /**
  27792. * Abstract class used to decouple action Manager from scene and meshes.
  27793. * Do not instantiate.
  27794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27795. */
  27796. export abstract class AbstractActionManager implements IDisposable {
  27797. /** Gets the list of active triggers */
  27798. static Triggers: {
  27799. [key: string]: number;
  27800. };
  27801. /** Gets the cursor to use when hovering items */
  27802. hoverCursor: string;
  27803. /** Gets the list of actions */
  27804. actions: IAction[];
  27805. /**
  27806. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27807. */
  27808. isRecursive: boolean;
  27809. /**
  27810. * Releases all associated resources
  27811. */
  27812. abstract dispose(): void;
  27813. /**
  27814. * Does this action manager has pointer triggers
  27815. */
  27816. abstract readonly hasPointerTriggers: boolean;
  27817. /**
  27818. * Does this action manager has pick triggers
  27819. */
  27820. abstract readonly hasPickTriggers: boolean;
  27821. /**
  27822. * Process a specific trigger
  27823. * @param trigger defines the trigger to process
  27824. * @param evt defines the event details to be processed
  27825. */
  27826. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27827. /**
  27828. * Does this action manager handles actions of any of the given triggers
  27829. * @param triggers defines the triggers to be tested
  27830. * @return a boolean indicating whether one (or more) of the triggers is handled
  27831. */
  27832. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27833. /**
  27834. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27835. * speed.
  27836. * @param triggerA defines the trigger to be tested
  27837. * @param triggerB defines the trigger to be tested
  27838. * @return a boolean indicating whether one (or more) of the triggers is handled
  27839. */
  27840. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27841. /**
  27842. * Does this action manager handles actions of a given trigger
  27843. * @param trigger defines the trigger to be tested
  27844. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27845. * @return whether the trigger is handled
  27846. */
  27847. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27848. /**
  27849. * Serialize this manager to a JSON object
  27850. * @param name defines the property name to store this manager
  27851. * @returns a JSON representation of this manager
  27852. */
  27853. abstract serialize(name: string): any;
  27854. /**
  27855. * Registers an action to this action manager
  27856. * @param action defines the action to be registered
  27857. * @return the action amended (prepared) after registration
  27858. */
  27859. abstract registerAction(action: IAction): Nullable<IAction>;
  27860. /**
  27861. * Unregisters an action to this action manager
  27862. * @param action defines the action to be unregistered
  27863. * @return a boolean indicating whether the action has been unregistered
  27864. */
  27865. abstract unregisterAction(action: IAction): Boolean;
  27866. /**
  27867. * Does exist one action manager with at least one trigger
  27868. **/
  27869. static readonly HasTriggers: boolean;
  27870. /**
  27871. * Does exist one action manager with at least one pick trigger
  27872. **/
  27873. static readonly HasPickTriggers: boolean;
  27874. /**
  27875. * Does exist one action manager that handles actions of a given trigger
  27876. * @param trigger defines the trigger to be tested
  27877. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27878. **/
  27879. static HasSpecificTrigger(trigger: number): boolean;
  27880. }
  27881. }
  27882. declare module "babylonjs/node" {
  27883. import { Scene } from "babylonjs/scene";
  27884. import { Nullable } from "babylonjs/types";
  27885. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27886. import { Engine } from "babylonjs/Engines/engine";
  27887. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27888. import { Observable } from "babylonjs/Misc/observable";
  27889. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27890. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27891. import { Animatable } from "babylonjs/Animations/animatable";
  27892. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27893. import { Animation } from "babylonjs/Animations/animation";
  27894. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27896. /**
  27897. * Defines how a node can be built from a string name.
  27898. */
  27899. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27900. /**
  27901. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27902. */
  27903. export class Node implements IBehaviorAware<Node> {
  27904. /** @hidden */
  27905. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27906. private static _NodeConstructors;
  27907. /**
  27908. * Add a new node constructor
  27909. * @param type defines the type name of the node to construct
  27910. * @param constructorFunc defines the constructor function
  27911. */
  27912. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27913. /**
  27914. * Returns a node constructor based on type name
  27915. * @param type defines the type name
  27916. * @param name defines the new node name
  27917. * @param scene defines the hosting scene
  27918. * @param options defines optional options to transmit to constructors
  27919. * @returns the new constructor or null
  27920. */
  27921. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27922. /**
  27923. * Gets or sets the name of the node
  27924. */
  27925. name: string;
  27926. /**
  27927. * Gets or sets the id of the node
  27928. */
  27929. id: string;
  27930. /**
  27931. * Gets or sets the unique id of the node
  27932. */
  27933. uniqueId: number;
  27934. /**
  27935. * Gets or sets a string used to store user defined state for the node
  27936. */
  27937. state: string;
  27938. /**
  27939. * Gets or sets an object used to store user defined information for the node
  27940. */
  27941. metadata: any;
  27942. /**
  27943. * For internal use only. Please do not use.
  27944. */
  27945. reservedDataStore: any;
  27946. /**
  27947. * List of inspectable custom properties (used by the Inspector)
  27948. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27949. */
  27950. inspectableCustomProperties: IInspectable[];
  27951. private _doNotSerialize;
  27952. /**
  27953. * Gets or sets a boolean used to define if the node must be serialized
  27954. */
  27955. doNotSerialize: boolean;
  27956. /** @hidden */
  27957. _isDisposed: boolean;
  27958. /**
  27959. * Gets a list of Animations associated with the node
  27960. */
  27961. animations: import("babylonjs/Animations/animation").Animation[];
  27962. protected _ranges: {
  27963. [name: string]: Nullable<AnimationRange>;
  27964. };
  27965. /**
  27966. * Callback raised when the node is ready to be used
  27967. */
  27968. onReady: Nullable<(node: Node) => void>;
  27969. private _isEnabled;
  27970. private _isParentEnabled;
  27971. private _isReady;
  27972. /** @hidden */
  27973. _currentRenderId: number;
  27974. private _parentUpdateId;
  27975. /** @hidden */
  27976. _childUpdateId: number;
  27977. /** @hidden */
  27978. _waitingParentId: Nullable<string>;
  27979. /** @hidden */
  27980. _scene: Scene;
  27981. /** @hidden */
  27982. _cache: any;
  27983. private _parentNode;
  27984. private _children;
  27985. /** @hidden */
  27986. _worldMatrix: Matrix;
  27987. /** @hidden */
  27988. _worldMatrixDeterminant: number;
  27989. /** @hidden */
  27990. _worldMatrixDeterminantIsDirty: boolean;
  27991. /** @hidden */
  27992. private _sceneRootNodesIndex;
  27993. /**
  27994. * Gets a boolean indicating if the node has been disposed
  27995. * @returns true if the node was disposed
  27996. */
  27997. isDisposed(): boolean;
  27998. /**
  27999. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28000. * @see https://doc.babylonjs.com/how_to/parenting
  28001. */
  28002. parent: Nullable<Node>;
  28003. /** @hidden */
  28004. _addToSceneRootNodes(): void;
  28005. /** @hidden */
  28006. _removeFromSceneRootNodes(): void;
  28007. private _animationPropertiesOverride;
  28008. /**
  28009. * Gets or sets the animation properties override
  28010. */
  28011. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28012. /**
  28013. * Gets a string idenfifying the name of the class
  28014. * @returns "Node" string
  28015. */
  28016. getClassName(): string;
  28017. /** @hidden */
  28018. readonly _isNode: boolean;
  28019. /**
  28020. * An event triggered when the mesh is disposed
  28021. */
  28022. onDisposeObservable: Observable<Node>;
  28023. private _onDisposeObserver;
  28024. /**
  28025. * Sets a callback that will be raised when the node will be disposed
  28026. */
  28027. onDispose: () => void;
  28028. /**
  28029. * Creates a new Node
  28030. * @param name the name and id to be given to this node
  28031. * @param scene the scene this node will be added to
  28032. */
  28033. constructor(name: string, scene?: Nullable<Scene>);
  28034. /**
  28035. * Gets the scene of the node
  28036. * @returns a scene
  28037. */
  28038. getScene(): Scene;
  28039. /**
  28040. * Gets the engine of the node
  28041. * @returns a Engine
  28042. */
  28043. getEngine(): Engine;
  28044. private _behaviors;
  28045. /**
  28046. * Attach a behavior to the node
  28047. * @see http://doc.babylonjs.com/features/behaviour
  28048. * @param behavior defines the behavior to attach
  28049. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28050. * @returns the current Node
  28051. */
  28052. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28053. /**
  28054. * Remove an attached behavior
  28055. * @see http://doc.babylonjs.com/features/behaviour
  28056. * @param behavior defines the behavior to attach
  28057. * @returns the current Node
  28058. */
  28059. removeBehavior(behavior: Behavior<Node>): Node;
  28060. /**
  28061. * Gets the list of attached behaviors
  28062. * @see http://doc.babylonjs.com/features/behaviour
  28063. */
  28064. readonly behaviors: Behavior<Node>[];
  28065. /**
  28066. * Gets an attached behavior by name
  28067. * @param name defines the name of the behavior to look for
  28068. * @see http://doc.babylonjs.com/features/behaviour
  28069. * @returns null if behavior was not found else the requested behavior
  28070. */
  28071. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28072. /**
  28073. * Returns the latest update of the World matrix
  28074. * @returns a Matrix
  28075. */
  28076. getWorldMatrix(): Matrix;
  28077. /** @hidden */
  28078. _getWorldMatrixDeterminant(): number;
  28079. /**
  28080. * Returns directly the latest state of the mesh World matrix.
  28081. * A Matrix is returned.
  28082. */
  28083. readonly worldMatrixFromCache: Matrix;
  28084. /** @hidden */
  28085. _initCache(): void;
  28086. /** @hidden */
  28087. updateCache(force?: boolean): void;
  28088. /** @hidden */
  28089. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28090. /** @hidden */
  28091. _updateCache(ignoreParentClass?: boolean): void;
  28092. /** @hidden */
  28093. _isSynchronized(): boolean;
  28094. /** @hidden */
  28095. _markSyncedWithParent(): void;
  28096. /** @hidden */
  28097. isSynchronizedWithParent(): boolean;
  28098. /** @hidden */
  28099. isSynchronized(): boolean;
  28100. /**
  28101. * Is this node ready to be used/rendered
  28102. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28103. * @return true if the node is ready
  28104. */
  28105. isReady(completeCheck?: boolean): boolean;
  28106. /**
  28107. * Is this node enabled?
  28108. * 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
  28109. * @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
  28110. * @return whether this node (and its parent) is enabled
  28111. */
  28112. isEnabled(checkAncestors?: boolean): boolean;
  28113. /** @hidden */
  28114. protected _syncParentEnabledState(): void;
  28115. /**
  28116. * Set the enabled state of this node
  28117. * @param value defines the new enabled state
  28118. */
  28119. setEnabled(value: boolean): void;
  28120. /**
  28121. * Is this node a descendant of the given node?
  28122. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28123. * @param ancestor defines the parent node to inspect
  28124. * @returns a boolean indicating if this node is a descendant of the given node
  28125. */
  28126. isDescendantOf(ancestor: Node): boolean;
  28127. /** @hidden */
  28128. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28129. /**
  28130. * Will return all nodes that have this node as ascendant
  28131. * @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
  28132. * @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
  28133. * @return all children nodes of all types
  28134. */
  28135. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28136. /**
  28137. * Get all child-meshes of this node
  28138. * @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)
  28139. * @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
  28140. * @returns an array of AbstractMesh
  28141. */
  28142. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28143. /**
  28144. * Get all direct children of this node
  28145. * @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
  28146. * @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)
  28147. * @returns an array of Node
  28148. */
  28149. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28150. /** @hidden */
  28151. _setReady(state: boolean): void;
  28152. /**
  28153. * Get an animation by name
  28154. * @param name defines the name of the animation to look for
  28155. * @returns null if not found else the requested animation
  28156. */
  28157. getAnimationByName(name: string): Nullable<Animation>;
  28158. /**
  28159. * Creates an animation range for this node
  28160. * @param name defines the name of the range
  28161. * @param from defines the starting key
  28162. * @param to defines the end key
  28163. */
  28164. createAnimationRange(name: string, from: number, to: number): void;
  28165. /**
  28166. * Delete a specific animation range
  28167. * @param name defines the name of the range to delete
  28168. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28169. */
  28170. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28171. /**
  28172. * Get an animation range by name
  28173. * @param name defines the name of the animation range to look for
  28174. * @returns null if not found else the requested animation range
  28175. */
  28176. getAnimationRange(name: string): Nullable<AnimationRange>;
  28177. /**
  28178. * Gets the list of all animation ranges defined on this node
  28179. * @returns an array
  28180. */
  28181. getAnimationRanges(): Nullable<AnimationRange>[];
  28182. /**
  28183. * Will start the animation sequence
  28184. * @param name defines the range frames for animation sequence
  28185. * @param loop defines if the animation should loop (false by default)
  28186. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28187. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28188. * @returns the object created for this animation. If range does not exist, it will return null
  28189. */
  28190. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28191. /**
  28192. * Serialize animation ranges into a JSON compatible object
  28193. * @returns serialization object
  28194. */
  28195. serializeAnimationRanges(): any;
  28196. /**
  28197. * Computes the world matrix of the node
  28198. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28199. * @returns the world matrix
  28200. */
  28201. computeWorldMatrix(force?: boolean): Matrix;
  28202. /**
  28203. * Releases resources associated with this node.
  28204. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28205. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28206. */
  28207. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28208. /**
  28209. * Parse animation range data from a serialization object and store them into a given node
  28210. * @param node defines where to store the animation ranges
  28211. * @param parsedNode defines the serialization object to read data from
  28212. * @param scene defines the hosting scene
  28213. */
  28214. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28215. /**
  28216. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28217. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28218. * @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
  28219. * @returns the new bounding vectors
  28220. */
  28221. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28222. min: Vector3;
  28223. max: Vector3;
  28224. };
  28225. }
  28226. }
  28227. declare module "babylonjs/Animations/animation" {
  28228. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28229. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28230. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28231. import { Nullable } from "babylonjs/types";
  28232. import { Scene } from "babylonjs/scene";
  28233. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28234. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28235. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28236. import { Node } from "babylonjs/node";
  28237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28238. import { Size } from "babylonjs/Maths/math.size";
  28239. import { Animatable } from "babylonjs/Animations/animatable";
  28240. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28241. /**
  28242. * @hidden
  28243. */
  28244. export class _IAnimationState {
  28245. key: number;
  28246. repeatCount: number;
  28247. workValue?: any;
  28248. loopMode?: number;
  28249. offsetValue?: any;
  28250. highLimitValue?: any;
  28251. }
  28252. /**
  28253. * Class used to store any kind of animation
  28254. */
  28255. export class Animation {
  28256. /**Name of the animation */
  28257. name: string;
  28258. /**Property to animate */
  28259. targetProperty: string;
  28260. /**The frames per second of the animation */
  28261. framePerSecond: number;
  28262. /**The data type of the animation */
  28263. dataType: number;
  28264. /**The loop mode of the animation */
  28265. loopMode?: number | undefined;
  28266. /**Specifies if blending should be enabled */
  28267. enableBlending?: boolean | undefined;
  28268. /**
  28269. * Use matrix interpolation instead of using direct key value when animating matrices
  28270. */
  28271. static AllowMatricesInterpolation: boolean;
  28272. /**
  28273. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28274. */
  28275. static AllowMatrixDecomposeForInterpolation: boolean;
  28276. /**
  28277. * Stores the key frames of the animation
  28278. */
  28279. private _keys;
  28280. /**
  28281. * Stores the easing function of the animation
  28282. */
  28283. private _easingFunction;
  28284. /**
  28285. * @hidden Internal use only
  28286. */
  28287. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28288. /**
  28289. * The set of event that will be linked to this animation
  28290. */
  28291. private _events;
  28292. /**
  28293. * Stores an array of target property paths
  28294. */
  28295. targetPropertyPath: string[];
  28296. /**
  28297. * Stores the blending speed of the animation
  28298. */
  28299. blendingSpeed: number;
  28300. /**
  28301. * Stores the animation ranges for the animation
  28302. */
  28303. private _ranges;
  28304. /**
  28305. * @hidden Internal use
  28306. */
  28307. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28308. /**
  28309. * Sets up an animation
  28310. * @param property The property to animate
  28311. * @param animationType The animation type to apply
  28312. * @param framePerSecond The frames per second of the animation
  28313. * @param easingFunction The easing function used in the animation
  28314. * @returns The created animation
  28315. */
  28316. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28317. /**
  28318. * Create and start an animation on a node
  28319. * @param name defines the name of the global animation that will be run on all nodes
  28320. * @param node defines the root node where the animation will take place
  28321. * @param targetProperty defines property to animate
  28322. * @param framePerSecond defines the number of frame per second yo use
  28323. * @param totalFrame defines the number of frames in total
  28324. * @param from defines the initial value
  28325. * @param to defines the final value
  28326. * @param loopMode defines which loop mode you want to use (off by default)
  28327. * @param easingFunction defines the easing function to use (linear by default)
  28328. * @param onAnimationEnd defines the callback to call when animation end
  28329. * @returns the animatable created for this animation
  28330. */
  28331. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28332. /**
  28333. * Create and start an animation on a node and its descendants
  28334. * @param name defines the name of the global animation that will be run on all nodes
  28335. * @param node defines the root node where the animation will take place
  28336. * @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
  28337. * @param targetProperty defines property to animate
  28338. * @param framePerSecond defines the number of frame per second to use
  28339. * @param totalFrame defines the number of frames in total
  28340. * @param from defines the initial value
  28341. * @param to defines the final value
  28342. * @param loopMode defines which loop mode you want to use (off by default)
  28343. * @param easingFunction defines the easing function to use (linear by default)
  28344. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28345. * @returns the list of animatables created for all nodes
  28346. * @example https://www.babylonjs-playground.com/#MH0VLI
  28347. */
  28348. 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[]>;
  28349. /**
  28350. * Creates a new animation, merges it with the existing animations and starts it
  28351. * @param name Name of the animation
  28352. * @param node Node which contains the scene that begins the animations
  28353. * @param targetProperty Specifies which property to animate
  28354. * @param framePerSecond The frames per second of the animation
  28355. * @param totalFrame The total number of frames
  28356. * @param from The frame at the beginning of the animation
  28357. * @param to The frame at the end of the animation
  28358. * @param loopMode Specifies the loop mode of the animation
  28359. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28360. * @param onAnimationEnd Callback to run once the animation is complete
  28361. * @returns Nullable animation
  28362. */
  28363. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28364. /**
  28365. * Transition property of an host to the target Value
  28366. * @param property The property to transition
  28367. * @param targetValue The target Value of the property
  28368. * @param host The object where the property to animate belongs
  28369. * @param scene Scene used to run the animation
  28370. * @param frameRate Framerate (in frame/s) to use
  28371. * @param transition The transition type we want to use
  28372. * @param duration The duration of the animation, in milliseconds
  28373. * @param onAnimationEnd Callback trigger at the end of the animation
  28374. * @returns Nullable animation
  28375. */
  28376. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28377. /**
  28378. * Return the array of runtime animations currently using this animation
  28379. */
  28380. readonly runtimeAnimations: RuntimeAnimation[];
  28381. /**
  28382. * Specifies if any of the runtime animations are currently running
  28383. */
  28384. readonly hasRunningRuntimeAnimations: boolean;
  28385. /**
  28386. * Initializes the animation
  28387. * @param name Name of the animation
  28388. * @param targetProperty Property to animate
  28389. * @param framePerSecond The frames per second of the animation
  28390. * @param dataType The data type of the animation
  28391. * @param loopMode The loop mode of the animation
  28392. * @param enableBlending Specifies if blending should be enabled
  28393. */
  28394. constructor(
  28395. /**Name of the animation */
  28396. name: string,
  28397. /**Property to animate */
  28398. targetProperty: string,
  28399. /**The frames per second of the animation */
  28400. framePerSecond: number,
  28401. /**The data type of the animation */
  28402. dataType: number,
  28403. /**The loop mode of the animation */
  28404. loopMode?: number | undefined,
  28405. /**Specifies if blending should be enabled */
  28406. enableBlending?: boolean | undefined);
  28407. /**
  28408. * Converts the animation to a string
  28409. * @param fullDetails support for multiple levels of logging within scene loading
  28410. * @returns String form of the animation
  28411. */
  28412. toString(fullDetails?: boolean): string;
  28413. /**
  28414. * Add an event to this animation
  28415. * @param event Event to add
  28416. */
  28417. addEvent(event: AnimationEvent): void;
  28418. /**
  28419. * Remove all events found at the given frame
  28420. * @param frame The frame to remove events from
  28421. */
  28422. removeEvents(frame: number): void;
  28423. /**
  28424. * Retrieves all the events from the animation
  28425. * @returns Events from the animation
  28426. */
  28427. getEvents(): AnimationEvent[];
  28428. /**
  28429. * Creates an animation range
  28430. * @param name Name of the animation range
  28431. * @param from Starting frame of the animation range
  28432. * @param to Ending frame of the animation
  28433. */
  28434. createRange(name: string, from: number, to: number): void;
  28435. /**
  28436. * Deletes an animation range by name
  28437. * @param name Name of the animation range to delete
  28438. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28439. */
  28440. deleteRange(name: string, deleteFrames?: boolean): void;
  28441. /**
  28442. * Gets the animation range by name, or null if not defined
  28443. * @param name Name of the animation range
  28444. * @returns Nullable animation range
  28445. */
  28446. getRange(name: string): Nullable<AnimationRange>;
  28447. /**
  28448. * Gets the key frames from the animation
  28449. * @returns The key frames of the animation
  28450. */
  28451. getKeys(): Array<IAnimationKey>;
  28452. /**
  28453. * Gets the highest frame rate of the animation
  28454. * @returns Highest frame rate of the animation
  28455. */
  28456. getHighestFrame(): number;
  28457. /**
  28458. * Gets the easing function of the animation
  28459. * @returns Easing function of the animation
  28460. */
  28461. getEasingFunction(): IEasingFunction;
  28462. /**
  28463. * Sets the easing function of the animation
  28464. * @param easingFunction A custom mathematical formula for animation
  28465. */
  28466. setEasingFunction(easingFunction: EasingFunction): void;
  28467. /**
  28468. * Interpolates a scalar linearly
  28469. * @param startValue Start value of the animation curve
  28470. * @param endValue End value of the animation curve
  28471. * @param gradient Scalar amount to interpolate
  28472. * @returns Interpolated scalar value
  28473. */
  28474. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28475. /**
  28476. * Interpolates a scalar cubically
  28477. * @param startValue Start value of the animation curve
  28478. * @param outTangent End tangent of the animation
  28479. * @param endValue End value of the animation curve
  28480. * @param inTangent Start tangent of the animation curve
  28481. * @param gradient Scalar amount to interpolate
  28482. * @returns Interpolated scalar value
  28483. */
  28484. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28485. /**
  28486. * Interpolates a quaternion using a spherical linear interpolation
  28487. * @param startValue Start value of the animation curve
  28488. * @param endValue End value of the animation curve
  28489. * @param gradient Scalar amount to interpolate
  28490. * @returns Interpolated quaternion value
  28491. */
  28492. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28493. /**
  28494. * Interpolates a quaternion cubically
  28495. * @param startValue Start value of the animation curve
  28496. * @param outTangent End tangent of the animation curve
  28497. * @param endValue End value of the animation curve
  28498. * @param inTangent Start tangent of the animation curve
  28499. * @param gradient Scalar amount to interpolate
  28500. * @returns Interpolated quaternion value
  28501. */
  28502. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28503. /**
  28504. * Interpolates a Vector3 linearl
  28505. * @param startValue Start value of the animation curve
  28506. * @param endValue End value of the animation curve
  28507. * @param gradient Scalar amount to interpolate
  28508. * @returns Interpolated scalar value
  28509. */
  28510. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28511. /**
  28512. * Interpolates a Vector3 cubically
  28513. * @param startValue Start value of the animation curve
  28514. * @param outTangent End tangent of the animation
  28515. * @param endValue End value of the animation curve
  28516. * @param inTangent Start tangent of the animation curve
  28517. * @param gradient Scalar amount to interpolate
  28518. * @returns InterpolatedVector3 value
  28519. */
  28520. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28521. /**
  28522. * Interpolates a Vector2 linearly
  28523. * @param startValue Start value of the animation curve
  28524. * @param endValue End value of the animation curve
  28525. * @param gradient Scalar amount to interpolate
  28526. * @returns Interpolated Vector2 value
  28527. */
  28528. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28529. /**
  28530. * Interpolates a Vector2 cubically
  28531. * @param startValue Start value of the animation curve
  28532. * @param outTangent End tangent of the animation
  28533. * @param endValue End value of the animation curve
  28534. * @param inTangent Start tangent of the animation curve
  28535. * @param gradient Scalar amount to interpolate
  28536. * @returns Interpolated Vector2 value
  28537. */
  28538. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28539. /**
  28540. * Interpolates a size linearly
  28541. * @param startValue Start value of the animation curve
  28542. * @param endValue End value of the animation curve
  28543. * @param gradient Scalar amount to interpolate
  28544. * @returns Interpolated Size value
  28545. */
  28546. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28547. /**
  28548. * Interpolates a Color3 linearly
  28549. * @param startValue Start value of the animation curve
  28550. * @param endValue End value of the animation curve
  28551. * @param gradient Scalar amount to interpolate
  28552. * @returns Interpolated Color3 value
  28553. */
  28554. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28555. /**
  28556. * Interpolates a Color4 linearly
  28557. * @param startValue Start value of the animation curve
  28558. * @param endValue End value of the animation curve
  28559. * @param gradient Scalar amount to interpolate
  28560. * @returns Interpolated Color3 value
  28561. */
  28562. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28563. /**
  28564. * @hidden Internal use only
  28565. */
  28566. _getKeyValue(value: any): any;
  28567. /**
  28568. * @hidden Internal use only
  28569. */
  28570. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28571. /**
  28572. * Defines the function to use to interpolate matrices
  28573. * @param startValue defines the start matrix
  28574. * @param endValue defines the end matrix
  28575. * @param gradient defines the gradient between both matrices
  28576. * @param result defines an optional target matrix where to store the interpolation
  28577. * @returns the interpolated matrix
  28578. */
  28579. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28580. /**
  28581. * Makes a copy of the animation
  28582. * @returns Cloned animation
  28583. */
  28584. clone(): Animation;
  28585. /**
  28586. * Sets the key frames of the animation
  28587. * @param values The animation key frames to set
  28588. */
  28589. setKeys(values: Array<IAnimationKey>): void;
  28590. /**
  28591. * Serializes the animation to an object
  28592. * @returns Serialized object
  28593. */
  28594. serialize(): any;
  28595. /**
  28596. * Float animation type
  28597. */
  28598. static readonly ANIMATIONTYPE_FLOAT: number;
  28599. /**
  28600. * Vector3 animation type
  28601. */
  28602. static readonly ANIMATIONTYPE_VECTOR3: number;
  28603. /**
  28604. * Quaternion animation type
  28605. */
  28606. static readonly ANIMATIONTYPE_QUATERNION: number;
  28607. /**
  28608. * Matrix animation type
  28609. */
  28610. static readonly ANIMATIONTYPE_MATRIX: number;
  28611. /**
  28612. * Color3 animation type
  28613. */
  28614. static readonly ANIMATIONTYPE_COLOR3: number;
  28615. /**
  28616. * Color3 animation type
  28617. */
  28618. static readonly ANIMATIONTYPE_COLOR4: number;
  28619. /**
  28620. * Vector2 animation type
  28621. */
  28622. static readonly ANIMATIONTYPE_VECTOR2: number;
  28623. /**
  28624. * Size animation type
  28625. */
  28626. static readonly ANIMATIONTYPE_SIZE: number;
  28627. /**
  28628. * Relative Loop Mode
  28629. */
  28630. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28631. /**
  28632. * Cycle Loop Mode
  28633. */
  28634. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28635. /**
  28636. * Constant Loop Mode
  28637. */
  28638. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28639. /** @hidden */
  28640. static _UniversalLerp(left: any, right: any, amount: number): any;
  28641. /**
  28642. * Parses an animation object and creates an animation
  28643. * @param parsedAnimation Parsed animation object
  28644. * @returns Animation object
  28645. */
  28646. static Parse(parsedAnimation: any): Animation;
  28647. /**
  28648. * Appends the serialized animations from the source animations
  28649. * @param source Source containing the animations
  28650. * @param destination Target to store the animations
  28651. */
  28652. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28653. }
  28654. }
  28655. declare module "babylonjs/Animations/animatable.interface" {
  28656. import { Nullable } from "babylonjs/types";
  28657. import { Animation } from "babylonjs/Animations/animation";
  28658. /**
  28659. * Interface containing an array of animations
  28660. */
  28661. export interface IAnimatable {
  28662. /**
  28663. * Array of animations
  28664. */
  28665. animations: Nullable<Array<Animation>>;
  28666. }
  28667. }
  28668. declare module "babylonjs/Materials/fresnelParameters" {
  28669. import { Color3 } from "babylonjs/Maths/math.color";
  28670. /**
  28671. * This represents all the required information to add a fresnel effect on a material:
  28672. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28673. */
  28674. export class FresnelParameters {
  28675. private _isEnabled;
  28676. /**
  28677. * Define if the fresnel effect is enable or not.
  28678. */
  28679. isEnabled: boolean;
  28680. /**
  28681. * Define the color used on edges (grazing angle)
  28682. */
  28683. leftColor: Color3;
  28684. /**
  28685. * Define the color used on center
  28686. */
  28687. rightColor: Color3;
  28688. /**
  28689. * Define bias applied to computed fresnel term
  28690. */
  28691. bias: number;
  28692. /**
  28693. * Defined the power exponent applied to fresnel term
  28694. */
  28695. power: number;
  28696. /**
  28697. * Clones the current fresnel and its valuues
  28698. * @returns a clone fresnel configuration
  28699. */
  28700. clone(): FresnelParameters;
  28701. /**
  28702. * Serializes the current fresnel parameters to a JSON representation.
  28703. * @return the JSON serialization
  28704. */
  28705. serialize(): any;
  28706. /**
  28707. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28708. * @param parsedFresnelParameters Define the JSON representation
  28709. * @returns the parsed parameters
  28710. */
  28711. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28712. }
  28713. }
  28714. declare module "babylonjs/Misc/decorators" {
  28715. import { Nullable } from "babylonjs/types";
  28716. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28717. import { Scene } from "babylonjs/scene";
  28718. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28719. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28720. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28721. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28722. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28723. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28724. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28725. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28726. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28727. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28728. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28729. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28730. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28731. /**
  28732. * Decorator used to define property that can be serialized as reference to a camera
  28733. * @param sourceName defines the name of the property to decorate
  28734. */
  28735. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28736. /**
  28737. * Class used to help serialization objects
  28738. */
  28739. export class SerializationHelper {
  28740. /** @hidden */
  28741. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28742. /** @hidden */
  28743. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28744. /** @hidden */
  28745. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28746. /** @hidden */
  28747. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28748. /**
  28749. * Appends the serialized animations from the source animations
  28750. * @param source Source containing the animations
  28751. * @param destination Target to store the animations
  28752. */
  28753. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28754. /**
  28755. * Static function used to serialized a specific entity
  28756. * @param entity defines the entity to serialize
  28757. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28758. * @returns a JSON compatible object representing the serialization of the entity
  28759. */
  28760. static Serialize<T>(entity: T, serializationObject?: any): any;
  28761. /**
  28762. * Creates a new entity from a serialization data object
  28763. * @param creationFunction defines a function used to instanciated the new entity
  28764. * @param source defines the source serialization data
  28765. * @param scene defines the hosting scene
  28766. * @param rootUrl defines the root url for resources
  28767. * @returns a new entity
  28768. */
  28769. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28770. /**
  28771. * Clones an object
  28772. * @param creationFunction defines the function used to instanciate the new object
  28773. * @param source defines the source object
  28774. * @returns the cloned object
  28775. */
  28776. static Clone<T>(creationFunction: () => T, source: T): T;
  28777. /**
  28778. * Instanciates a new object based on a source one (some data will be shared between both object)
  28779. * @param creationFunction defines the function used to instanciate the new object
  28780. * @param source defines the source object
  28781. * @returns the new object
  28782. */
  28783. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28784. }
  28785. }
  28786. declare module "babylonjs/Misc/guid" {
  28787. /**
  28788. * Class used to manipulate GUIDs
  28789. */
  28790. export class GUID {
  28791. /**
  28792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28793. * Be aware Math.random() could cause collisions, but:
  28794. * "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"
  28795. * @returns a pseudo random id
  28796. */
  28797. static RandomId(): string;
  28798. }
  28799. }
  28800. declare module "babylonjs/Materials/Textures/baseTexture" {
  28801. import { Observable } from "babylonjs/Misc/observable";
  28802. import { Nullable } from "babylonjs/types";
  28803. import { Scene } from "babylonjs/scene";
  28804. import { Matrix } from "babylonjs/Maths/math.vector";
  28805. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28806. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28807. import { ISize } from "babylonjs/Maths/math.size";
  28808. /**
  28809. * Base class of all the textures in babylon.
  28810. * It groups all the common properties the materials, post process, lights... might need
  28811. * in order to make a correct use of the texture.
  28812. */
  28813. export class BaseTexture implements IAnimatable {
  28814. /**
  28815. * Default anisotropic filtering level for the application.
  28816. * It is set to 4 as a good tradeoff between perf and quality.
  28817. */
  28818. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28819. /**
  28820. * Gets or sets the unique id of the texture
  28821. */
  28822. uniqueId: number;
  28823. /**
  28824. * Define the name of the texture.
  28825. */
  28826. name: string;
  28827. /**
  28828. * Gets or sets an object used to store user defined information.
  28829. */
  28830. metadata: any;
  28831. /**
  28832. * For internal use only. Please do not use.
  28833. */
  28834. reservedDataStore: any;
  28835. private _hasAlpha;
  28836. /**
  28837. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28838. */
  28839. hasAlpha: boolean;
  28840. /**
  28841. * Defines if the alpha value should be determined via the rgb values.
  28842. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28843. */
  28844. getAlphaFromRGB: boolean;
  28845. /**
  28846. * Intensity or strength of the texture.
  28847. * It is commonly used by materials to fine tune the intensity of the texture
  28848. */
  28849. level: number;
  28850. /**
  28851. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28852. * This is part of the texture as textures usually maps to one uv set.
  28853. */
  28854. coordinatesIndex: number;
  28855. private _coordinatesMode;
  28856. /**
  28857. * How a texture is mapped.
  28858. *
  28859. * | Value | Type | Description |
  28860. * | ----- | ----------------------------------- | ----------- |
  28861. * | 0 | EXPLICIT_MODE | |
  28862. * | 1 | SPHERICAL_MODE | |
  28863. * | 2 | PLANAR_MODE | |
  28864. * | 3 | CUBIC_MODE | |
  28865. * | 4 | PROJECTION_MODE | |
  28866. * | 5 | SKYBOX_MODE | |
  28867. * | 6 | INVCUBIC_MODE | |
  28868. * | 7 | EQUIRECTANGULAR_MODE | |
  28869. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28870. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28871. */
  28872. coordinatesMode: number;
  28873. /**
  28874. * | Value | Type | Description |
  28875. * | ----- | ------------------ | ----------- |
  28876. * | 0 | CLAMP_ADDRESSMODE | |
  28877. * | 1 | WRAP_ADDRESSMODE | |
  28878. * | 2 | MIRROR_ADDRESSMODE | |
  28879. */
  28880. wrapU: number;
  28881. /**
  28882. * | Value | Type | Description |
  28883. * | ----- | ------------------ | ----------- |
  28884. * | 0 | CLAMP_ADDRESSMODE | |
  28885. * | 1 | WRAP_ADDRESSMODE | |
  28886. * | 2 | MIRROR_ADDRESSMODE | |
  28887. */
  28888. wrapV: number;
  28889. /**
  28890. * | Value | Type | Description |
  28891. * | ----- | ------------------ | ----------- |
  28892. * | 0 | CLAMP_ADDRESSMODE | |
  28893. * | 1 | WRAP_ADDRESSMODE | |
  28894. * | 2 | MIRROR_ADDRESSMODE | |
  28895. */
  28896. wrapR: number;
  28897. /**
  28898. * With compliant hardware and browser (supporting anisotropic filtering)
  28899. * this defines the level of anisotropic filtering in the texture.
  28900. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28901. */
  28902. anisotropicFilteringLevel: number;
  28903. /**
  28904. * Define if the texture is a cube texture or if false a 2d texture.
  28905. */
  28906. isCube: boolean;
  28907. /**
  28908. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28909. */
  28910. is3D: boolean;
  28911. /**
  28912. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28913. */
  28914. is2DArray: boolean;
  28915. /**
  28916. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28917. * HDR texture are usually stored in linear space.
  28918. * This only impacts the PBR and Background materials
  28919. */
  28920. gammaSpace: boolean;
  28921. /**
  28922. * Gets or sets whether or not the texture contains RGBD data.
  28923. */
  28924. isRGBD: boolean;
  28925. /**
  28926. * Is Z inverted in the texture (useful in a cube texture).
  28927. */
  28928. invertZ: boolean;
  28929. /**
  28930. * Are mip maps generated for this texture or not.
  28931. */
  28932. readonly noMipmap: boolean;
  28933. /**
  28934. * @hidden
  28935. */
  28936. lodLevelInAlpha: boolean;
  28937. /**
  28938. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28939. */
  28940. lodGenerationOffset: number;
  28941. /**
  28942. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28943. */
  28944. lodGenerationScale: number;
  28945. /**
  28946. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28947. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28948. * average roughness values.
  28949. */
  28950. linearSpecularLOD: boolean;
  28951. /**
  28952. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28953. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28954. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28955. */
  28956. irradianceTexture: Nullable<BaseTexture>;
  28957. /**
  28958. * Define if the texture is a render target.
  28959. */
  28960. isRenderTarget: boolean;
  28961. /**
  28962. * Define the unique id of the texture in the scene.
  28963. */
  28964. readonly uid: string;
  28965. /**
  28966. * Return a string representation of the texture.
  28967. * @returns the texture as a string
  28968. */
  28969. toString(): string;
  28970. /**
  28971. * Get the class name of the texture.
  28972. * @returns "BaseTexture"
  28973. */
  28974. getClassName(): string;
  28975. /**
  28976. * Define the list of animation attached to the texture.
  28977. */
  28978. animations: import("babylonjs/Animations/animation").Animation[];
  28979. /**
  28980. * An event triggered when the texture is disposed.
  28981. */
  28982. onDisposeObservable: Observable<BaseTexture>;
  28983. private _onDisposeObserver;
  28984. /**
  28985. * Callback triggered when the texture has been disposed.
  28986. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28987. */
  28988. onDispose: () => void;
  28989. /**
  28990. * Define the current state of the loading sequence when in delayed load mode.
  28991. */
  28992. delayLoadState: number;
  28993. private _scene;
  28994. /** @hidden */
  28995. _texture: Nullable<InternalTexture>;
  28996. private _uid;
  28997. /**
  28998. * Define if the texture is preventinga material to render or not.
  28999. * If not and the texture is not ready, the engine will use a default black texture instead.
  29000. */
  29001. readonly isBlocking: boolean;
  29002. /**
  29003. * Instantiates a new BaseTexture.
  29004. * Base class of all the textures in babylon.
  29005. * It groups all the common properties the materials, post process, lights... might need
  29006. * in order to make a correct use of the texture.
  29007. * @param scene Define the scene the texture blongs to
  29008. */
  29009. constructor(scene: Nullable<Scene>);
  29010. /**
  29011. * Get the scene the texture belongs to.
  29012. * @returns the scene or null if undefined
  29013. */
  29014. getScene(): Nullable<Scene>;
  29015. /**
  29016. * Get the texture transform matrix used to offset tile the texture for istance.
  29017. * @returns the transformation matrix
  29018. */
  29019. getTextureMatrix(): Matrix;
  29020. /**
  29021. * Get the texture reflection matrix used to rotate/transform the reflection.
  29022. * @returns the reflection matrix
  29023. */
  29024. getReflectionTextureMatrix(): Matrix;
  29025. /**
  29026. * Get the underlying lower level texture from Babylon.
  29027. * @returns the insternal texture
  29028. */
  29029. getInternalTexture(): Nullable<InternalTexture>;
  29030. /**
  29031. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29032. * @returns true if ready or not blocking
  29033. */
  29034. isReadyOrNotBlocking(): boolean;
  29035. /**
  29036. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29037. * @returns true if fully ready
  29038. */
  29039. isReady(): boolean;
  29040. private _cachedSize;
  29041. /**
  29042. * Get the size of the texture.
  29043. * @returns the texture size.
  29044. */
  29045. getSize(): ISize;
  29046. /**
  29047. * Get the base size of the texture.
  29048. * It can be different from the size if the texture has been resized for POT for instance
  29049. * @returns the base size
  29050. */
  29051. getBaseSize(): ISize;
  29052. /**
  29053. * Update the sampling mode of the texture.
  29054. * Default is Trilinear mode.
  29055. *
  29056. * | Value | Type | Description |
  29057. * | ----- | ------------------ | ----------- |
  29058. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29059. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29060. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29061. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29062. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29063. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29064. * | 7 | NEAREST_LINEAR | |
  29065. * | 8 | NEAREST_NEAREST | |
  29066. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29067. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29068. * | 11 | LINEAR_LINEAR | |
  29069. * | 12 | LINEAR_NEAREST | |
  29070. *
  29071. * > _mag_: magnification filter (close to the viewer)
  29072. * > _min_: minification filter (far from the viewer)
  29073. * > _mip_: filter used between mip map levels
  29074. *@param samplingMode Define the new sampling mode of the texture
  29075. */
  29076. updateSamplingMode(samplingMode: number): void;
  29077. /**
  29078. * Scales the texture if is `canRescale()`
  29079. * @param ratio the resize factor we want to use to rescale
  29080. */
  29081. scale(ratio: number): void;
  29082. /**
  29083. * Get if the texture can rescale.
  29084. */
  29085. readonly canRescale: boolean;
  29086. /** @hidden */
  29087. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29088. /** @hidden */
  29089. _rebuild(): void;
  29090. /**
  29091. * Triggers the load sequence in delayed load mode.
  29092. */
  29093. delayLoad(): void;
  29094. /**
  29095. * Clones the texture.
  29096. * @returns the cloned texture
  29097. */
  29098. clone(): Nullable<BaseTexture>;
  29099. /**
  29100. * Get the texture underlying type (INT, FLOAT...)
  29101. */
  29102. readonly textureType: number;
  29103. /**
  29104. * Get the texture underlying format (RGB, RGBA...)
  29105. */
  29106. readonly textureFormat: number;
  29107. /**
  29108. * Indicates that textures need to be re-calculated for all materials
  29109. */
  29110. protected _markAllSubMeshesAsTexturesDirty(): void;
  29111. /**
  29112. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29113. * This will returns an RGBA array buffer containing either in values (0-255) or
  29114. * float values (0-1) depending of the underlying buffer type.
  29115. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29116. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29117. * @param buffer defines a user defined buffer to fill with data (can be null)
  29118. * @returns The Array buffer containing the pixels data.
  29119. */
  29120. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29121. /**
  29122. * Release and destroy the underlying lower level texture aka internalTexture.
  29123. */
  29124. releaseInternalTexture(): void;
  29125. /** @hidden */
  29126. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29127. /** @hidden */
  29128. readonly _lodTextureMid: Nullable<BaseTexture>;
  29129. /** @hidden */
  29130. readonly _lodTextureLow: Nullable<BaseTexture>;
  29131. /**
  29132. * Dispose the texture and release its associated resources.
  29133. */
  29134. dispose(): void;
  29135. /**
  29136. * Serialize the texture into a JSON representation that can be parsed later on.
  29137. * @returns the JSON representation of the texture
  29138. */
  29139. serialize(): any;
  29140. /**
  29141. * Helper function to be called back once a list of texture contains only ready textures.
  29142. * @param textures Define the list of textures to wait for
  29143. * @param callback Define the callback triggered once the entire list will be ready
  29144. */
  29145. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29146. }
  29147. }
  29148. declare module "babylonjs/Materials/effect" {
  29149. import { Observable } from "babylonjs/Misc/observable";
  29150. import { Nullable } from "babylonjs/types";
  29151. import { IDisposable } from "babylonjs/scene";
  29152. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29153. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29154. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29155. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29156. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29157. import { Engine } from "babylonjs/Engines/engine";
  29158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29160. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29162. /**
  29163. * Options to be used when creating an effect.
  29164. */
  29165. export interface IEffectCreationOptions {
  29166. /**
  29167. * Atrributes that will be used in the shader.
  29168. */
  29169. attributes: string[];
  29170. /**
  29171. * Uniform varible names that will be set in the shader.
  29172. */
  29173. uniformsNames: string[];
  29174. /**
  29175. * Uniform buffer varible names that will be set in the shader.
  29176. */
  29177. uniformBuffersNames: string[];
  29178. /**
  29179. * Sampler texture variable names that will be set in the shader.
  29180. */
  29181. samplers: string[];
  29182. /**
  29183. * Define statements that will be set in the shader.
  29184. */
  29185. defines: any;
  29186. /**
  29187. * Possible fallbacks for this effect to improve performance when needed.
  29188. */
  29189. fallbacks: Nullable<IEffectFallbacks>;
  29190. /**
  29191. * Callback that will be called when the shader is compiled.
  29192. */
  29193. onCompiled: Nullable<(effect: Effect) => void>;
  29194. /**
  29195. * Callback that will be called if an error occurs during shader compilation.
  29196. */
  29197. onError: Nullable<(effect: Effect, errors: string) => void>;
  29198. /**
  29199. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29200. */
  29201. indexParameters?: any;
  29202. /**
  29203. * Max number of lights that can be used in the shader.
  29204. */
  29205. maxSimultaneousLights?: number;
  29206. /**
  29207. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29208. */
  29209. transformFeedbackVaryings?: Nullable<string[]>;
  29210. }
  29211. /**
  29212. * Effect containing vertex and fragment shader that can be executed on an object.
  29213. */
  29214. export class Effect implements IDisposable {
  29215. /**
  29216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29217. */
  29218. static ShadersRepository: string;
  29219. /**
  29220. * Name of the effect.
  29221. */
  29222. name: any;
  29223. /**
  29224. * String container all the define statements that should be set on the shader.
  29225. */
  29226. defines: string;
  29227. /**
  29228. * Callback that will be called when the shader is compiled.
  29229. */
  29230. onCompiled: Nullable<(effect: Effect) => void>;
  29231. /**
  29232. * Callback that will be called if an error occurs during shader compilation.
  29233. */
  29234. onError: Nullable<(effect: Effect, errors: string) => void>;
  29235. /**
  29236. * Callback that will be called when effect is bound.
  29237. */
  29238. onBind: Nullable<(effect: Effect) => void>;
  29239. /**
  29240. * Unique ID of the effect.
  29241. */
  29242. uniqueId: number;
  29243. /**
  29244. * Observable that will be called when the shader is compiled.
  29245. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29246. */
  29247. onCompileObservable: Observable<Effect>;
  29248. /**
  29249. * Observable that will be called if an error occurs during shader compilation.
  29250. */
  29251. onErrorObservable: Observable<Effect>;
  29252. /** @hidden */
  29253. _onBindObservable: Nullable<Observable<Effect>>;
  29254. /**
  29255. * Observable that will be called when effect is bound.
  29256. */
  29257. readonly onBindObservable: Observable<Effect>;
  29258. /** @hidden */
  29259. _bonesComputationForcedToCPU: boolean;
  29260. private static _uniqueIdSeed;
  29261. private _engine;
  29262. private _uniformBuffersNames;
  29263. private _uniformsNames;
  29264. private _samplerList;
  29265. private _samplers;
  29266. private _isReady;
  29267. private _compilationError;
  29268. private _allFallbacksProcessed;
  29269. private _attributesNames;
  29270. private _attributes;
  29271. private _uniforms;
  29272. /**
  29273. * Key for the effect.
  29274. * @hidden
  29275. */
  29276. _key: string;
  29277. private _indexParameters;
  29278. private _fallbacks;
  29279. private _vertexSourceCode;
  29280. private _fragmentSourceCode;
  29281. private _vertexSourceCodeOverride;
  29282. private _fragmentSourceCodeOverride;
  29283. private _transformFeedbackVaryings;
  29284. /**
  29285. * Compiled shader to webGL program.
  29286. * @hidden
  29287. */
  29288. _pipelineContext: Nullable<IPipelineContext>;
  29289. private _valueCache;
  29290. private static _baseCache;
  29291. /**
  29292. * Instantiates an effect.
  29293. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29294. * @param baseName Name of the effect.
  29295. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29296. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29297. * @param samplers List of sampler variables that will be passed to the shader.
  29298. * @param engine Engine to be used to render the effect
  29299. * @param defines Define statements to be added to the shader.
  29300. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29301. * @param onCompiled Callback that will be called when the shader is compiled.
  29302. * @param onError Callback that will be called if an error occurs during shader compilation.
  29303. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29304. */
  29305. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29306. private _useFinalCode;
  29307. /**
  29308. * Unique key for this effect
  29309. */
  29310. readonly key: string;
  29311. /**
  29312. * If the effect has been compiled and prepared.
  29313. * @returns if the effect is compiled and prepared.
  29314. */
  29315. isReady(): boolean;
  29316. private _isReadyInternal;
  29317. /**
  29318. * The engine the effect was initialized with.
  29319. * @returns the engine.
  29320. */
  29321. getEngine(): Engine;
  29322. /**
  29323. * The pipeline context for this effect
  29324. * @returns the associated pipeline context
  29325. */
  29326. getPipelineContext(): Nullable<IPipelineContext>;
  29327. /**
  29328. * The set of names of attribute variables for the shader.
  29329. * @returns An array of attribute names.
  29330. */
  29331. getAttributesNames(): string[];
  29332. /**
  29333. * Returns the attribute at the given index.
  29334. * @param index The index of the attribute.
  29335. * @returns The location of the attribute.
  29336. */
  29337. getAttributeLocation(index: number): number;
  29338. /**
  29339. * Returns the attribute based on the name of the variable.
  29340. * @param name of the attribute to look up.
  29341. * @returns the attribute location.
  29342. */
  29343. getAttributeLocationByName(name: string): number;
  29344. /**
  29345. * The number of attributes.
  29346. * @returns the numnber of attributes.
  29347. */
  29348. getAttributesCount(): number;
  29349. /**
  29350. * Gets the index of a uniform variable.
  29351. * @param uniformName of the uniform to look up.
  29352. * @returns the index.
  29353. */
  29354. getUniformIndex(uniformName: string): number;
  29355. /**
  29356. * Returns the attribute based on the name of the variable.
  29357. * @param uniformName of the uniform to look up.
  29358. * @returns the location of the uniform.
  29359. */
  29360. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29361. /**
  29362. * Returns an array of sampler variable names
  29363. * @returns The array of sampler variable neames.
  29364. */
  29365. getSamplers(): string[];
  29366. /**
  29367. * The error from the last compilation.
  29368. * @returns the error string.
  29369. */
  29370. getCompilationError(): string;
  29371. /**
  29372. * Gets a boolean indicating that all fallbacks were used during compilation
  29373. * @returns true if all fallbacks were used
  29374. */
  29375. allFallbacksProcessed(): boolean;
  29376. /**
  29377. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29378. * @param func The callback to be used.
  29379. */
  29380. executeWhenCompiled(func: (effect: Effect) => void): void;
  29381. private _checkIsReady;
  29382. private _loadShader;
  29383. /**
  29384. * Recompiles the webGL program
  29385. * @param vertexSourceCode The source code for the vertex shader.
  29386. * @param fragmentSourceCode The source code for the fragment shader.
  29387. * @param onCompiled Callback called when completed.
  29388. * @param onError Callback called on error.
  29389. * @hidden
  29390. */
  29391. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29392. /**
  29393. * Prepares the effect
  29394. * @hidden
  29395. */
  29396. _prepareEffect(): void;
  29397. private _processCompilationErrors;
  29398. /**
  29399. * Checks if the effect is supported. (Must be called after compilation)
  29400. */
  29401. readonly isSupported: boolean;
  29402. /**
  29403. * Binds a texture to the engine to be used as output of the shader.
  29404. * @param channel Name of the output variable.
  29405. * @param texture Texture to bind.
  29406. * @hidden
  29407. */
  29408. _bindTexture(channel: string, texture: InternalTexture): void;
  29409. /**
  29410. * Sets a texture on the engine to be used in the shader.
  29411. * @param channel Name of the sampler variable.
  29412. * @param texture Texture to set.
  29413. */
  29414. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29415. /**
  29416. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29417. * @param channel Name of the sampler variable.
  29418. * @param texture Texture to set.
  29419. */
  29420. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29421. /**
  29422. * Sets an array of textures on the engine to be used in the shader.
  29423. * @param channel Name of the variable.
  29424. * @param textures Textures to set.
  29425. */
  29426. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29427. /**
  29428. * 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)
  29429. * @param channel Name of the sampler variable.
  29430. * @param postProcess Post process to get the input texture from.
  29431. */
  29432. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29433. /**
  29434. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29435. * 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)
  29436. * @param channel Name of the sampler variable.
  29437. * @param postProcess Post process to get the output texture from.
  29438. */
  29439. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29440. /** @hidden */
  29441. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29442. /** @hidden */
  29443. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29444. /** @hidden */
  29445. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29446. /** @hidden */
  29447. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29448. /**
  29449. * Binds a buffer to a uniform.
  29450. * @param buffer Buffer to bind.
  29451. * @param name Name of the uniform variable to bind to.
  29452. */
  29453. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29454. /**
  29455. * Binds block to a uniform.
  29456. * @param blockName Name of the block to bind.
  29457. * @param index Index to bind.
  29458. */
  29459. bindUniformBlock(blockName: string, index: number): void;
  29460. /**
  29461. * Sets an interger value on a uniform variable.
  29462. * @param uniformName Name of the variable.
  29463. * @param value Value to be set.
  29464. * @returns this effect.
  29465. */
  29466. setInt(uniformName: string, value: number): Effect;
  29467. /**
  29468. * Sets an int array on a uniform variable.
  29469. * @param uniformName Name of the variable.
  29470. * @param array array to be set.
  29471. * @returns this effect.
  29472. */
  29473. setIntArray(uniformName: string, array: Int32Array): Effect;
  29474. /**
  29475. * 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)
  29476. * @param uniformName Name of the variable.
  29477. * @param array array to be set.
  29478. * @returns this effect.
  29479. */
  29480. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29481. /**
  29482. * 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)
  29483. * @param uniformName Name of the variable.
  29484. * @param array array to be set.
  29485. * @returns this effect.
  29486. */
  29487. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29488. /**
  29489. * 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)
  29490. * @param uniformName Name of the variable.
  29491. * @param array array to be set.
  29492. * @returns this effect.
  29493. */
  29494. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29495. /**
  29496. * Sets an float array on a uniform variable.
  29497. * @param uniformName Name of the variable.
  29498. * @param array array to be set.
  29499. * @returns this effect.
  29500. */
  29501. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29502. /**
  29503. * 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)
  29504. * @param uniformName Name of the variable.
  29505. * @param array array to be set.
  29506. * @returns this effect.
  29507. */
  29508. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29509. /**
  29510. * 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)
  29511. * @param uniformName Name of the variable.
  29512. * @param array array to be set.
  29513. * @returns this effect.
  29514. */
  29515. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29516. /**
  29517. * 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)
  29518. * @param uniformName Name of the variable.
  29519. * @param array array to be set.
  29520. * @returns this effect.
  29521. */
  29522. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29523. /**
  29524. * Sets an array on a uniform variable.
  29525. * @param uniformName Name of the variable.
  29526. * @param array array to be set.
  29527. * @returns this effect.
  29528. */
  29529. setArray(uniformName: string, array: number[]): Effect;
  29530. /**
  29531. * 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)
  29532. * @param uniformName Name of the variable.
  29533. * @param array array to be set.
  29534. * @returns this effect.
  29535. */
  29536. setArray2(uniformName: string, array: number[]): Effect;
  29537. /**
  29538. * 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)
  29539. * @param uniformName Name of the variable.
  29540. * @param array array to be set.
  29541. * @returns this effect.
  29542. */
  29543. setArray3(uniformName: string, array: number[]): Effect;
  29544. /**
  29545. * 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)
  29546. * @param uniformName Name of the variable.
  29547. * @param array array to be set.
  29548. * @returns this effect.
  29549. */
  29550. setArray4(uniformName: string, array: number[]): Effect;
  29551. /**
  29552. * Sets matrices on a uniform variable.
  29553. * @param uniformName Name of the variable.
  29554. * @param matrices matrices to be set.
  29555. * @returns this effect.
  29556. */
  29557. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29558. /**
  29559. * Sets matrix on a uniform variable.
  29560. * @param uniformName Name of the variable.
  29561. * @param matrix matrix to be set.
  29562. * @returns this effect.
  29563. */
  29564. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29565. /**
  29566. * 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)
  29567. * @param uniformName Name of the variable.
  29568. * @param matrix matrix to be set.
  29569. * @returns this effect.
  29570. */
  29571. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29572. /**
  29573. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29574. * @param uniformName Name of the variable.
  29575. * @param matrix matrix to be set.
  29576. * @returns this effect.
  29577. */
  29578. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29579. /**
  29580. * Sets a float on a uniform variable.
  29581. * @param uniformName Name of the variable.
  29582. * @param value value to be set.
  29583. * @returns this effect.
  29584. */
  29585. setFloat(uniformName: string, value: number): Effect;
  29586. /**
  29587. * Sets a boolean on a uniform variable.
  29588. * @param uniformName Name of the variable.
  29589. * @param bool value to be set.
  29590. * @returns this effect.
  29591. */
  29592. setBool(uniformName: string, bool: boolean): Effect;
  29593. /**
  29594. * Sets a Vector2 on a uniform variable.
  29595. * @param uniformName Name of the variable.
  29596. * @param vector2 vector2 to be set.
  29597. * @returns this effect.
  29598. */
  29599. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29600. /**
  29601. * Sets a float2 on a uniform variable.
  29602. * @param uniformName Name of the variable.
  29603. * @param x First float in float2.
  29604. * @param y Second float in float2.
  29605. * @returns this effect.
  29606. */
  29607. setFloat2(uniformName: string, x: number, y: number): Effect;
  29608. /**
  29609. * Sets a Vector3 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param vector3 Value to be set.
  29612. * @returns this effect.
  29613. */
  29614. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29615. /**
  29616. * Sets a float3 on a uniform variable.
  29617. * @param uniformName Name of the variable.
  29618. * @param x First float in float3.
  29619. * @param y Second float in float3.
  29620. * @param z Third float in float3.
  29621. * @returns this effect.
  29622. */
  29623. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29624. /**
  29625. * Sets a Vector4 on a uniform variable.
  29626. * @param uniformName Name of the variable.
  29627. * @param vector4 Value to be set.
  29628. * @returns this effect.
  29629. */
  29630. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29631. /**
  29632. * Sets a float4 on a uniform variable.
  29633. * @param uniformName Name of the variable.
  29634. * @param x First float in float4.
  29635. * @param y Second float in float4.
  29636. * @param z Third float in float4.
  29637. * @param w Fourth float in float4.
  29638. * @returns this effect.
  29639. */
  29640. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29641. /**
  29642. * Sets a Color3 on a uniform variable.
  29643. * @param uniformName Name of the variable.
  29644. * @param color3 Value to be set.
  29645. * @returns this effect.
  29646. */
  29647. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29648. /**
  29649. * Sets a Color4 on a uniform variable.
  29650. * @param uniformName Name of the variable.
  29651. * @param color3 Value to be set.
  29652. * @param alpha Alpha value to be set.
  29653. * @returns this effect.
  29654. */
  29655. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29656. /**
  29657. * Sets a Color4 on a uniform variable
  29658. * @param uniformName defines the name of the variable
  29659. * @param color4 defines the value to be set
  29660. * @returns this effect.
  29661. */
  29662. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29663. /** Release all associated resources */
  29664. dispose(): void;
  29665. /**
  29666. * This function will add a new shader to the shader store
  29667. * @param name the name of the shader
  29668. * @param pixelShader optional pixel shader content
  29669. * @param vertexShader optional vertex shader content
  29670. */
  29671. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29672. /**
  29673. * Store of each shader (The can be looked up using effect.key)
  29674. */
  29675. static ShadersStore: {
  29676. [key: string]: string;
  29677. };
  29678. /**
  29679. * Store of each included file for a shader (The can be looked up using effect.key)
  29680. */
  29681. static IncludesShadersStore: {
  29682. [key: string]: string;
  29683. };
  29684. /**
  29685. * Resets the cache of effects.
  29686. */
  29687. static ResetCache(): void;
  29688. }
  29689. }
  29690. declare module "babylonjs/Engines/engineCapabilities" {
  29691. /**
  29692. * Interface used to describe the capabilities of the engine relatively to the current browser
  29693. */
  29694. export interface EngineCapabilities {
  29695. /** Maximum textures units per fragment shader */
  29696. maxTexturesImageUnits: number;
  29697. /** Maximum texture units per vertex shader */
  29698. maxVertexTextureImageUnits: number;
  29699. /** Maximum textures units in the entire pipeline */
  29700. maxCombinedTexturesImageUnits: number;
  29701. /** Maximum texture size */
  29702. maxTextureSize: number;
  29703. /** Maximum cube texture size */
  29704. maxCubemapTextureSize: number;
  29705. /** Maximum render texture size */
  29706. maxRenderTextureSize: number;
  29707. /** Maximum number of vertex attributes */
  29708. maxVertexAttribs: number;
  29709. /** Maximum number of varyings */
  29710. maxVaryingVectors: number;
  29711. /** Maximum number of uniforms per vertex shader */
  29712. maxVertexUniformVectors: number;
  29713. /** Maximum number of uniforms per fragment shader */
  29714. maxFragmentUniformVectors: number;
  29715. /** Defines if standard derivates (dx/dy) are supported */
  29716. standardDerivatives: boolean;
  29717. /** Defines if s3tc texture compression is supported */
  29718. s3tc?: WEBGL_compressed_texture_s3tc;
  29719. /** Defines if pvrtc texture compression is supported */
  29720. pvrtc: any;
  29721. /** Defines if etc1 texture compression is supported */
  29722. etc1: any;
  29723. /** Defines if etc2 texture compression is supported */
  29724. etc2: any;
  29725. /** Defines if astc texture compression is supported */
  29726. astc: any;
  29727. /** Defines if float textures are supported */
  29728. textureFloat: boolean;
  29729. /** Defines if vertex array objects are supported */
  29730. vertexArrayObject: boolean;
  29731. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29732. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29733. /** Gets the maximum level of anisotropy supported */
  29734. maxAnisotropy: number;
  29735. /** Defines if instancing is supported */
  29736. instancedArrays: boolean;
  29737. /** Defines if 32 bits indices are supported */
  29738. uintIndices: boolean;
  29739. /** Defines if high precision shaders are supported */
  29740. highPrecisionShaderSupported: boolean;
  29741. /** Defines if depth reading in the fragment shader is supported */
  29742. fragmentDepthSupported: boolean;
  29743. /** Defines if float texture linear filtering is supported*/
  29744. textureFloatLinearFiltering: boolean;
  29745. /** Defines if rendering to float textures is supported */
  29746. textureFloatRender: boolean;
  29747. /** Defines if half float textures are supported*/
  29748. textureHalfFloat: boolean;
  29749. /** Defines if half float texture linear filtering is supported*/
  29750. textureHalfFloatLinearFiltering: boolean;
  29751. /** Defines if rendering to half float textures is supported */
  29752. textureHalfFloatRender: boolean;
  29753. /** Defines if textureLOD shader command is supported */
  29754. textureLOD: boolean;
  29755. /** Defines if draw buffers extension is supported */
  29756. drawBuffersExtension: boolean;
  29757. /** Defines if depth textures are supported */
  29758. depthTextureExtension: boolean;
  29759. /** Defines if float color buffer are supported */
  29760. colorBufferFloat: boolean;
  29761. /** Gets disjoint timer query extension (null if not supported) */
  29762. timerQuery?: EXT_disjoint_timer_query;
  29763. /** Defines if timestamp can be used with timer query */
  29764. canUseTimestampForTimerQuery: boolean;
  29765. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29766. multiview?: any;
  29767. /** Function used to let the system compiles shaders in background */
  29768. parallelShaderCompile?: {
  29769. COMPLETION_STATUS_KHR: number;
  29770. };
  29771. /** Max number of texture samples for MSAA */
  29772. maxMSAASamples: number;
  29773. /** Defines if the blend min max extension is supported */
  29774. blendMinMax: boolean;
  29775. }
  29776. }
  29777. declare module "babylonjs/States/depthCullingState" {
  29778. import { Nullable } from "babylonjs/types";
  29779. /**
  29780. * @hidden
  29781. **/
  29782. export class DepthCullingState {
  29783. private _isDepthTestDirty;
  29784. private _isDepthMaskDirty;
  29785. private _isDepthFuncDirty;
  29786. private _isCullFaceDirty;
  29787. private _isCullDirty;
  29788. private _isZOffsetDirty;
  29789. private _isFrontFaceDirty;
  29790. private _depthTest;
  29791. private _depthMask;
  29792. private _depthFunc;
  29793. private _cull;
  29794. private _cullFace;
  29795. private _zOffset;
  29796. private _frontFace;
  29797. /**
  29798. * Initializes the state.
  29799. */
  29800. constructor();
  29801. readonly isDirty: boolean;
  29802. zOffset: number;
  29803. cullFace: Nullable<number>;
  29804. cull: Nullable<boolean>;
  29805. depthFunc: Nullable<number>;
  29806. depthMask: boolean;
  29807. depthTest: boolean;
  29808. frontFace: Nullable<number>;
  29809. reset(): void;
  29810. apply(gl: WebGLRenderingContext): void;
  29811. }
  29812. }
  29813. declare module "babylonjs/States/stencilState" {
  29814. /**
  29815. * @hidden
  29816. **/
  29817. export class StencilState {
  29818. /** 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 */
  29819. static readonly ALWAYS: number;
  29820. /** Passed to stencilOperation to specify that stencil value must be kept */
  29821. static readonly KEEP: number;
  29822. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29823. static readonly REPLACE: number;
  29824. private _isStencilTestDirty;
  29825. private _isStencilMaskDirty;
  29826. private _isStencilFuncDirty;
  29827. private _isStencilOpDirty;
  29828. private _stencilTest;
  29829. private _stencilMask;
  29830. private _stencilFunc;
  29831. private _stencilFuncRef;
  29832. private _stencilFuncMask;
  29833. private _stencilOpStencilFail;
  29834. private _stencilOpDepthFail;
  29835. private _stencilOpStencilDepthPass;
  29836. readonly isDirty: boolean;
  29837. stencilFunc: number;
  29838. stencilFuncRef: number;
  29839. stencilFuncMask: number;
  29840. stencilOpStencilFail: number;
  29841. stencilOpDepthFail: number;
  29842. stencilOpStencilDepthPass: number;
  29843. stencilMask: number;
  29844. stencilTest: boolean;
  29845. constructor();
  29846. reset(): void;
  29847. apply(gl: WebGLRenderingContext): void;
  29848. }
  29849. }
  29850. declare module "babylonjs/States/alphaCullingState" {
  29851. /**
  29852. * @hidden
  29853. **/
  29854. export class AlphaState {
  29855. private _isAlphaBlendDirty;
  29856. private _isBlendFunctionParametersDirty;
  29857. private _isBlendEquationParametersDirty;
  29858. private _isBlendConstantsDirty;
  29859. private _alphaBlend;
  29860. private _blendFunctionParameters;
  29861. private _blendEquationParameters;
  29862. private _blendConstants;
  29863. /**
  29864. * Initializes the state.
  29865. */
  29866. constructor();
  29867. readonly isDirty: boolean;
  29868. alphaBlend: boolean;
  29869. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29870. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29871. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29872. reset(): void;
  29873. apply(gl: WebGLRenderingContext): void;
  29874. }
  29875. }
  29876. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29877. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29878. /** @hidden */
  29879. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29880. attributeProcessor(attribute: string): string;
  29881. varyingProcessor(varying: string, isFragment: boolean): string;
  29882. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29883. }
  29884. }
  29885. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29886. /**
  29887. * Interface for attribute information associated with buffer instanciation
  29888. */
  29889. export interface InstancingAttributeInfo {
  29890. /**
  29891. * Index/offset of the attribute in the vertex shader
  29892. */
  29893. index: number;
  29894. /**
  29895. * size of the attribute, 1, 2, 3 or 4
  29896. */
  29897. attributeSize: number;
  29898. /**
  29899. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29900. * default is FLOAT
  29901. */
  29902. attributeType: number;
  29903. /**
  29904. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29905. */
  29906. normalized: boolean;
  29907. /**
  29908. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29909. */
  29910. offset: number;
  29911. /**
  29912. * Name of the GLSL attribute, for debugging purpose only
  29913. */
  29914. attributeName: string;
  29915. }
  29916. }
  29917. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29918. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29919. import { Nullable } from "babylonjs/types";
  29920. module "babylonjs/Engines/thinEngine" {
  29921. interface ThinEngine {
  29922. /**
  29923. * Update a video texture
  29924. * @param texture defines the texture to update
  29925. * @param video defines the video element to use
  29926. * @param invertY defines if data must be stored with Y axis inverted
  29927. */
  29928. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29929. }
  29930. }
  29931. }
  29932. declare module "babylonjs/Materials/Textures/videoTexture" {
  29933. import { Observable } from "babylonjs/Misc/observable";
  29934. import { Nullable } from "babylonjs/types";
  29935. import { Scene } from "babylonjs/scene";
  29936. import { Texture } from "babylonjs/Materials/Textures/texture";
  29937. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29938. /**
  29939. * Settings for finer control over video usage
  29940. */
  29941. export interface VideoTextureSettings {
  29942. /**
  29943. * Applies `autoplay` to video, if specified
  29944. */
  29945. autoPlay?: boolean;
  29946. /**
  29947. * Applies `loop` to video, if specified
  29948. */
  29949. loop?: boolean;
  29950. /**
  29951. * Automatically updates internal texture from video at every frame in the render loop
  29952. */
  29953. autoUpdateTexture: boolean;
  29954. /**
  29955. * Image src displayed during the video loading or until the user interacts with the video.
  29956. */
  29957. poster?: string;
  29958. }
  29959. /**
  29960. * If you want to display a video in your scene, this is the special texture for that.
  29961. * This special texture works similar to other textures, with the exception of a few parameters.
  29962. * @see https://doc.babylonjs.com/how_to/video_texture
  29963. */
  29964. export class VideoTexture extends Texture {
  29965. /**
  29966. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29967. */
  29968. readonly autoUpdateTexture: boolean;
  29969. /**
  29970. * The video instance used by the texture internally
  29971. */
  29972. readonly video: HTMLVideoElement;
  29973. private _onUserActionRequestedObservable;
  29974. /**
  29975. * Event triggerd when a dom action is required by the user to play the video.
  29976. * This happens due to recent changes in browser policies preventing video to auto start.
  29977. */
  29978. readonly onUserActionRequestedObservable: Observable<Texture>;
  29979. private _generateMipMaps;
  29980. private _engine;
  29981. private _stillImageCaptured;
  29982. private _displayingPosterTexture;
  29983. private _settings;
  29984. private _createInternalTextureOnEvent;
  29985. private _frameId;
  29986. /**
  29987. * Creates a video texture.
  29988. * If you want to display a video in your scene, this is the special texture for that.
  29989. * This special texture works similar to other textures, with the exception of a few parameters.
  29990. * @see https://doc.babylonjs.com/how_to/video_texture
  29991. * @param name optional name, will detect from video source, if not defined
  29992. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29993. * @param scene is obviously the current scene.
  29994. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29995. * @param invertY is false by default but can be used to invert video on Y axis
  29996. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29997. * @param settings allows finer control over video usage
  29998. */
  29999. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30000. private _getName;
  30001. private _getVideo;
  30002. private _createInternalTexture;
  30003. private reset;
  30004. /**
  30005. * @hidden Internal method to initiate `update`.
  30006. */
  30007. _rebuild(): void;
  30008. /**
  30009. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30010. */
  30011. update(): void;
  30012. /**
  30013. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30014. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30015. */
  30016. updateTexture(isVisible: boolean): void;
  30017. protected _updateInternalTexture: () => void;
  30018. /**
  30019. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30020. * @param url New url.
  30021. */
  30022. updateURL(url: string): void;
  30023. /**
  30024. * Dispose the texture and release its associated resources.
  30025. */
  30026. dispose(): void;
  30027. /**
  30028. * Creates a video texture straight from a stream.
  30029. * @param scene Define the scene the texture should be created in
  30030. * @param stream Define the stream the texture should be created from
  30031. * @returns The created video texture as a promise
  30032. */
  30033. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30034. /**
  30035. * Creates a video texture straight from your WebCam video feed.
  30036. * @param scene Define the scene the texture should be created in
  30037. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30038. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30039. * @returns The created video texture as a promise
  30040. */
  30041. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30042. minWidth: number;
  30043. maxWidth: number;
  30044. minHeight: number;
  30045. maxHeight: number;
  30046. deviceId: string;
  30047. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30048. /**
  30049. * Creates a video texture straight from your WebCam video feed.
  30050. * @param scene Define the scene the texture should be created in
  30051. * @param onReady Define a callback to triggered once the texture will be ready
  30052. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30053. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30054. */
  30055. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30056. minWidth: number;
  30057. maxWidth: number;
  30058. minHeight: number;
  30059. maxHeight: number;
  30060. deviceId: string;
  30061. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30062. }
  30063. }
  30064. declare module "babylonjs/Engines/thinEngine" {
  30065. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30066. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30067. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30068. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30069. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30070. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30071. import { Observable } from "babylonjs/Misc/observable";
  30072. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30073. import { StencilState } from "babylonjs/States/stencilState";
  30074. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30075. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30076. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30078. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30079. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30080. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30081. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30082. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30084. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30085. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30086. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30087. /**
  30088. * Defines the interface used by objects working like Scene
  30089. * @hidden
  30090. */
  30091. interface ISceneLike {
  30092. _addPendingData(data: any): void;
  30093. _removePendingData(data: any): void;
  30094. offlineProvider: IOfflineProvider;
  30095. }
  30096. /** Interface defining initialization parameters for Engine class */
  30097. export interface EngineOptions extends WebGLContextAttributes {
  30098. /**
  30099. * Defines if the engine should no exceed a specified device ratio
  30100. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30101. */
  30102. limitDeviceRatio?: number;
  30103. /**
  30104. * Defines if webvr should be enabled automatically
  30105. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30106. */
  30107. autoEnableWebVR?: boolean;
  30108. /**
  30109. * Defines if webgl2 should be turned off even if supported
  30110. * @see http://doc.babylonjs.com/features/webgl2
  30111. */
  30112. disableWebGL2Support?: boolean;
  30113. /**
  30114. * Defines if webaudio should be initialized as well
  30115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30116. */
  30117. audioEngine?: boolean;
  30118. /**
  30119. * Defines if animations should run using a deterministic lock step
  30120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30121. */
  30122. deterministicLockstep?: boolean;
  30123. /** Defines the maximum steps to use with deterministic lock step mode */
  30124. lockstepMaxSteps?: number;
  30125. /**
  30126. * Defines that engine should ignore context lost events
  30127. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30128. */
  30129. doNotHandleContextLost?: boolean;
  30130. /**
  30131. * Defines that engine should ignore modifying touch action attribute and style
  30132. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30133. */
  30134. doNotHandleTouchAction?: boolean;
  30135. /**
  30136. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30137. */
  30138. useHighPrecisionFloats?: boolean;
  30139. }
  30140. /**
  30141. * The base engine class (root of all engines)
  30142. */
  30143. export class ThinEngine {
  30144. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30145. static ExceptionList: ({
  30146. key: string;
  30147. capture: string;
  30148. captureConstraint: number;
  30149. targets: string[];
  30150. } | {
  30151. key: string;
  30152. capture: null;
  30153. captureConstraint: null;
  30154. targets: string[];
  30155. })[];
  30156. /** @hidden */
  30157. static _TextureLoaders: IInternalTextureLoader[];
  30158. /**
  30159. * Returns the current npm package of the sdk
  30160. */
  30161. static readonly NpmPackage: string;
  30162. /**
  30163. * Returns the current version of the framework
  30164. */
  30165. static readonly Version: string;
  30166. /**
  30167. * Returns a string describing the current engine
  30168. */
  30169. readonly description: string;
  30170. /**
  30171. * Gets or sets the epsilon value used by collision engine
  30172. */
  30173. static CollisionsEpsilon: number;
  30174. /**
  30175. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30176. */
  30177. static ShadersRepository: string;
  30178. /** @hidden */
  30179. _shaderProcessor: IShaderProcessor;
  30180. /**
  30181. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30182. */
  30183. forcePOTTextures: boolean;
  30184. /**
  30185. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30186. */
  30187. isFullscreen: boolean;
  30188. /**
  30189. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30190. */
  30191. cullBackFaces: boolean;
  30192. /**
  30193. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30194. */
  30195. renderEvenInBackground: boolean;
  30196. /**
  30197. * Gets or sets a boolean indicating that cache can be kept between frames
  30198. */
  30199. preventCacheWipeBetweenFrames: boolean;
  30200. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30201. validateShaderPrograms: boolean;
  30202. /**
  30203. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30204. */
  30205. disableUniformBuffers: boolean;
  30206. /** @hidden */
  30207. _uniformBuffers: UniformBuffer[];
  30208. /**
  30209. * Gets a boolean indicating that the engine supports uniform buffers
  30210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30211. */
  30212. readonly supportsUniformBuffers: boolean;
  30213. /** @hidden */
  30214. _gl: WebGLRenderingContext;
  30215. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30216. protected _windowIsBackground: boolean;
  30217. protected _webGLVersion: number;
  30218. protected _creationOptions: EngineOptions;
  30219. protected _highPrecisionShadersAllowed: boolean;
  30220. /** @hidden */
  30221. readonly _shouldUseHighPrecisionShader: boolean;
  30222. /**
  30223. * Gets a boolean indicating that only power of 2 textures are supported
  30224. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30225. */
  30226. readonly needPOTTextures: boolean;
  30227. /** @hidden */
  30228. _badOS: boolean;
  30229. /** @hidden */
  30230. _badDesktopOS: boolean;
  30231. private _hardwareScalingLevel;
  30232. /** @hidden */
  30233. _caps: EngineCapabilities;
  30234. private _isStencilEnable;
  30235. protected _colorWrite: boolean;
  30236. private _glVersion;
  30237. private _glRenderer;
  30238. private _glVendor;
  30239. /** @hidden */
  30240. _videoTextureSupported: boolean;
  30241. protected _renderingQueueLaunched: boolean;
  30242. protected _activeRenderLoops: (() => void)[];
  30243. /**
  30244. * Observable signaled when a context lost event is raised
  30245. */
  30246. onContextLostObservable: Observable<ThinEngine>;
  30247. /**
  30248. * Observable signaled when a context restored event is raised
  30249. */
  30250. onContextRestoredObservable: Observable<ThinEngine>;
  30251. private _onContextLost;
  30252. private _onContextRestored;
  30253. protected _contextWasLost: boolean;
  30254. /** @hidden */
  30255. _doNotHandleContextLost: boolean;
  30256. /**
  30257. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30259. */
  30260. doNotHandleContextLost: boolean;
  30261. /**
  30262. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30263. */
  30264. disableVertexArrayObjects: boolean;
  30265. /** @hidden */
  30266. protected _depthCullingState: DepthCullingState;
  30267. /** @hidden */
  30268. protected _stencilState: StencilState;
  30269. /** @hidden */
  30270. protected _alphaState: AlphaState;
  30271. /** @hidden */
  30272. _internalTexturesCache: InternalTexture[];
  30273. /** @hidden */
  30274. protected _activeChannel: number;
  30275. private _currentTextureChannel;
  30276. /** @hidden */
  30277. protected _boundTexturesCache: {
  30278. [key: string]: Nullable<InternalTexture>;
  30279. };
  30280. /** @hidden */
  30281. protected _currentEffect: Nullable<Effect>;
  30282. /** @hidden */
  30283. protected _currentProgram: Nullable<WebGLProgram>;
  30284. private _compiledEffects;
  30285. private _vertexAttribArraysEnabled;
  30286. /** @hidden */
  30287. protected _cachedViewport: Nullable<IViewportLike>;
  30288. private _cachedVertexArrayObject;
  30289. /** @hidden */
  30290. protected _cachedVertexBuffers: any;
  30291. /** @hidden */
  30292. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30293. /** @hidden */
  30294. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30295. /** @hidden */
  30296. _currentRenderTarget: Nullable<InternalTexture>;
  30297. private _uintIndicesCurrentlySet;
  30298. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30299. /** @hidden */
  30300. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30301. private _currentBufferPointers;
  30302. private _currentInstanceLocations;
  30303. private _currentInstanceBuffers;
  30304. private _textureUnits;
  30305. /** @hidden */
  30306. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30307. /** @hidden */
  30308. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30309. /** @hidden */
  30310. _boundRenderFunction: any;
  30311. private _vaoRecordInProgress;
  30312. private _mustWipeVertexAttributes;
  30313. private _emptyTexture;
  30314. private _emptyCubeTexture;
  30315. private _emptyTexture3D;
  30316. private _emptyTexture2DArray;
  30317. /** @hidden */
  30318. _frameHandler: number;
  30319. private _nextFreeTextureSlots;
  30320. private _maxSimultaneousTextures;
  30321. private _activeRequests;
  30322. protected _texturesSupported: string[];
  30323. /** @hidden */
  30324. _textureFormatInUse: Nullable<string>;
  30325. protected readonly _supportsHardwareTextureRescaling: boolean;
  30326. /**
  30327. * Gets the list of texture formats supported
  30328. */
  30329. readonly texturesSupported: Array<string>;
  30330. /**
  30331. * Gets the list of texture formats in use
  30332. */
  30333. readonly textureFormatInUse: Nullable<string>;
  30334. /**
  30335. * Gets the current viewport
  30336. */
  30337. readonly currentViewport: Nullable<IViewportLike>;
  30338. /**
  30339. * Gets the default empty texture
  30340. */
  30341. readonly emptyTexture: InternalTexture;
  30342. /**
  30343. * Gets the default empty 3D texture
  30344. */
  30345. readonly emptyTexture3D: InternalTexture;
  30346. /**
  30347. * Gets the default empty 2D array texture
  30348. */
  30349. readonly emptyTexture2DArray: InternalTexture;
  30350. /**
  30351. * Gets the default empty cube texture
  30352. */
  30353. readonly emptyCubeTexture: InternalTexture;
  30354. /**
  30355. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30356. */
  30357. readonly premultipliedAlpha: boolean;
  30358. /**
  30359. * Observable event triggered before each texture is initialized
  30360. */
  30361. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30362. /**
  30363. * Creates a new engine
  30364. * @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
  30365. * @param antialias defines enable antialiasing (default: false)
  30366. * @param options defines further options to be sent to the getContext() function
  30367. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30368. */
  30369. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30370. private _rebuildInternalTextures;
  30371. private _rebuildEffects;
  30372. /**
  30373. * Gets a boolean indicating if all created effects are ready
  30374. * @returns true if all effects are ready
  30375. */
  30376. areAllEffectsReady(): boolean;
  30377. protected _rebuildBuffers(): void;
  30378. private _initGLContext;
  30379. /**
  30380. * Gets version of the current webGL context
  30381. */
  30382. readonly webGLVersion: number;
  30383. /**
  30384. * Gets a string idenfifying the name of the class
  30385. * @returns "Engine" string
  30386. */
  30387. getClassName(): string;
  30388. /**
  30389. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30390. */
  30391. readonly isStencilEnable: boolean;
  30392. /** @hidden */
  30393. _prepareWorkingCanvas(): void;
  30394. /**
  30395. * Reset the texture cache to empty state
  30396. */
  30397. resetTextureCache(): void;
  30398. /**
  30399. * Gets an object containing information about the current webGL context
  30400. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30401. */
  30402. getGlInfo(): {
  30403. vendor: string;
  30404. renderer: string;
  30405. version: string;
  30406. };
  30407. /**
  30408. * Defines the hardware scaling level.
  30409. * By default the hardware scaling level is computed from the window device ratio.
  30410. * 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.
  30411. * @param level defines the level to use
  30412. */
  30413. setHardwareScalingLevel(level: number): void;
  30414. /**
  30415. * Gets the current hardware scaling level.
  30416. * By default the hardware scaling level is computed from the window device ratio.
  30417. * 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.
  30418. * @returns a number indicating the current hardware scaling level
  30419. */
  30420. getHardwareScalingLevel(): number;
  30421. /**
  30422. * Gets the list of loaded textures
  30423. * @returns an array containing all loaded textures
  30424. */
  30425. getLoadedTexturesCache(): InternalTexture[];
  30426. /**
  30427. * Gets the object containing all engine capabilities
  30428. * @returns the EngineCapabilities object
  30429. */
  30430. getCaps(): EngineCapabilities;
  30431. /**
  30432. * stop executing a render loop function and remove it from the execution array
  30433. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30434. */
  30435. stopRenderLoop(renderFunction?: () => void): void;
  30436. /** @hidden */
  30437. _renderLoop(): void;
  30438. /**
  30439. * Gets the HTML canvas attached with the current webGL context
  30440. * @returns a HTML canvas
  30441. */
  30442. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30443. /**
  30444. * Gets host window
  30445. * @returns the host window object
  30446. */
  30447. getHostWindow(): Nullable<Window>;
  30448. /**
  30449. * Gets the current render width
  30450. * @param useScreen defines if screen size must be used (or the current render target if any)
  30451. * @returns a number defining the current render width
  30452. */
  30453. getRenderWidth(useScreen?: boolean): number;
  30454. /**
  30455. * Gets the current render height
  30456. * @param useScreen defines if screen size must be used (or the current render target if any)
  30457. * @returns a number defining the current render height
  30458. */
  30459. getRenderHeight(useScreen?: boolean): number;
  30460. /**
  30461. * Can be used to override the current requestAnimationFrame requester.
  30462. * @hidden
  30463. */
  30464. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30465. /**
  30466. * Register and execute a render loop. The engine can have more than one render function
  30467. * @param renderFunction defines the function to continuously execute
  30468. */
  30469. runRenderLoop(renderFunction: () => void): void;
  30470. /**
  30471. * Clear the current render buffer or the current render target (if any is set up)
  30472. * @param color defines the color to use
  30473. * @param backBuffer defines if the back buffer must be cleared
  30474. * @param depth defines if the depth buffer must be cleared
  30475. * @param stencil defines if the stencil buffer must be cleared
  30476. */
  30477. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30478. private _viewportCached;
  30479. /** @hidden */
  30480. _viewport(x: number, y: number, width: number, height: number): void;
  30481. /**
  30482. * Set the WebGL's viewport
  30483. * @param viewport defines the viewport element to be used
  30484. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30485. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30486. */
  30487. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30488. /**
  30489. * Begin a new frame
  30490. */
  30491. beginFrame(): void;
  30492. /**
  30493. * Enf the current frame
  30494. */
  30495. endFrame(): void;
  30496. /**
  30497. * Resize the view according to the canvas' size
  30498. */
  30499. resize(): void;
  30500. /**
  30501. * Force a specific size of the canvas
  30502. * @param width defines the new canvas' width
  30503. * @param height defines the new canvas' height
  30504. */
  30505. setSize(width: number, height: number): void;
  30506. /**
  30507. * Binds the frame buffer to the specified texture.
  30508. * @param texture The texture to render to or null for the default canvas
  30509. * @param faceIndex The face of the texture to render to in case of cube texture
  30510. * @param requiredWidth The width of the target to render to
  30511. * @param requiredHeight The height of the target to render to
  30512. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30513. * @param depthStencilTexture The depth stencil texture to use to render
  30514. * @param lodLevel defines le lod level to bind to the frame buffer
  30515. */
  30516. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30517. /** @hidden */
  30518. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30519. /**
  30520. * Unbind the current render target texture from the webGL context
  30521. * @param texture defines the render target texture to unbind
  30522. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30523. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30524. */
  30525. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30526. /**
  30527. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30528. */
  30529. flushFramebuffer(): void;
  30530. /**
  30531. * Unbind the current render target and bind the default framebuffer
  30532. */
  30533. restoreDefaultFramebuffer(): void;
  30534. /** @hidden */
  30535. protected _resetVertexBufferBinding(): void;
  30536. /**
  30537. * Creates a vertex buffer
  30538. * @param data the data for the vertex buffer
  30539. * @returns the new WebGL static buffer
  30540. */
  30541. createVertexBuffer(data: DataArray): DataBuffer;
  30542. private _createVertexBuffer;
  30543. /**
  30544. * Creates a dynamic vertex buffer
  30545. * @param data the data for the dynamic vertex buffer
  30546. * @returns the new WebGL dynamic buffer
  30547. */
  30548. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30549. protected _resetIndexBufferBinding(): void;
  30550. /**
  30551. * Creates a new index buffer
  30552. * @param indices defines the content of the index buffer
  30553. * @param updatable defines if the index buffer must be updatable
  30554. * @returns a new webGL buffer
  30555. */
  30556. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30557. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30558. /**
  30559. * Bind a webGL buffer to the webGL context
  30560. * @param buffer defines the buffer to bind
  30561. */
  30562. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30563. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30564. private bindBuffer;
  30565. /**
  30566. * update the bound buffer with the given data
  30567. * @param data defines the data to update
  30568. */
  30569. updateArrayBuffer(data: Float32Array): void;
  30570. private _vertexAttribPointer;
  30571. private _bindIndexBufferWithCache;
  30572. private _bindVertexBuffersAttributes;
  30573. /**
  30574. * Records a vertex array object
  30575. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30576. * @param vertexBuffers defines the list of vertex buffers to store
  30577. * @param indexBuffer defines the index buffer to store
  30578. * @param effect defines the effect to store
  30579. * @returns the new vertex array object
  30580. */
  30581. recordVertexArrayObject(vertexBuffers: {
  30582. [key: string]: VertexBuffer;
  30583. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30584. /**
  30585. * Bind a specific vertex array object
  30586. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30587. * @param vertexArrayObject defines the vertex array object to bind
  30588. * @param indexBuffer defines the index buffer to bind
  30589. */
  30590. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30591. /**
  30592. * Bind webGl buffers directly to the webGL context
  30593. * @param vertexBuffer defines the vertex buffer to bind
  30594. * @param indexBuffer defines the index buffer to bind
  30595. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30596. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30597. * @param effect defines the effect associated with the vertex buffer
  30598. */
  30599. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30600. private _unbindVertexArrayObject;
  30601. /**
  30602. * Bind a list of vertex buffers to the webGL context
  30603. * @param vertexBuffers defines the list of vertex buffers to bind
  30604. * @param indexBuffer defines the index buffer to bind
  30605. * @param effect defines the effect associated with the vertex buffers
  30606. */
  30607. bindBuffers(vertexBuffers: {
  30608. [key: string]: Nullable<VertexBuffer>;
  30609. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30610. /**
  30611. * Unbind all instance attributes
  30612. */
  30613. unbindInstanceAttributes(): void;
  30614. /**
  30615. * Release and free the memory of a vertex array object
  30616. * @param vao defines the vertex array object to delete
  30617. */
  30618. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30619. /** @hidden */
  30620. _releaseBuffer(buffer: DataBuffer): boolean;
  30621. protected _deleteBuffer(buffer: DataBuffer): void;
  30622. /**
  30623. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30624. * @param instancesBuffer defines the webGL buffer to update and bind
  30625. * @param data defines the data to store in the buffer
  30626. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30627. */
  30628. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30629. /**
  30630. * Apply all cached states (depth, culling, stencil and alpha)
  30631. */
  30632. applyStates(): void;
  30633. /**
  30634. * Send a draw order
  30635. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30636. * @param indexStart defines the starting index
  30637. * @param indexCount defines the number of index to draw
  30638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30639. */
  30640. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30641. /**
  30642. * Draw a list of points
  30643. * @param verticesStart defines the index of first vertex to draw
  30644. * @param verticesCount defines the count of vertices to draw
  30645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30646. */
  30647. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30648. /**
  30649. * Draw a list of unindexed primitives
  30650. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30651. * @param verticesStart defines the index of first vertex to draw
  30652. * @param verticesCount defines the count of vertices to draw
  30653. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30654. */
  30655. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30656. /**
  30657. * Draw a list of indexed primitives
  30658. * @param fillMode defines the primitive to use
  30659. * @param indexStart defines the starting index
  30660. * @param indexCount defines the number of index to draw
  30661. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30662. */
  30663. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30664. /**
  30665. * Draw a list of unindexed primitives
  30666. * @param fillMode defines the primitive to use
  30667. * @param verticesStart defines the index of first vertex to draw
  30668. * @param verticesCount defines the count of vertices to draw
  30669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30670. */
  30671. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30672. private _drawMode;
  30673. /** @hidden */
  30674. protected _reportDrawCall(): void;
  30675. /** @hidden */
  30676. _releaseEffect(effect: Effect): void;
  30677. /** @hidden */
  30678. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30679. /**
  30680. * Create a new effect (used to store vertex/fragment shaders)
  30681. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30682. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30683. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30684. * @param samplers defines an array of string used to represent textures
  30685. * @param defines defines the string containing the defines to use to compile the shaders
  30686. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30687. * @param onCompiled defines a function to call when the effect creation is successful
  30688. * @param onError defines a function to call when the effect creation has failed
  30689. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30690. * @returns the new Effect
  30691. */
  30692. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30693. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30694. private _compileShader;
  30695. private _compileRawShader;
  30696. /**
  30697. * Directly creates a webGL program
  30698. * @param pipelineContext defines the pipeline context to attach to
  30699. * @param vertexCode defines the vertex shader code to use
  30700. * @param fragmentCode defines the fragment shader code to use
  30701. * @param context defines the webGL context to use (if not set, the current one will be used)
  30702. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30703. * @returns the new webGL program
  30704. */
  30705. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30706. /**
  30707. * Creates a webGL program
  30708. * @param pipelineContext defines the pipeline context to attach to
  30709. * @param vertexCode defines the vertex shader code to use
  30710. * @param fragmentCode defines the fragment shader code to use
  30711. * @param defines defines the string containing the defines to use to compile the shaders
  30712. * @param context defines the webGL context to use (if not set, the current one will be used)
  30713. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30714. * @returns the new webGL program
  30715. */
  30716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30717. /**
  30718. * Creates a new pipeline context
  30719. * @returns the new pipeline
  30720. */
  30721. createPipelineContext(): IPipelineContext;
  30722. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30723. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30724. /** @hidden */
  30725. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30726. /** @hidden */
  30727. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30728. /** @hidden */
  30729. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30730. /**
  30731. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30732. * @param pipelineContext defines the pipeline context to use
  30733. * @param uniformsNames defines the list of uniform names
  30734. * @returns an array of webGL uniform locations
  30735. */
  30736. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30737. /**
  30738. * Gets the lsit of active attributes for a given webGL program
  30739. * @param pipelineContext defines the pipeline context to use
  30740. * @param attributesNames defines the list of attribute names to get
  30741. * @returns an array of indices indicating the offset of each attribute
  30742. */
  30743. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30744. /**
  30745. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30746. * @param effect defines the effect to activate
  30747. */
  30748. enableEffect(effect: Nullable<Effect>): void;
  30749. /**
  30750. * Set the value of an uniform to a number (int)
  30751. * @param uniform defines the webGL uniform location where to store the value
  30752. * @param value defines the int number to store
  30753. */
  30754. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30755. /**
  30756. * Set the value of an uniform to an array of int32
  30757. * @param uniform defines the webGL uniform location where to store the value
  30758. * @param array defines the array of int32 to store
  30759. */
  30760. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30761. /**
  30762. * Set the value of an uniform to an array of int32 (stored as vec2)
  30763. * @param uniform defines the webGL uniform location where to store the value
  30764. * @param array defines the array of int32 to store
  30765. */
  30766. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30767. /**
  30768. * Set the value of an uniform to an array of int32 (stored as vec3)
  30769. * @param uniform defines the webGL uniform location where to store the value
  30770. * @param array defines the array of int32 to store
  30771. */
  30772. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30773. /**
  30774. * Set the value of an uniform to an array of int32 (stored as vec4)
  30775. * @param uniform defines the webGL uniform location where to store the value
  30776. * @param array defines the array of int32 to store
  30777. */
  30778. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30779. /**
  30780. * Set the value of an uniform to an array of number
  30781. * @param uniform defines the webGL uniform location where to store the value
  30782. * @param array defines the array of number to store
  30783. */
  30784. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30785. /**
  30786. * Set the value of an uniform to an array of number (stored as vec2)
  30787. * @param uniform defines the webGL uniform location where to store the value
  30788. * @param array defines the array of number to store
  30789. */
  30790. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30791. /**
  30792. * Set the value of an uniform to an array of number (stored as vec3)
  30793. * @param uniform defines the webGL uniform location where to store the value
  30794. * @param array defines the array of number to store
  30795. */
  30796. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30797. /**
  30798. * Set the value of an uniform to an array of number (stored as vec4)
  30799. * @param uniform defines the webGL uniform location where to store the value
  30800. * @param array defines the array of number to store
  30801. */
  30802. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30803. /**
  30804. * Set the value of an uniform to an array of float32 (stored as matrices)
  30805. * @param uniform defines the webGL uniform location where to store the value
  30806. * @param matrices defines the array of float32 to store
  30807. */
  30808. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30809. /**
  30810. * Set the value of an uniform to a matrix (3x3)
  30811. * @param uniform defines the webGL uniform location where to store the value
  30812. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30813. */
  30814. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30815. /**
  30816. * Set the value of an uniform to a matrix (2x2)
  30817. * @param uniform defines the webGL uniform location where to store the value
  30818. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30819. */
  30820. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30821. /**
  30822. * Set the value of an uniform to a number (float)
  30823. * @param uniform defines the webGL uniform location where to store the value
  30824. * @param value defines the float number to store
  30825. */
  30826. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30827. /**
  30828. * Set the value of an uniform to a vec2
  30829. * @param uniform defines the webGL uniform location where to store the value
  30830. * @param x defines the 1st component of the value
  30831. * @param y defines the 2nd component of the value
  30832. */
  30833. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30834. /**
  30835. * Set the value of an uniform to a vec3
  30836. * @param uniform defines the webGL uniform location where to store the value
  30837. * @param x defines the 1st component of the value
  30838. * @param y defines the 2nd component of the value
  30839. * @param z defines the 3rd component of the value
  30840. */
  30841. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30842. /**
  30843. * Set the value of an uniform to a vec4
  30844. * @param uniform defines the webGL uniform location where to store the value
  30845. * @param x defines the 1st component of the value
  30846. * @param y defines the 2nd component of the value
  30847. * @param z defines the 3rd component of the value
  30848. * @param w defines the 4th component of the value
  30849. */
  30850. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30851. /**
  30852. * Gets the depth culling state manager
  30853. */
  30854. readonly depthCullingState: DepthCullingState;
  30855. /**
  30856. * Gets the alpha state manager
  30857. */
  30858. readonly alphaState: AlphaState;
  30859. /**
  30860. * Gets the stencil state manager
  30861. */
  30862. readonly stencilState: StencilState;
  30863. /**
  30864. * Clears the list of texture accessible through engine.
  30865. * This can help preventing texture load conflict due to name collision.
  30866. */
  30867. clearInternalTexturesCache(): void;
  30868. /**
  30869. * Force the entire cache to be cleared
  30870. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30871. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30872. */
  30873. wipeCaches(bruteForce?: boolean): void;
  30874. /** @hidden */
  30875. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30876. min: number;
  30877. mag: number;
  30878. };
  30879. /** @hidden */
  30880. _createTexture(): WebGLTexture;
  30881. /**
  30882. * Usually called from Texture.ts.
  30883. * Passed information to create a WebGLTexture
  30884. * @param urlArg defines a value which contains one of the following:
  30885. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30886. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30887. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30888. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30889. * @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)
  30890. * @param scene needed for loading to the correct scene
  30891. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30892. * @param onLoad optional callback to be called upon successful completion
  30893. * @param onError optional callback to be called upon failure
  30894. * @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
  30895. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30896. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30897. * @param forcedExtension defines the extension to use to pick the right loader
  30898. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30899. * @param mimeType defines an optional mime type
  30900. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30901. */
  30902. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30903. /**
  30904. * @hidden
  30905. */
  30906. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30907. /**
  30908. * Creates a raw texture
  30909. * @param data defines the data to store in the texture
  30910. * @param width defines the width of the texture
  30911. * @param height defines the height of the texture
  30912. * @param format defines the format of the data
  30913. * @param generateMipMaps defines if the engine should generate the mip levels
  30914. * @param invertY defines if data must be stored with Y axis inverted
  30915. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30916. * @param compression defines the compression used (null by default)
  30917. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30918. * @returns the raw texture inside an InternalTexture
  30919. */
  30920. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30921. /**
  30922. * Creates a new raw cube texture
  30923. * @param data defines the array of data to use to create each face
  30924. * @param size defines the size of the textures
  30925. * @param format defines the format of the data
  30926. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30927. * @param generateMipMaps defines if the engine should generate the mip levels
  30928. * @param invertY defines if data must be stored with Y axis inverted
  30929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30930. * @param compression defines the compression used (null by default)
  30931. * @returns the cube texture as an InternalTexture
  30932. */
  30933. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30934. /**
  30935. * Creates a new raw 3D texture
  30936. * @param data defines the data used to create the texture
  30937. * @param width defines the width of the texture
  30938. * @param height defines the height of the texture
  30939. * @param depth defines the depth of the texture
  30940. * @param format defines the format of the texture
  30941. * @param generateMipMaps defines if the engine must generate mip levels
  30942. * @param invertY defines if data must be stored with Y axis inverted
  30943. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30944. * @param compression defines the compressed used (can be null)
  30945. * @param textureType defines the compressed used (can be null)
  30946. * @returns a new raw 3D texture (stored in an InternalTexture)
  30947. */
  30948. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30949. /**
  30950. * Creates a new raw 2D array texture
  30951. * @param data defines the data used to create the texture
  30952. * @param width defines the width of the texture
  30953. * @param height defines the height of the texture
  30954. * @param depth defines the number of layers of the texture
  30955. * @param format defines the format of the texture
  30956. * @param generateMipMaps defines if the engine must generate mip levels
  30957. * @param invertY defines if data must be stored with Y axis inverted
  30958. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30959. * @param compression defines the compressed used (can be null)
  30960. * @param textureType defines the compressed used (can be null)
  30961. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30962. */
  30963. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30964. private _unpackFlipYCached;
  30965. /**
  30966. * In case you are sharing the context with other applications, it might
  30967. * be interested to not cache the unpack flip y state to ensure a consistent
  30968. * value would be set.
  30969. */
  30970. enableUnpackFlipYCached: boolean;
  30971. /** @hidden */
  30972. _unpackFlipY(value: boolean): void;
  30973. /** @hidden */
  30974. _getUnpackAlignement(): number;
  30975. /**
  30976. * Update the sampling mode of a given texture
  30977. * @param samplingMode defines the required sampling mode
  30978. * @param texture defines the texture to update
  30979. */
  30980. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30981. /** @hidden */
  30982. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30983. width: number;
  30984. height: number;
  30985. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30986. /** @hidden */
  30987. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30988. /** @hidden */
  30989. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30990. /** @hidden */
  30991. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30992. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30993. private _prepareWebGLTexture;
  30994. /** @hidden */
  30995. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30996. /** @hidden */
  30997. _releaseFramebufferObjects(texture: InternalTexture): void;
  30998. /** @hidden */
  30999. _releaseTexture(texture: InternalTexture): void;
  31000. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31001. protected _setProgram(program: WebGLProgram): void;
  31002. protected _boundUniforms: {
  31003. [key: number]: WebGLUniformLocation;
  31004. };
  31005. /**
  31006. * Binds an effect to the webGL context
  31007. * @param effect defines the effect to bind
  31008. */
  31009. bindSamplers(effect: Effect): void;
  31010. private _activateCurrentTexture;
  31011. /** @hidden */
  31012. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31013. /** @hidden */
  31014. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31015. /**
  31016. * Unbind all textures from the webGL context
  31017. */
  31018. unbindAllTextures(): void;
  31019. /**
  31020. * Sets a texture to the according uniform.
  31021. * @param channel The texture channel
  31022. * @param uniform The uniform to set
  31023. * @param texture The texture to apply
  31024. */
  31025. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31026. private _bindSamplerUniformToChannel;
  31027. private _getTextureWrapMode;
  31028. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31029. /**
  31030. * Sets an array of texture to the webGL context
  31031. * @param channel defines the channel where the texture array must be set
  31032. * @param uniform defines the associated uniform location
  31033. * @param textures defines the array of textures to bind
  31034. */
  31035. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31036. /** @hidden */
  31037. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31038. private _setTextureParameterFloat;
  31039. private _setTextureParameterInteger;
  31040. /**
  31041. * Unbind all vertex attributes from the webGL context
  31042. */
  31043. unbindAllAttributes(): void;
  31044. /**
  31045. * 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
  31046. */
  31047. releaseEffects(): void;
  31048. /**
  31049. * Dispose and release all associated resources
  31050. */
  31051. dispose(): void;
  31052. /**
  31053. * Attach a new callback raised when context lost event is fired
  31054. * @param callback defines the callback to call
  31055. */
  31056. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31057. /**
  31058. * Attach a new callback raised when context restored event is fired
  31059. * @param callback defines the callback to call
  31060. */
  31061. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31062. /**
  31063. * Get the current error code of the webGL context
  31064. * @returns the error code
  31065. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31066. */
  31067. getError(): number;
  31068. private _canRenderToFloatFramebuffer;
  31069. private _canRenderToHalfFloatFramebuffer;
  31070. private _canRenderToFramebuffer;
  31071. /** @hidden */
  31072. _getWebGLTextureType(type: number): number;
  31073. /** @hidden */
  31074. _getInternalFormat(format: number): number;
  31075. /** @hidden */
  31076. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31077. /** @hidden */
  31078. _getRGBAMultiSampleBufferFormat(type: number): number;
  31079. /** @hidden */
  31080. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31081. /**
  31082. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31083. * @returns true if the engine can be created
  31084. * @ignorenaming
  31085. */
  31086. static isSupported(): boolean;
  31087. /**
  31088. * Find the next highest power of two.
  31089. * @param x Number to start search from.
  31090. * @return Next highest power of two.
  31091. */
  31092. static CeilingPOT(x: number): number;
  31093. /**
  31094. * Find the next lowest power of two.
  31095. * @param x Number to start search from.
  31096. * @return Next lowest power of two.
  31097. */
  31098. static FloorPOT(x: number): number;
  31099. /**
  31100. * Find the nearest power of two.
  31101. * @param x Number to start search from.
  31102. * @return Next nearest power of two.
  31103. */
  31104. static NearestPOT(x: number): number;
  31105. /**
  31106. * Get the closest exponent of two
  31107. * @param value defines the value to approximate
  31108. * @param max defines the maximum value to return
  31109. * @param mode defines how to define the closest value
  31110. * @returns closest exponent of two of the given value
  31111. */
  31112. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31113. /**
  31114. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31115. * @param func - the function to be called
  31116. * @param requester - the object that will request the next frame. Falls back to window.
  31117. * @returns frame number
  31118. */
  31119. static QueueNewFrame(func: () => void, requester?: any): number;
  31120. }
  31121. }
  31122. declare module "babylonjs/Maths/sphericalPolynomial" {
  31123. import { Vector3 } from "babylonjs/Maths/math.vector";
  31124. import { Color3 } from "babylonjs/Maths/math.color";
  31125. /**
  31126. * Class representing spherical harmonics coefficients to the 3rd degree
  31127. */
  31128. export class SphericalHarmonics {
  31129. /**
  31130. * Defines whether or not the harmonics have been prescaled for rendering.
  31131. */
  31132. preScaled: boolean;
  31133. /**
  31134. * The l0,0 coefficients of the spherical harmonics
  31135. */
  31136. l00: Vector3;
  31137. /**
  31138. * The l1,-1 coefficients of the spherical harmonics
  31139. */
  31140. l1_1: Vector3;
  31141. /**
  31142. * The l1,0 coefficients of the spherical harmonics
  31143. */
  31144. l10: Vector3;
  31145. /**
  31146. * The l1,1 coefficients of the spherical harmonics
  31147. */
  31148. l11: Vector3;
  31149. /**
  31150. * The l2,-2 coefficients of the spherical harmonics
  31151. */
  31152. l2_2: Vector3;
  31153. /**
  31154. * The l2,-1 coefficients of the spherical harmonics
  31155. */
  31156. l2_1: Vector3;
  31157. /**
  31158. * The l2,0 coefficients of the spherical harmonics
  31159. */
  31160. l20: Vector3;
  31161. /**
  31162. * The l2,1 coefficients of the spherical harmonics
  31163. */
  31164. l21: Vector3;
  31165. /**
  31166. * The l2,2 coefficients of the spherical harmonics
  31167. */
  31168. l22: Vector3;
  31169. /**
  31170. * Adds a light to the spherical harmonics
  31171. * @param direction the direction of the light
  31172. * @param color the color of the light
  31173. * @param deltaSolidAngle the delta solid angle of the light
  31174. */
  31175. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31176. /**
  31177. * Scales the spherical harmonics by the given amount
  31178. * @param scale the amount to scale
  31179. */
  31180. scaleInPlace(scale: number): void;
  31181. /**
  31182. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31183. *
  31184. * ```
  31185. * E_lm = A_l * L_lm
  31186. * ```
  31187. *
  31188. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31189. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31190. * the scaling factors are given in equation 9.
  31191. */
  31192. convertIncidentRadianceToIrradiance(): void;
  31193. /**
  31194. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31195. *
  31196. * ```
  31197. * L = (1/pi) * E * rho
  31198. * ```
  31199. *
  31200. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31201. */
  31202. convertIrradianceToLambertianRadiance(): void;
  31203. /**
  31204. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31205. * required operations at run time.
  31206. *
  31207. * This is simply done by scaling back the SH with Ylm constants parameter.
  31208. * The trigonometric part being applied by the shader at run time.
  31209. */
  31210. preScaleForRendering(): void;
  31211. /**
  31212. * Constructs a spherical harmonics from an array.
  31213. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31214. * @returns the spherical harmonics
  31215. */
  31216. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31217. /**
  31218. * Gets the spherical harmonics from polynomial
  31219. * @param polynomial the spherical polynomial
  31220. * @returns the spherical harmonics
  31221. */
  31222. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31223. }
  31224. /**
  31225. * Class representing spherical polynomial coefficients to the 3rd degree
  31226. */
  31227. export class SphericalPolynomial {
  31228. private _harmonics;
  31229. /**
  31230. * The spherical harmonics used to create the polynomials.
  31231. */
  31232. readonly preScaledHarmonics: SphericalHarmonics;
  31233. /**
  31234. * The x coefficients of the spherical polynomial
  31235. */
  31236. x: Vector3;
  31237. /**
  31238. * The y coefficients of the spherical polynomial
  31239. */
  31240. y: Vector3;
  31241. /**
  31242. * The z coefficients of the spherical polynomial
  31243. */
  31244. z: Vector3;
  31245. /**
  31246. * The xx coefficients of the spherical polynomial
  31247. */
  31248. xx: Vector3;
  31249. /**
  31250. * The yy coefficients of the spherical polynomial
  31251. */
  31252. yy: Vector3;
  31253. /**
  31254. * The zz coefficients of the spherical polynomial
  31255. */
  31256. zz: Vector3;
  31257. /**
  31258. * The xy coefficients of the spherical polynomial
  31259. */
  31260. xy: Vector3;
  31261. /**
  31262. * The yz coefficients of the spherical polynomial
  31263. */
  31264. yz: Vector3;
  31265. /**
  31266. * The zx coefficients of the spherical polynomial
  31267. */
  31268. zx: Vector3;
  31269. /**
  31270. * Adds an ambient color to the spherical polynomial
  31271. * @param color the color to add
  31272. */
  31273. addAmbient(color: Color3): void;
  31274. /**
  31275. * Scales the spherical polynomial by the given amount
  31276. * @param scale the amount to scale
  31277. */
  31278. scaleInPlace(scale: number): void;
  31279. /**
  31280. * Gets the spherical polynomial from harmonics
  31281. * @param harmonics the spherical harmonics
  31282. * @returns the spherical polynomial
  31283. */
  31284. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31285. /**
  31286. * Constructs a spherical polynomial from an array.
  31287. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31288. * @returns the spherical polynomial
  31289. */
  31290. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31291. }
  31292. }
  31293. declare module "babylonjs/Materials/Textures/internalTexture" {
  31294. import { Observable } from "babylonjs/Misc/observable";
  31295. import { Nullable, int } from "babylonjs/types";
  31296. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31298. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31299. /**
  31300. * Defines the source of the internal texture
  31301. */
  31302. export enum InternalTextureSource {
  31303. /**
  31304. * The source of the texture data is unknown
  31305. */
  31306. Unknown = 0,
  31307. /**
  31308. * Texture data comes from an URL
  31309. */
  31310. Url = 1,
  31311. /**
  31312. * Texture data is only used for temporary storage
  31313. */
  31314. Temp = 2,
  31315. /**
  31316. * Texture data comes from raw data (ArrayBuffer)
  31317. */
  31318. Raw = 3,
  31319. /**
  31320. * Texture content is dynamic (video or dynamic texture)
  31321. */
  31322. Dynamic = 4,
  31323. /**
  31324. * Texture content is generated by rendering to it
  31325. */
  31326. RenderTarget = 5,
  31327. /**
  31328. * Texture content is part of a multi render target process
  31329. */
  31330. MultiRenderTarget = 6,
  31331. /**
  31332. * Texture data comes from a cube data file
  31333. */
  31334. Cube = 7,
  31335. /**
  31336. * Texture data comes from a raw cube data
  31337. */
  31338. CubeRaw = 8,
  31339. /**
  31340. * Texture data come from a prefiltered cube data file
  31341. */
  31342. CubePrefiltered = 9,
  31343. /**
  31344. * Texture content is raw 3D data
  31345. */
  31346. Raw3D = 10,
  31347. /**
  31348. * Texture content is raw 2D array data
  31349. */
  31350. Raw2DArray = 11,
  31351. /**
  31352. * Texture content is a depth texture
  31353. */
  31354. Depth = 12,
  31355. /**
  31356. * Texture data comes from a raw cube data encoded with RGBD
  31357. */
  31358. CubeRawRGBD = 13
  31359. }
  31360. /**
  31361. * Class used to store data associated with WebGL texture data for the engine
  31362. * This class should not be used directly
  31363. */
  31364. export class InternalTexture {
  31365. /** @hidden */
  31366. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31367. /**
  31368. * Defines if the texture is ready
  31369. */
  31370. isReady: boolean;
  31371. /**
  31372. * Defines if the texture is a cube texture
  31373. */
  31374. isCube: boolean;
  31375. /**
  31376. * Defines if the texture contains 3D data
  31377. */
  31378. is3D: boolean;
  31379. /**
  31380. * Defines if the texture contains 2D array data
  31381. */
  31382. is2DArray: boolean;
  31383. /**
  31384. * Defines if the texture contains multiview data
  31385. */
  31386. isMultiview: boolean;
  31387. /**
  31388. * Gets the URL used to load this texture
  31389. */
  31390. url: string;
  31391. /**
  31392. * Gets the sampling mode of the texture
  31393. */
  31394. samplingMode: number;
  31395. /**
  31396. * Gets a boolean indicating if the texture needs mipmaps generation
  31397. */
  31398. generateMipMaps: boolean;
  31399. /**
  31400. * Gets the number of samples used by the texture (WebGL2+ only)
  31401. */
  31402. samples: number;
  31403. /**
  31404. * Gets the type of the texture (int, float...)
  31405. */
  31406. type: number;
  31407. /**
  31408. * Gets the format of the texture (RGB, RGBA...)
  31409. */
  31410. format: number;
  31411. /**
  31412. * Observable called when the texture is loaded
  31413. */
  31414. onLoadedObservable: Observable<InternalTexture>;
  31415. /**
  31416. * Gets the width of the texture
  31417. */
  31418. width: number;
  31419. /**
  31420. * Gets the height of the texture
  31421. */
  31422. height: number;
  31423. /**
  31424. * Gets the depth of the texture
  31425. */
  31426. depth: number;
  31427. /**
  31428. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31429. */
  31430. baseWidth: number;
  31431. /**
  31432. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31433. */
  31434. baseHeight: number;
  31435. /**
  31436. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31437. */
  31438. baseDepth: number;
  31439. /**
  31440. * Gets a boolean indicating if the texture is inverted on Y axis
  31441. */
  31442. invertY: boolean;
  31443. /** @hidden */
  31444. _invertVScale: boolean;
  31445. /** @hidden */
  31446. _associatedChannel: number;
  31447. /** @hidden */
  31448. _source: InternalTextureSource;
  31449. /** @hidden */
  31450. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31451. /** @hidden */
  31452. _bufferView: Nullable<ArrayBufferView>;
  31453. /** @hidden */
  31454. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31455. /** @hidden */
  31456. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31457. /** @hidden */
  31458. _size: number;
  31459. /** @hidden */
  31460. _extension: string;
  31461. /** @hidden */
  31462. _files: Nullable<string[]>;
  31463. /** @hidden */
  31464. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31465. /** @hidden */
  31466. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31467. /** @hidden */
  31468. _framebuffer: Nullable<WebGLFramebuffer>;
  31469. /** @hidden */
  31470. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31471. /** @hidden */
  31472. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31473. /** @hidden */
  31474. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31475. /** @hidden */
  31476. _attachments: Nullable<number[]>;
  31477. /** @hidden */
  31478. _cachedCoordinatesMode: Nullable<number>;
  31479. /** @hidden */
  31480. _cachedWrapU: Nullable<number>;
  31481. /** @hidden */
  31482. _cachedWrapV: Nullable<number>;
  31483. /** @hidden */
  31484. _cachedWrapR: Nullable<number>;
  31485. /** @hidden */
  31486. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31487. /** @hidden */
  31488. _isDisabled: boolean;
  31489. /** @hidden */
  31490. _compression: Nullable<string>;
  31491. /** @hidden */
  31492. _generateStencilBuffer: boolean;
  31493. /** @hidden */
  31494. _generateDepthBuffer: boolean;
  31495. /** @hidden */
  31496. _comparisonFunction: number;
  31497. /** @hidden */
  31498. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31499. /** @hidden */
  31500. _lodGenerationScale: number;
  31501. /** @hidden */
  31502. _lodGenerationOffset: number;
  31503. /** @hidden */
  31504. _colorTextureArray: Nullable<WebGLTexture>;
  31505. /** @hidden */
  31506. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31507. /** @hidden */
  31508. _lodTextureHigh: Nullable<BaseTexture>;
  31509. /** @hidden */
  31510. _lodTextureMid: Nullable<BaseTexture>;
  31511. /** @hidden */
  31512. _lodTextureLow: Nullable<BaseTexture>;
  31513. /** @hidden */
  31514. _isRGBD: boolean;
  31515. /** @hidden */
  31516. _linearSpecularLOD: boolean;
  31517. /** @hidden */
  31518. _irradianceTexture: Nullable<BaseTexture>;
  31519. /** @hidden */
  31520. _webGLTexture: Nullable<WebGLTexture>;
  31521. /** @hidden */
  31522. _references: number;
  31523. private _engine;
  31524. /**
  31525. * Gets the Engine the texture belongs to.
  31526. * @returns The babylon engine
  31527. */
  31528. getEngine(): ThinEngine;
  31529. /**
  31530. * Gets the data source type of the texture
  31531. */
  31532. readonly source: InternalTextureSource;
  31533. /**
  31534. * Creates a new InternalTexture
  31535. * @param engine defines the engine to use
  31536. * @param source defines the type of data that will be used
  31537. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31538. */
  31539. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31540. /**
  31541. * Increments the number of references (ie. the number of Texture that point to it)
  31542. */
  31543. incrementReferences(): void;
  31544. /**
  31545. * Change the size of the texture (not the size of the content)
  31546. * @param width defines the new width
  31547. * @param height defines the new height
  31548. * @param depth defines the new depth (1 by default)
  31549. */
  31550. updateSize(width: int, height: int, depth?: int): void;
  31551. /** @hidden */
  31552. _rebuild(): void;
  31553. /** @hidden */
  31554. _swapAndDie(target: InternalTexture): void;
  31555. /**
  31556. * Dispose the current allocated resources
  31557. */
  31558. dispose(): void;
  31559. }
  31560. }
  31561. declare module "babylonjs/Audio/analyser" {
  31562. import { Scene } from "babylonjs/scene";
  31563. /**
  31564. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31566. */
  31567. export class Analyser {
  31568. /**
  31569. * Gets or sets the smoothing
  31570. * @ignorenaming
  31571. */
  31572. SMOOTHING: number;
  31573. /**
  31574. * Gets or sets the FFT table size
  31575. * @ignorenaming
  31576. */
  31577. FFT_SIZE: number;
  31578. /**
  31579. * Gets or sets the bar graph amplitude
  31580. * @ignorenaming
  31581. */
  31582. BARGRAPHAMPLITUDE: number;
  31583. /**
  31584. * Gets or sets the position of the debug canvas
  31585. * @ignorenaming
  31586. */
  31587. DEBUGCANVASPOS: {
  31588. x: number;
  31589. y: number;
  31590. };
  31591. /**
  31592. * Gets or sets the debug canvas size
  31593. * @ignorenaming
  31594. */
  31595. DEBUGCANVASSIZE: {
  31596. width: number;
  31597. height: number;
  31598. };
  31599. private _byteFreqs;
  31600. private _byteTime;
  31601. private _floatFreqs;
  31602. private _webAudioAnalyser;
  31603. private _debugCanvas;
  31604. private _debugCanvasContext;
  31605. private _scene;
  31606. private _registerFunc;
  31607. private _audioEngine;
  31608. /**
  31609. * Creates a new analyser
  31610. * @param scene defines hosting scene
  31611. */
  31612. constructor(scene: Scene);
  31613. /**
  31614. * Get the number of data values you will have to play with for the visualization
  31615. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31616. * @returns a number
  31617. */
  31618. getFrequencyBinCount(): number;
  31619. /**
  31620. * Gets the current frequency data as a byte array
  31621. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31622. * @returns a Uint8Array
  31623. */
  31624. getByteFrequencyData(): Uint8Array;
  31625. /**
  31626. * Gets the current waveform as a byte array
  31627. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31628. * @returns a Uint8Array
  31629. */
  31630. getByteTimeDomainData(): Uint8Array;
  31631. /**
  31632. * Gets the current frequency data as a float array
  31633. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31634. * @returns a Float32Array
  31635. */
  31636. getFloatFrequencyData(): Float32Array;
  31637. /**
  31638. * Renders the debug canvas
  31639. */
  31640. drawDebugCanvas(): void;
  31641. /**
  31642. * Stops rendering the debug canvas and removes it
  31643. */
  31644. stopDebugCanvas(): void;
  31645. /**
  31646. * Connects two audio nodes
  31647. * @param inputAudioNode defines first node to connect
  31648. * @param outputAudioNode defines second node to connect
  31649. */
  31650. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31651. /**
  31652. * Releases all associated resources
  31653. */
  31654. dispose(): void;
  31655. }
  31656. }
  31657. declare module "babylonjs/Audio/audioEngine" {
  31658. import { IDisposable } from "babylonjs/scene";
  31659. import { Analyser } from "babylonjs/Audio/analyser";
  31660. import { Nullable } from "babylonjs/types";
  31661. import { Observable } from "babylonjs/Misc/observable";
  31662. /**
  31663. * This represents an audio engine and it is responsible
  31664. * to play, synchronize and analyse sounds throughout the application.
  31665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31666. */
  31667. export interface IAudioEngine extends IDisposable {
  31668. /**
  31669. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31670. */
  31671. readonly canUseWebAudio: boolean;
  31672. /**
  31673. * Gets the current AudioContext if available.
  31674. */
  31675. readonly audioContext: Nullable<AudioContext>;
  31676. /**
  31677. * The master gain node defines the global audio volume of your audio engine.
  31678. */
  31679. readonly masterGain: GainNode;
  31680. /**
  31681. * Gets whether or not mp3 are supported by your browser.
  31682. */
  31683. readonly isMP3supported: boolean;
  31684. /**
  31685. * Gets whether or not ogg are supported by your browser.
  31686. */
  31687. readonly isOGGsupported: boolean;
  31688. /**
  31689. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31690. * @ignoreNaming
  31691. */
  31692. WarnedWebAudioUnsupported: boolean;
  31693. /**
  31694. * Defines if the audio engine relies on a custom unlocked button.
  31695. * In this case, the embedded button will not be displayed.
  31696. */
  31697. useCustomUnlockedButton: boolean;
  31698. /**
  31699. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31700. */
  31701. readonly unlocked: boolean;
  31702. /**
  31703. * Event raised when audio has been unlocked on the browser.
  31704. */
  31705. onAudioUnlockedObservable: Observable<AudioEngine>;
  31706. /**
  31707. * Event raised when audio has been locked on the browser.
  31708. */
  31709. onAudioLockedObservable: Observable<AudioEngine>;
  31710. /**
  31711. * Flags the audio engine in Locked state.
  31712. * This happens due to new browser policies preventing audio to autoplay.
  31713. */
  31714. lock(): void;
  31715. /**
  31716. * Unlocks the audio engine once a user action has been done on the dom.
  31717. * This is helpful to resume play once browser policies have been satisfied.
  31718. */
  31719. unlock(): void;
  31720. }
  31721. /**
  31722. * This represents the default audio engine used in babylon.
  31723. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31725. */
  31726. export class AudioEngine implements IAudioEngine {
  31727. private _audioContext;
  31728. private _audioContextInitialized;
  31729. private _muteButton;
  31730. private _hostElement;
  31731. /**
  31732. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31733. */
  31734. canUseWebAudio: boolean;
  31735. /**
  31736. * The master gain node defines the global audio volume of your audio engine.
  31737. */
  31738. masterGain: GainNode;
  31739. /**
  31740. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31741. * @ignoreNaming
  31742. */
  31743. WarnedWebAudioUnsupported: boolean;
  31744. /**
  31745. * Gets whether or not mp3 are supported by your browser.
  31746. */
  31747. isMP3supported: boolean;
  31748. /**
  31749. * Gets whether or not ogg are supported by your browser.
  31750. */
  31751. isOGGsupported: boolean;
  31752. /**
  31753. * Gets whether audio has been unlocked on the device.
  31754. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31755. * a user interaction has happened.
  31756. */
  31757. unlocked: boolean;
  31758. /**
  31759. * Defines if the audio engine relies on a custom unlocked button.
  31760. * In this case, the embedded button will not be displayed.
  31761. */
  31762. useCustomUnlockedButton: boolean;
  31763. /**
  31764. * Event raised when audio has been unlocked on the browser.
  31765. */
  31766. onAudioUnlockedObservable: Observable<AudioEngine>;
  31767. /**
  31768. * Event raised when audio has been locked on the browser.
  31769. */
  31770. onAudioLockedObservable: Observable<AudioEngine>;
  31771. /**
  31772. * Gets the current AudioContext if available.
  31773. */
  31774. readonly audioContext: Nullable<AudioContext>;
  31775. private _connectedAnalyser;
  31776. /**
  31777. * Instantiates a new audio engine.
  31778. *
  31779. * There should be only one per page as some browsers restrict the number
  31780. * of audio contexts you can create.
  31781. * @param hostElement defines the host element where to display the mute icon if necessary
  31782. */
  31783. constructor(hostElement?: Nullable<HTMLElement>);
  31784. /**
  31785. * Flags the audio engine in Locked state.
  31786. * This happens due to new browser policies preventing audio to autoplay.
  31787. */
  31788. lock(): void;
  31789. /**
  31790. * Unlocks the audio engine once a user action has been done on the dom.
  31791. * This is helpful to resume play once browser policies have been satisfied.
  31792. */
  31793. unlock(): void;
  31794. private _resumeAudioContext;
  31795. private _initializeAudioContext;
  31796. private _tryToRun;
  31797. private _triggerRunningState;
  31798. private _triggerSuspendedState;
  31799. private _displayMuteButton;
  31800. private _moveButtonToTopLeft;
  31801. private _onResize;
  31802. private _hideMuteButton;
  31803. /**
  31804. * Destroy and release the resources associated with the audio ccontext.
  31805. */
  31806. dispose(): void;
  31807. /**
  31808. * Gets the global volume sets on the master gain.
  31809. * @returns the global volume if set or -1 otherwise
  31810. */
  31811. getGlobalVolume(): number;
  31812. /**
  31813. * Sets the global volume of your experience (sets on the master gain).
  31814. * @param newVolume Defines the new global volume of the application
  31815. */
  31816. setGlobalVolume(newVolume: number): void;
  31817. /**
  31818. * Connect the audio engine to an audio analyser allowing some amazing
  31819. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31821. * @param analyser The analyser to connect to the engine
  31822. */
  31823. connectToAnalyser(analyser: Analyser): void;
  31824. }
  31825. }
  31826. declare module "babylonjs/Loading/loadingScreen" {
  31827. /**
  31828. * Interface used to present a loading screen while loading a scene
  31829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31830. */
  31831. export interface ILoadingScreen {
  31832. /**
  31833. * Function called to display the loading screen
  31834. */
  31835. displayLoadingUI: () => void;
  31836. /**
  31837. * Function called to hide the loading screen
  31838. */
  31839. hideLoadingUI: () => void;
  31840. /**
  31841. * Gets or sets the color to use for the background
  31842. */
  31843. loadingUIBackgroundColor: string;
  31844. /**
  31845. * Gets or sets the text to display while loading
  31846. */
  31847. loadingUIText: string;
  31848. }
  31849. /**
  31850. * Class used for the default loading screen
  31851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31852. */
  31853. export class DefaultLoadingScreen implements ILoadingScreen {
  31854. private _renderingCanvas;
  31855. private _loadingText;
  31856. private _loadingDivBackgroundColor;
  31857. private _loadingDiv;
  31858. private _loadingTextDiv;
  31859. /** Gets or sets the logo url to use for the default loading screen */
  31860. static DefaultLogoUrl: string;
  31861. /** Gets or sets the spinner url to use for the default loading screen */
  31862. static DefaultSpinnerUrl: string;
  31863. /**
  31864. * Creates a new default loading screen
  31865. * @param _renderingCanvas defines the canvas used to render the scene
  31866. * @param _loadingText defines the default text to display
  31867. * @param _loadingDivBackgroundColor defines the default background color
  31868. */
  31869. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31870. /**
  31871. * Function called to display the loading screen
  31872. */
  31873. displayLoadingUI(): void;
  31874. /**
  31875. * Function called to hide the loading screen
  31876. */
  31877. hideLoadingUI(): void;
  31878. /**
  31879. * Gets or sets the text to display while loading
  31880. */
  31881. loadingUIText: string;
  31882. /**
  31883. * Gets or sets the color to use for the background
  31884. */
  31885. loadingUIBackgroundColor: string;
  31886. private _resizeLoadingUI;
  31887. }
  31888. }
  31889. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31890. /**
  31891. * Interface for any object that can request an animation frame
  31892. */
  31893. export interface ICustomAnimationFrameRequester {
  31894. /**
  31895. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31896. */
  31897. renderFunction?: Function;
  31898. /**
  31899. * Called to request the next frame to render to
  31900. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31901. */
  31902. requestAnimationFrame: Function;
  31903. /**
  31904. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31905. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31906. */
  31907. requestID?: number;
  31908. }
  31909. }
  31910. declare module "babylonjs/Misc/performanceMonitor" {
  31911. /**
  31912. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31913. */
  31914. export class PerformanceMonitor {
  31915. private _enabled;
  31916. private _rollingFrameTime;
  31917. private _lastFrameTimeMs;
  31918. /**
  31919. * constructor
  31920. * @param frameSampleSize The number of samples required to saturate the sliding window
  31921. */
  31922. constructor(frameSampleSize?: number);
  31923. /**
  31924. * Samples current frame
  31925. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31926. */
  31927. sampleFrame(timeMs?: number): void;
  31928. /**
  31929. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31930. */
  31931. readonly averageFrameTime: number;
  31932. /**
  31933. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31934. */
  31935. readonly averageFrameTimeVariance: number;
  31936. /**
  31937. * Returns the frame time of the most recent frame
  31938. */
  31939. readonly instantaneousFrameTime: number;
  31940. /**
  31941. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31942. */
  31943. readonly averageFPS: number;
  31944. /**
  31945. * Returns the average framerate in frames per second using the most recent frame time
  31946. */
  31947. readonly instantaneousFPS: number;
  31948. /**
  31949. * Returns true if enough samples have been taken to completely fill the sliding window
  31950. */
  31951. readonly isSaturated: boolean;
  31952. /**
  31953. * Enables contributions to the sliding window sample set
  31954. */
  31955. enable(): void;
  31956. /**
  31957. * Disables contributions to the sliding window sample set
  31958. * Samples will not be interpolated over the disabled period
  31959. */
  31960. disable(): void;
  31961. /**
  31962. * Returns true if sampling is enabled
  31963. */
  31964. readonly isEnabled: boolean;
  31965. /**
  31966. * Resets performance monitor
  31967. */
  31968. reset(): void;
  31969. }
  31970. /**
  31971. * RollingAverage
  31972. *
  31973. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31974. */
  31975. export class RollingAverage {
  31976. /**
  31977. * Current average
  31978. */
  31979. average: number;
  31980. /**
  31981. * Current variance
  31982. */
  31983. variance: number;
  31984. protected _samples: Array<number>;
  31985. protected _sampleCount: number;
  31986. protected _pos: number;
  31987. protected _m2: number;
  31988. /**
  31989. * constructor
  31990. * @param length The number of samples required to saturate the sliding window
  31991. */
  31992. constructor(length: number);
  31993. /**
  31994. * Adds a sample to the sample set
  31995. * @param v The sample value
  31996. */
  31997. add(v: number): void;
  31998. /**
  31999. * Returns previously added values or null if outside of history or outside the sliding window domain
  32000. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32001. * @return Value previously recorded with add() or null if outside of range
  32002. */
  32003. history(i: number): number;
  32004. /**
  32005. * Returns true if enough samples have been taken to completely fill the sliding window
  32006. * @return true if sample-set saturated
  32007. */
  32008. isSaturated(): boolean;
  32009. /**
  32010. * Resets the rolling average (equivalent to 0 samples taken so far)
  32011. */
  32012. reset(): void;
  32013. /**
  32014. * Wraps a value around the sample range boundaries
  32015. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32016. * @return Wrapped position in sample range
  32017. */
  32018. protected _wrapPosition(i: number): number;
  32019. }
  32020. }
  32021. declare module "babylonjs/Misc/perfCounter" {
  32022. /**
  32023. * This class is used to track a performance counter which is number based.
  32024. * The user has access to many properties which give statistics of different nature.
  32025. *
  32026. * The implementer can track two kinds of Performance Counter: time and count.
  32027. * 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.
  32028. * 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.
  32029. */
  32030. export class PerfCounter {
  32031. /**
  32032. * Gets or sets a global boolean to turn on and off all the counters
  32033. */
  32034. static Enabled: boolean;
  32035. /**
  32036. * Returns the smallest value ever
  32037. */
  32038. readonly min: number;
  32039. /**
  32040. * Returns the biggest value ever
  32041. */
  32042. readonly max: number;
  32043. /**
  32044. * Returns the average value since the performance counter is running
  32045. */
  32046. readonly average: number;
  32047. /**
  32048. * Returns the average value of the last second the counter was monitored
  32049. */
  32050. readonly lastSecAverage: number;
  32051. /**
  32052. * Returns the current value
  32053. */
  32054. readonly current: number;
  32055. /**
  32056. * Gets the accumulated total
  32057. */
  32058. readonly total: number;
  32059. /**
  32060. * Gets the total value count
  32061. */
  32062. readonly count: number;
  32063. /**
  32064. * Creates a new counter
  32065. */
  32066. constructor();
  32067. /**
  32068. * Call this method to start monitoring a new frame.
  32069. * 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.
  32070. */
  32071. fetchNewFrame(): void;
  32072. /**
  32073. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32074. * @param newCount the count value to add to the monitored count
  32075. * @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.
  32076. */
  32077. addCount(newCount: number, fetchResult: boolean): void;
  32078. /**
  32079. * Start monitoring this performance counter
  32080. */
  32081. beginMonitoring(): void;
  32082. /**
  32083. * Compute the time lapsed since the previous beginMonitoring() call.
  32084. * @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
  32085. */
  32086. endMonitoring(newFrame?: boolean): void;
  32087. private _fetchResult;
  32088. private _startMonitoringTime;
  32089. private _min;
  32090. private _max;
  32091. private _average;
  32092. private _current;
  32093. private _totalValueCount;
  32094. private _totalAccumulated;
  32095. private _lastSecAverage;
  32096. private _lastSecAccumulated;
  32097. private _lastSecTime;
  32098. private _lastSecValueCount;
  32099. }
  32100. }
  32101. declare module "babylonjs/Engines/engine" {
  32102. import { Observable } from "babylonjs/Misc/observable";
  32103. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32104. import { Scene } from "babylonjs/scene";
  32105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32106. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32107. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32108. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32109. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32110. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32111. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32112. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32113. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32114. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32115. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32116. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32117. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32118. import { Material } from "babylonjs/Materials/material";
  32119. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32120. /**
  32121. * Defines the interface used by display changed events
  32122. */
  32123. export interface IDisplayChangedEventArgs {
  32124. /** Gets the vrDisplay object (if any) */
  32125. vrDisplay: Nullable<any>;
  32126. /** Gets a boolean indicating if webVR is supported */
  32127. vrSupported: boolean;
  32128. }
  32129. /**
  32130. * Defines the interface used by objects containing a viewport (like a camera)
  32131. */
  32132. interface IViewportOwnerLike {
  32133. /**
  32134. * Gets or sets the viewport
  32135. */
  32136. viewport: IViewportLike;
  32137. }
  32138. /**
  32139. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32140. */
  32141. export class Engine extends ThinEngine {
  32142. /** Defines that alpha blending is disabled */
  32143. static readonly ALPHA_DISABLE: number;
  32144. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32145. static readonly ALPHA_ADD: number;
  32146. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32147. static readonly ALPHA_COMBINE: number;
  32148. /** Defines that alpha blending to DEST - SRC * DEST */
  32149. static readonly ALPHA_SUBTRACT: number;
  32150. /** Defines that alpha blending to SRC * DEST */
  32151. static readonly ALPHA_MULTIPLY: number;
  32152. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32153. static readonly ALPHA_MAXIMIZED: number;
  32154. /** Defines that alpha blending to SRC + DEST */
  32155. static readonly ALPHA_ONEONE: number;
  32156. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32157. static readonly ALPHA_PREMULTIPLIED: number;
  32158. /**
  32159. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32160. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32161. */
  32162. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32163. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32164. static readonly ALPHA_INTERPOLATE: number;
  32165. /**
  32166. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32167. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32168. */
  32169. static readonly ALPHA_SCREENMODE: number;
  32170. /** Defines that the ressource is not delayed*/
  32171. static readonly DELAYLOADSTATE_NONE: number;
  32172. /** Defines that the ressource was successfully delay loaded */
  32173. static readonly DELAYLOADSTATE_LOADED: number;
  32174. /** Defines that the ressource is currently delay loading */
  32175. static readonly DELAYLOADSTATE_LOADING: number;
  32176. /** Defines that the ressource is delayed and has not started loading */
  32177. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32178. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32179. static readonly NEVER: number;
  32180. /** 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 */
  32181. static readonly ALWAYS: number;
  32182. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32183. static readonly LESS: number;
  32184. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32185. static readonly EQUAL: number;
  32186. /** 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 */
  32187. static readonly LEQUAL: number;
  32188. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32189. static readonly GREATER: number;
  32190. /** 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 */
  32191. static readonly GEQUAL: number;
  32192. /** 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 */
  32193. static readonly NOTEQUAL: number;
  32194. /** Passed to stencilOperation to specify that stencil value must be kept */
  32195. static readonly KEEP: number;
  32196. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32197. static readonly REPLACE: number;
  32198. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32199. static readonly INCR: number;
  32200. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32201. static readonly DECR: number;
  32202. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32203. static readonly INVERT: number;
  32204. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32205. static readonly INCR_WRAP: number;
  32206. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32207. static readonly DECR_WRAP: number;
  32208. /** Texture is not repeating outside of 0..1 UVs */
  32209. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32210. /** Texture is repeating outside of 0..1 UVs */
  32211. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32212. /** Texture is repeating and mirrored */
  32213. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32214. /** ALPHA */
  32215. static readonly TEXTUREFORMAT_ALPHA: number;
  32216. /** LUMINANCE */
  32217. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32218. /** LUMINANCE_ALPHA */
  32219. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32220. /** RGB */
  32221. static readonly TEXTUREFORMAT_RGB: number;
  32222. /** RGBA */
  32223. static readonly TEXTUREFORMAT_RGBA: number;
  32224. /** RED */
  32225. static readonly TEXTUREFORMAT_RED: number;
  32226. /** RED (2nd reference) */
  32227. static readonly TEXTUREFORMAT_R: number;
  32228. /** RG */
  32229. static readonly TEXTUREFORMAT_RG: number;
  32230. /** RED_INTEGER */
  32231. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32232. /** RED_INTEGER (2nd reference) */
  32233. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32234. /** RG_INTEGER */
  32235. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32236. /** RGB_INTEGER */
  32237. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32238. /** RGBA_INTEGER */
  32239. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32240. /** UNSIGNED_BYTE */
  32241. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32242. /** UNSIGNED_BYTE (2nd reference) */
  32243. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32244. /** FLOAT */
  32245. static readonly TEXTURETYPE_FLOAT: number;
  32246. /** HALF_FLOAT */
  32247. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32248. /** BYTE */
  32249. static readonly TEXTURETYPE_BYTE: number;
  32250. /** SHORT */
  32251. static readonly TEXTURETYPE_SHORT: number;
  32252. /** UNSIGNED_SHORT */
  32253. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32254. /** INT */
  32255. static readonly TEXTURETYPE_INT: number;
  32256. /** UNSIGNED_INT */
  32257. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32258. /** UNSIGNED_SHORT_4_4_4_4 */
  32259. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32260. /** UNSIGNED_SHORT_5_5_5_1 */
  32261. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32262. /** UNSIGNED_SHORT_5_6_5 */
  32263. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32264. /** UNSIGNED_INT_2_10_10_10_REV */
  32265. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32266. /** UNSIGNED_INT_24_8 */
  32267. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32268. /** UNSIGNED_INT_10F_11F_11F_REV */
  32269. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32270. /** UNSIGNED_INT_5_9_9_9_REV */
  32271. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32272. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32273. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32274. /** nearest is mag = nearest and min = nearest and mip = linear */
  32275. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32276. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32277. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32278. /** Trilinear is mag = linear and min = linear and mip = linear */
  32279. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32280. /** nearest is mag = nearest and min = nearest and mip = linear */
  32281. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32282. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32283. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32284. /** Trilinear is mag = linear and min = linear and mip = linear */
  32285. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32286. /** mag = nearest and min = nearest and mip = nearest */
  32287. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32288. /** mag = nearest and min = linear and mip = nearest */
  32289. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32290. /** mag = nearest and min = linear and mip = linear */
  32291. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32292. /** mag = nearest and min = linear and mip = none */
  32293. static readonly TEXTURE_NEAREST_LINEAR: number;
  32294. /** mag = nearest and min = nearest and mip = none */
  32295. static readonly TEXTURE_NEAREST_NEAREST: number;
  32296. /** mag = linear and min = nearest and mip = nearest */
  32297. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32298. /** mag = linear and min = nearest and mip = linear */
  32299. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32300. /** mag = linear and min = linear and mip = none */
  32301. static readonly TEXTURE_LINEAR_LINEAR: number;
  32302. /** mag = linear and min = nearest and mip = none */
  32303. static readonly TEXTURE_LINEAR_NEAREST: number;
  32304. /** Explicit coordinates mode */
  32305. static readonly TEXTURE_EXPLICIT_MODE: number;
  32306. /** Spherical coordinates mode */
  32307. static readonly TEXTURE_SPHERICAL_MODE: number;
  32308. /** Planar coordinates mode */
  32309. static readonly TEXTURE_PLANAR_MODE: number;
  32310. /** Cubic coordinates mode */
  32311. static readonly TEXTURE_CUBIC_MODE: number;
  32312. /** Projection coordinates mode */
  32313. static readonly TEXTURE_PROJECTION_MODE: number;
  32314. /** Skybox coordinates mode */
  32315. static readonly TEXTURE_SKYBOX_MODE: number;
  32316. /** Inverse Cubic coordinates mode */
  32317. static readonly TEXTURE_INVCUBIC_MODE: number;
  32318. /** Equirectangular coordinates mode */
  32319. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32320. /** Equirectangular Fixed coordinates mode */
  32321. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32322. /** Equirectangular Fixed Mirrored coordinates mode */
  32323. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32324. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32325. static readonly SCALEMODE_FLOOR: number;
  32326. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32327. static readonly SCALEMODE_NEAREST: number;
  32328. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32329. static readonly SCALEMODE_CEILING: number;
  32330. /**
  32331. * Returns the current npm package of the sdk
  32332. */
  32333. static readonly NpmPackage: string;
  32334. /**
  32335. * Returns the current version of the framework
  32336. */
  32337. static readonly Version: string;
  32338. /** Gets the list of created engines */
  32339. static readonly Instances: Engine[];
  32340. /**
  32341. * Gets the latest created engine
  32342. */
  32343. static readonly LastCreatedEngine: Nullable<Engine>;
  32344. /**
  32345. * Gets the latest created scene
  32346. */
  32347. static readonly LastCreatedScene: Nullable<Scene>;
  32348. /**
  32349. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32350. * @param flag defines which part of the materials must be marked as dirty
  32351. * @param predicate defines a predicate used to filter which materials should be affected
  32352. */
  32353. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32354. /**
  32355. * Method called to create the default loading screen.
  32356. * This can be overriden in your own app.
  32357. * @param canvas The rendering canvas element
  32358. * @returns The loading screen
  32359. */
  32360. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32361. /**
  32362. * Method called to create the default rescale post process on each engine.
  32363. */
  32364. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32365. /**
  32366. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32367. **/
  32368. enableOfflineSupport: boolean;
  32369. /**
  32370. * 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)
  32371. **/
  32372. disableManifestCheck: boolean;
  32373. /**
  32374. * Gets the list of created scenes
  32375. */
  32376. scenes: Scene[];
  32377. /**
  32378. * Event raised when a new scene is created
  32379. */
  32380. onNewSceneAddedObservable: Observable<Scene>;
  32381. /**
  32382. * Gets the list of created postprocesses
  32383. */
  32384. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32385. /**
  32386. * Gets a boolean indicating if the pointer is currently locked
  32387. */
  32388. isPointerLock: boolean;
  32389. /**
  32390. * Observable event triggered each time the rendering canvas is resized
  32391. */
  32392. onResizeObservable: Observable<Engine>;
  32393. /**
  32394. * Observable event triggered each time the canvas loses focus
  32395. */
  32396. onCanvasBlurObservable: Observable<Engine>;
  32397. /**
  32398. * Observable event triggered each time the canvas gains focus
  32399. */
  32400. onCanvasFocusObservable: Observable<Engine>;
  32401. /**
  32402. * Observable event triggered each time the canvas receives pointerout event
  32403. */
  32404. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32405. /**
  32406. * Observable raised when the engine begins a new frame
  32407. */
  32408. onBeginFrameObservable: Observable<Engine>;
  32409. /**
  32410. * If set, will be used to request the next animation frame for the render loop
  32411. */
  32412. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32413. /**
  32414. * Observable raised when the engine ends the current frame
  32415. */
  32416. onEndFrameObservable: Observable<Engine>;
  32417. /**
  32418. * Observable raised when the engine is about to compile a shader
  32419. */
  32420. onBeforeShaderCompilationObservable: Observable<Engine>;
  32421. /**
  32422. * Observable raised when the engine has jsut compiled a shader
  32423. */
  32424. onAfterShaderCompilationObservable: Observable<Engine>;
  32425. /**
  32426. * Gets the audio engine
  32427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32428. * @ignorenaming
  32429. */
  32430. static audioEngine: IAudioEngine;
  32431. /**
  32432. * Default AudioEngine factory responsible of creating the Audio Engine.
  32433. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32434. */
  32435. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32436. /**
  32437. * Default offline support factory responsible of creating a tool used to store data locally.
  32438. * By default, this will create a Database object if the workload has been embedded.
  32439. */
  32440. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32441. private _loadingScreen;
  32442. private _pointerLockRequested;
  32443. private _dummyFramebuffer;
  32444. private _rescalePostProcess;
  32445. /** @hidden */
  32446. protected _alphaMode: number;
  32447. /** @hidden */
  32448. protected _alphaEquation: number;
  32449. private _deterministicLockstep;
  32450. private _lockstepMaxSteps;
  32451. protected readonly _supportsHardwareTextureRescaling: boolean;
  32452. private _fps;
  32453. private _deltaTime;
  32454. /** @hidden */
  32455. _drawCalls: PerfCounter;
  32456. /**
  32457. * Turn this value on if you want to pause FPS computation when in background
  32458. */
  32459. disablePerformanceMonitorInBackground: boolean;
  32460. private _performanceMonitor;
  32461. /**
  32462. * Gets the performance monitor attached to this engine
  32463. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32464. */
  32465. readonly performanceMonitor: PerformanceMonitor;
  32466. private _onFocus;
  32467. private _onBlur;
  32468. private _onCanvasPointerOut;
  32469. private _onCanvasBlur;
  32470. private _onCanvasFocus;
  32471. private _onFullscreenChange;
  32472. private _onPointerLockChange;
  32473. /**
  32474. * Gets the HTML element used to attach event listeners
  32475. * @returns a HTML element
  32476. */
  32477. getInputElement(): Nullable<HTMLElement>;
  32478. /**
  32479. * Creates a new engine
  32480. * @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
  32481. * @param antialias defines enable antialiasing (default: false)
  32482. * @param options defines further options to be sent to the getContext() function
  32483. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32484. */
  32485. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32486. /**
  32487. * Gets current aspect ratio
  32488. * @param viewportOwner defines the camera to use to get the aspect ratio
  32489. * @param useScreen defines if screen size must be used (or the current render target if any)
  32490. * @returns a number defining the aspect ratio
  32491. */
  32492. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32493. /**
  32494. * Gets current screen aspect ratio
  32495. * @returns a number defining the aspect ratio
  32496. */
  32497. getScreenAspectRatio(): number;
  32498. /**
  32499. * Gets host document
  32500. * @returns the host document object
  32501. */
  32502. getHostDocument(): Document;
  32503. /**
  32504. * Gets the client rect of the HTML canvas attached with the current webGL context
  32505. * @returns a client rectanglee
  32506. */
  32507. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32508. /**
  32509. * Gets the client rect of the HTML element used for events
  32510. * @returns a client rectanglee
  32511. */
  32512. getInputElementClientRect(): Nullable<ClientRect>;
  32513. /**
  32514. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32516. * @returns true if engine is in deterministic lock step mode
  32517. */
  32518. isDeterministicLockStep(): boolean;
  32519. /**
  32520. * Gets the max steps when engine is running in deterministic lock step
  32521. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32522. * @returns the max steps
  32523. */
  32524. getLockstepMaxSteps(): number;
  32525. /**
  32526. * Force the mipmap generation for the given render target texture
  32527. * @param texture defines the render target texture to use
  32528. */
  32529. generateMipMapsForCubemap(texture: InternalTexture): void;
  32530. /** States */
  32531. /**
  32532. * Set various states to the webGL context
  32533. * @param culling defines backface culling state
  32534. * @param zOffset defines the value to apply to zOffset (0 by default)
  32535. * @param force defines if states must be applied even if cache is up to date
  32536. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32537. */
  32538. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32539. /**
  32540. * Set the z offset to apply to current rendering
  32541. * @param value defines the offset to apply
  32542. */
  32543. setZOffset(value: number): void;
  32544. /**
  32545. * Gets the current value of the zOffset
  32546. * @returns the current zOffset state
  32547. */
  32548. getZOffset(): number;
  32549. /**
  32550. * Enable or disable depth buffering
  32551. * @param enable defines the state to set
  32552. */
  32553. setDepthBuffer(enable: boolean): void;
  32554. /**
  32555. * Gets a boolean indicating if depth writing is enabled
  32556. * @returns the current depth writing state
  32557. */
  32558. getDepthWrite(): boolean;
  32559. /**
  32560. * Enable or disable depth writing
  32561. * @param enable defines the state to set
  32562. */
  32563. setDepthWrite(enable: boolean): void;
  32564. /**
  32565. * Enable or disable color writing
  32566. * @param enable defines the state to set
  32567. */
  32568. setColorWrite(enable: boolean): void;
  32569. /**
  32570. * Gets a boolean indicating if color writing is enabled
  32571. * @returns the current color writing state
  32572. */
  32573. getColorWrite(): boolean;
  32574. /**
  32575. * Sets alpha constants used by some alpha blending modes
  32576. * @param r defines the red component
  32577. * @param g defines the green component
  32578. * @param b defines the blue component
  32579. * @param a defines the alpha component
  32580. */
  32581. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32582. /**
  32583. * Sets the current alpha mode
  32584. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32585. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32586. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32587. */
  32588. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32589. /**
  32590. * Gets the current alpha mode
  32591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32592. * @returns the current alpha mode
  32593. */
  32594. getAlphaMode(): number;
  32595. /**
  32596. * Sets the current alpha equation
  32597. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32598. */
  32599. setAlphaEquation(equation: number): void;
  32600. /**
  32601. * Gets the current alpha equation.
  32602. * @returns the current alpha equation
  32603. */
  32604. getAlphaEquation(): number;
  32605. /**
  32606. * Gets a boolean indicating if stencil buffer is enabled
  32607. * @returns the current stencil buffer state
  32608. */
  32609. getStencilBuffer(): boolean;
  32610. /**
  32611. * Enable or disable the stencil buffer
  32612. * @param enable defines if the stencil buffer must be enabled or disabled
  32613. */
  32614. setStencilBuffer(enable: boolean): void;
  32615. /**
  32616. * Gets the current stencil mask
  32617. * @returns a number defining the new stencil mask to use
  32618. */
  32619. getStencilMask(): number;
  32620. /**
  32621. * Sets the current stencil mask
  32622. * @param mask defines the new stencil mask to use
  32623. */
  32624. setStencilMask(mask: number): void;
  32625. /**
  32626. * Gets the current stencil function
  32627. * @returns a number defining the stencil function to use
  32628. */
  32629. getStencilFunction(): number;
  32630. /**
  32631. * Gets the current stencil reference value
  32632. * @returns a number defining the stencil reference value to use
  32633. */
  32634. getStencilFunctionReference(): number;
  32635. /**
  32636. * Gets the current stencil mask
  32637. * @returns a number defining the stencil mask to use
  32638. */
  32639. getStencilFunctionMask(): number;
  32640. /**
  32641. * Sets the current stencil function
  32642. * @param stencilFunc defines the new stencil function to use
  32643. */
  32644. setStencilFunction(stencilFunc: number): void;
  32645. /**
  32646. * Sets the current stencil reference
  32647. * @param reference defines the new stencil reference to use
  32648. */
  32649. setStencilFunctionReference(reference: number): void;
  32650. /**
  32651. * Sets the current stencil mask
  32652. * @param mask defines the new stencil mask to use
  32653. */
  32654. setStencilFunctionMask(mask: number): void;
  32655. /**
  32656. * Gets the current stencil operation when stencil fails
  32657. * @returns a number defining stencil operation to use when stencil fails
  32658. */
  32659. getStencilOperationFail(): number;
  32660. /**
  32661. * Gets the current stencil operation when depth fails
  32662. * @returns a number defining stencil operation to use when depth fails
  32663. */
  32664. getStencilOperationDepthFail(): number;
  32665. /**
  32666. * Gets the current stencil operation when stencil passes
  32667. * @returns a number defining stencil operation to use when stencil passes
  32668. */
  32669. getStencilOperationPass(): number;
  32670. /**
  32671. * Sets the stencil operation to use when stencil fails
  32672. * @param operation defines the stencil operation to use when stencil fails
  32673. */
  32674. setStencilOperationFail(operation: number): void;
  32675. /**
  32676. * Sets the stencil operation to use when depth fails
  32677. * @param operation defines the stencil operation to use when depth fails
  32678. */
  32679. setStencilOperationDepthFail(operation: number): void;
  32680. /**
  32681. * Sets the stencil operation to use when stencil passes
  32682. * @param operation defines the stencil operation to use when stencil passes
  32683. */
  32684. setStencilOperationPass(operation: number): void;
  32685. /**
  32686. * Sets a boolean indicating if the dithering state is enabled or disabled
  32687. * @param value defines the dithering state
  32688. */
  32689. setDitheringState(value: boolean): void;
  32690. /**
  32691. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32692. * @param value defines the rasterizer state
  32693. */
  32694. setRasterizerState(value: boolean): void;
  32695. /**
  32696. * Gets the current depth function
  32697. * @returns a number defining the depth function
  32698. */
  32699. getDepthFunction(): Nullable<number>;
  32700. /**
  32701. * Sets the current depth function
  32702. * @param depthFunc defines the function to use
  32703. */
  32704. setDepthFunction(depthFunc: number): void;
  32705. /**
  32706. * Sets the current depth function to GREATER
  32707. */
  32708. setDepthFunctionToGreater(): void;
  32709. /**
  32710. * Sets the current depth function to GEQUAL
  32711. */
  32712. setDepthFunctionToGreaterOrEqual(): void;
  32713. /**
  32714. * Sets the current depth function to LESS
  32715. */
  32716. setDepthFunctionToLess(): void;
  32717. /**
  32718. * Sets the current depth function to LEQUAL
  32719. */
  32720. setDepthFunctionToLessOrEqual(): void;
  32721. private _cachedStencilBuffer;
  32722. private _cachedStencilFunction;
  32723. private _cachedStencilMask;
  32724. private _cachedStencilOperationPass;
  32725. private _cachedStencilOperationFail;
  32726. private _cachedStencilOperationDepthFail;
  32727. private _cachedStencilReference;
  32728. /**
  32729. * Caches the the state of the stencil buffer
  32730. */
  32731. cacheStencilState(): void;
  32732. /**
  32733. * Restores the state of the stencil buffer
  32734. */
  32735. restoreStencilState(): void;
  32736. /**
  32737. * Directly set the WebGL Viewport
  32738. * @param x defines the x coordinate of the viewport (in screen space)
  32739. * @param y defines the y coordinate of the viewport (in screen space)
  32740. * @param width defines the width of the viewport (in screen space)
  32741. * @param height defines the height of the viewport (in screen space)
  32742. * @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
  32743. */
  32744. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32745. /**
  32746. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32747. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32748. * @param y defines the y-coordinate of the corner of the clear rectangle
  32749. * @param width defines the width of the clear rectangle
  32750. * @param height defines the height of the clear rectangle
  32751. * @param clearColor defines the clear color
  32752. */
  32753. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32754. /**
  32755. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32756. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32757. * @param y defines the y-coordinate of the corner of the clear rectangle
  32758. * @param width defines the width of the clear rectangle
  32759. * @param height defines the height of the clear rectangle
  32760. */
  32761. enableScissor(x: number, y: number, width: number, height: number): void;
  32762. /**
  32763. * Disable previously set scissor test rectangle
  32764. */
  32765. disableScissor(): void;
  32766. protected _reportDrawCall(): void;
  32767. /**
  32768. * Initializes a webVR display and starts listening to display change events
  32769. * The onVRDisplayChangedObservable will be notified upon these changes
  32770. * @returns The onVRDisplayChangedObservable
  32771. */
  32772. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32773. /** @hidden */
  32774. _prepareVRComponent(): void;
  32775. /** @hidden */
  32776. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32777. /** @hidden */
  32778. _submitVRFrame(): void;
  32779. /**
  32780. * Call this function to leave webVR mode
  32781. * Will do nothing if webVR is not supported or if there is no webVR device
  32782. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32783. */
  32784. disableVR(): void;
  32785. /**
  32786. * Gets a boolean indicating that the system is in VR mode and is presenting
  32787. * @returns true if VR mode is engaged
  32788. */
  32789. isVRPresenting(): boolean;
  32790. /** @hidden */
  32791. _requestVRFrame(): void;
  32792. /** @hidden */
  32793. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32794. /**
  32795. * Gets the source code of the vertex shader associated with a specific webGL program
  32796. * @param program defines the program to use
  32797. * @returns a string containing the source code of the vertex shader associated with the program
  32798. */
  32799. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32800. /**
  32801. * Gets the source code of the fragment shader associated with a specific webGL program
  32802. * @param program defines the program to use
  32803. * @returns a string containing the source code of the fragment shader associated with the program
  32804. */
  32805. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32806. /**
  32807. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32808. * @param x defines the x coordinate of the rectangle where pixels must be read
  32809. * @param y defines the y coordinate of the rectangle where pixels must be read
  32810. * @param width defines the width of the rectangle where pixels must be read
  32811. * @param height defines the height of the rectangle where pixels must be read
  32812. * @returns a Uint8Array containing RGBA colors
  32813. */
  32814. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32815. /**
  32816. * Sets a depth stencil texture from a render target to the according uniform.
  32817. * @param channel The texture channel
  32818. * @param uniform The uniform to set
  32819. * @param texture The render target texture containing the depth stencil texture to apply
  32820. */
  32821. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32822. /**
  32823. * Sets a texture to the webGL context from a postprocess
  32824. * @param channel defines the channel to use
  32825. * @param postProcess defines the source postprocess
  32826. */
  32827. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32828. /**
  32829. * Binds the output of the passed in post process to the texture channel specified
  32830. * @param channel The channel the texture should be bound to
  32831. * @param postProcess The post process which's output should be bound
  32832. */
  32833. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32834. /** @hidden */
  32835. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32836. protected _rebuildBuffers(): void;
  32837. /** @hidden */
  32838. _renderFrame(): void;
  32839. _renderLoop(): void;
  32840. /** @hidden */
  32841. _renderViews(): boolean;
  32842. /**
  32843. * Toggle full screen mode
  32844. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32845. */
  32846. switchFullscreen(requestPointerLock: boolean): void;
  32847. /**
  32848. * Enters full screen mode
  32849. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32850. */
  32851. enterFullscreen(requestPointerLock: boolean): void;
  32852. /**
  32853. * Exits full screen mode
  32854. */
  32855. exitFullscreen(): void;
  32856. /**
  32857. * Enters Pointerlock mode
  32858. */
  32859. enterPointerlock(): void;
  32860. /**
  32861. * Exits Pointerlock mode
  32862. */
  32863. exitPointerlock(): void;
  32864. /**
  32865. * Begin a new frame
  32866. */
  32867. beginFrame(): void;
  32868. /**
  32869. * Enf the current frame
  32870. */
  32871. endFrame(): void;
  32872. resize(): void;
  32873. /**
  32874. * Set the compressed texture format to use, based on the formats you have, and the formats
  32875. * supported by the hardware / browser.
  32876. *
  32877. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32878. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32879. * to API arguments needed to compressed textures. This puts the burden on the container
  32880. * generator to house the arcane code for determining these for current & future formats.
  32881. *
  32882. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32883. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32884. *
  32885. * Note: The result of this call is not taken into account when a texture is base64.
  32886. *
  32887. * @param formatsAvailable defines the list of those format families you have created
  32888. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32889. *
  32890. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32891. * @returns The extension selected.
  32892. */
  32893. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32894. /**
  32895. * Force a specific size of the canvas
  32896. * @param width defines the new canvas' width
  32897. * @param height defines the new canvas' height
  32898. */
  32899. setSize(width: number, height: number): void;
  32900. /**
  32901. * Updates a dynamic vertex buffer.
  32902. * @param vertexBuffer the vertex buffer to update
  32903. * @param data the data used to update the vertex buffer
  32904. * @param byteOffset the byte offset of the data
  32905. * @param byteLength the byte length of the data
  32906. */
  32907. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32908. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32909. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32910. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32911. _releaseTexture(texture: InternalTexture): void;
  32912. /**
  32913. * @hidden
  32914. * Rescales a texture
  32915. * @param source input texutre
  32916. * @param destination destination texture
  32917. * @param scene scene to use to render the resize
  32918. * @param internalFormat format to use when resizing
  32919. * @param onComplete callback to be called when resize has completed
  32920. */
  32921. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32922. /**
  32923. * Gets the current framerate
  32924. * @returns a number representing the framerate
  32925. */
  32926. getFps(): number;
  32927. /**
  32928. * Gets the time spent between current and previous frame
  32929. * @returns a number representing the delta time in ms
  32930. */
  32931. getDeltaTime(): number;
  32932. private _measureFps;
  32933. /** @hidden */
  32934. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32935. /**
  32936. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32937. * @param renderTarget The render target to set the frame buffer for
  32938. */
  32939. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32940. /**
  32941. * Update a dynamic index buffer
  32942. * @param indexBuffer defines the target index buffer
  32943. * @param indices defines the data to update
  32944. * @param offset defines the offset in the target index buffer where update should start
  32945. */
  32946. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32947. /**
  32948. * Updates the sample count of a render target texture
  32949. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32950. * @param texture defines the texture to update
  32951. * @param samples defines the sample count to set
  32952. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32953. */
  32954. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32955. /**
  32956. * Updates a depth texture Comparison Mode and Function.
  32957. * If the comparison Function is equal to 0, the mode will be set to none.
  32958. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32959. * @param texture The texture to set the comparison function for
  32960. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32961. */
  32962. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32963. /**
  32964. * Creates a webGL buffer to use with instanciation
  32965. * @param capacity defines the size of the buffer
  32966. * @returns the webGL buffer
  32967. */
  32968. createInstancesBuffer(capacity: number): DataBuffer;
  32969. /**
  32970. * Delete a webGL buffer used with instanciation
  32971. * @param buffer defines the webGL buffer to delete
  32972. */
  32973. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32974. /** @hidden */
  32975. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32976. dispose(): void;
  32977. private _disableTouchAction;
  32978. /**
  32979. * Display the loading screen
  32980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32981. */
  32982. displayLoadingUI(): void;
  32983. /**
  32984. * Hide the loading screen
  32985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32986. */
  32987. hideLoadingUI(): void;
  32988. /**
  32989. * Gets the current loading screen object
  32990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32991. */
  32992. /**
  32993. * Sets the current loading screen object
  32994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32995. */
  32996. loadingScreen: ILoadingScreen;
  32997. /**
  32998. * Sets the current loading screen text
  32999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33000. */
  33001. loadingUIText: string;
  33002. /**
  33003. * Sets the current loading screen background color
  33004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33005. */
  33006. loadingUIBackgroundColor: string;
  33007. /** Pointerlock and fullscreen */
  33008. /**
  33009. * Ask the browser to promote the current element to pointerlock mode
  33010. * @param element defines the DOM element to promote
  33011. */
  33012. static _RequestPointerlock(element: HTMLElement): void;
  33013. /**
  33014. * Asks the browser to exit pointerlock mode
  33015. */
  33016. static _ExitPointerlock(): void;
  33017. /**
  33018. * Ask the browser to promote the current element to fullscreen rendering mode
  33019. * @param element defines the DOM element to promote
  33020. */
  33021. static _RequestFullscreen(element: HTMLElement): void;
  33022. /**
  33023. * Asks the browser to exit fullscreen mode
  33024. */
  33025. static _ExitFullscreen(): void;
  33026. }
  33027. }
  33028. declare module "babylonjs/Engines/engineStore" {
  33029. import { Nullable } from "babylonjs/types";
  33030. import { Engine } from "babylonjs/Engines/engine";
  33031. import { Scene } from "babylonjs/scene";
  33032. /**
  33033. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33034. * during the life time of the application.
  33035. */
  33036. export class EngineStore {
  33037. /** Gets the list of created engines */
  33038. static Instances: import("babylonjs/Engines/engine").Engine[];
  33039. /** @hidden */
  33040. static _LastCreatedScene: Nullable<Scene>;
  33041. /**
  33042. * Gets the latest created engine
  33043. */
  33044. static readonly LastCreatedEngine: Nullable<Engine>;
  33045. /**
  33046. * Gets the latest created scene
  33047. */
  33048. static readonly LastCreatedScene: Nullable<Scene>;
  33049. /**
  33050. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33051. * @ignorenaming
  33052. */
  33053. static UseFallbackTexture: boolean;
  33054. /**
  33055. * Texture content used if a texture cannot loaded
  33056. * @ignorenaming
  33057. */
  33058. static FallbackTexture: string;
  33059. }
  33060. }
  33061. declare module "babylonjs/Misc/promise" {
  33062. /**
  33063. * Helper class that provides a small promise polyfill
  33064. */
  33065. export class PromisePolyfill {
  33066. /**
  33067. * Static function used to check if the polyfill is required
  33068. * If this is the case then the function will inject the polyfill to window.Promise
  33069. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33070. */
  33071. static Apply(force?: boolean): void;
  33072. }
  33073. }
  33074. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33075. /**
  33076. * Interface for screenshot methods with describe argument called `size` as object with options
  33077. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33078. */
  33079. export interface IScreenshotSize {
  33080. /**
  33081. * number in pixels for canvas height
  33082. */
  33083. height?: number;
  33084. /**
  33085. * multiplier allowing render at a higher or lower resolution
  33086. * If value is defined then height and width will be ignored and taken from camera
  33087. */
  33088. precision?: number;
  33089. /**
  33090. * number in pixels for canvas width
  33091. */
  33092. width?: number;
  33093. }
  33094. }
  33095. declare module "babylonjs/Misc/tools" {
  33096. import { Nullable, float } from "babylonjs/types";
  33097. import { DomManagement } from "babylonjs/Misc/domManagement";
  33098. import { WebRequest } from "babylonjs/Misc/webRequest";
  33099. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33100. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33101. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33102. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33103. import { Camera } from "babylonjs/Cameras/camera";
  33104. import { Engine } from "babylonjs/Engines/engine";
  33105. interface IColor4Like {
  33106. r: float;
  33107. g: float;
  33108. b: float;
  33109. a: float;
  33110. }
  33111. /**
  33112. * Class containing a set of static utilities functions
  33113. */
  33114. export class Tools {
  33115. /**
  33116. * Gets or sets the base URL to use to load assets
  33117. */
  33118. static BaseUrl: string;
  33119. /**
  33120. * Enable/Disable Custom HTTP Request Headers globally.
  33121. * default = false
  33122. * @see CustomRequestHeaders
  33123. */
  33124. static UseCustomRequestHeaders: boolean;
  33125. /**
  33126. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33127. * i.e. when loading files, where the server/service expects an Authorization header
  33128. */
  33129. static CustomRequestHeaders: {
  33130. [key: string]: string;
  33131. };
  33132. /**
  33133. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33134. */
  33135. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33136. /**
  33137. * Default behaviour for cors in the application.
  33138. * It can be a string if the expected behavior is identical in the entire app.
  33139. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33140. */
  33141. static CorsBehavior: string | ((url: string | string[]) => string);
  33142. /**
  33143. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33144. * @ignorenaming
  33145. */
  33146. static UseFallbackTexture: boolean;
  33147. /**
  33148. * Use this object to register external classes like custom textures or material
  33149. * to allow the laoders to instantiate them
  33150. */
  33151. static RegisteredExternalClasses: {
  33152. [key: string]: Object;
  33153. };
  33154. /**
  33155. * Texture content used if a texture cannot loaded
  33156. * @ignorenaming
  33157. */
  33158. static fallbackTexture: string;
  33159. /**
  33160. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33161. * @param u defines the coordinate on X axis
  33162. * @param v defines the coordinate on Y axis
  33163. * @param width defines the width of the source data
  33164. * @param height defines the height of the source data
  33165. * @param pixels defines the source byte array
  33166. * @param color defines the output color
  33167. */
  33168. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33169. /**
  33170. * Interpolates between a and b via alpha
  33171. * @param a The lower value (returned when alpha = 0)
  33172. * @param b The upper value (returned when alpha = 1)
  33173. * @param alpha The interpolation-factor
  33174. * @return The mixed value
  33175. */
  33176. static Mix(a: number, b: number, alpha: number): number;
  33177. /**
  33178. * Tries to instantiate a new object from a given class name
  33179. * @param className defines the class name to instantiate
  33180. * @returns the new object or null if the system was not able to do the instantiation
  33181. */
  33182. static Instantiate(className: string): any;
  33183. /**
  33184. * Provides a slice function that will work even on IE
  33185. * @param data defines the array to slice
  33186. * @param start defines the start of the data (optional)
  33187. * @param end defines the end of the data (optional)
  33188. * @returns the new sliced array
  33189. */
  33190. static Slice<T>(data: T, start?: number, end?: number): T;
  33191. /**
  33192. * Polyfill for setImmediate
  33193. * @param action defines the action to execute after the current execution block
  33194. */
  33195. static SetImmediate(action: () => void): void;
  33196. /**
  33197. * Function indicating if a number is an exponent of 2
  33198. * @param value defines the value to test
  33199. * @returns true if the value is an exponent of 2
  33200. */
  33201. static IsExponentOfTwo(value: number): boolean;
  33202. private static _tmpFloatArray;
  33203. /**
  33204. * Returns the nearest 32-bit single precision float representation of a Number
  33205. * @param value A Number. If the parameter is of a different type, it will get converted
  33206. * to a number or to NaN if it cannot be converted
  33207. * @returns number
  33208. */
  33209. static FloatRound(value: number): number;
  33210. /**
  33211. * Extracts the filename from a path
  33212. * @param path defines the path to use
  33213. * @returns the filename
  33214. */
  33215. static GetFilename(path: string): string;
  33216. /**
  33217. * Extracts the "folder" part of a path (everything before the filename).
  33218. * @param uri The URI to extract the info from
  33219. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33220. * @returns The "folder" part of the path
  33221. */
  33222. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33223. /**
  33224. * Extracts text content from a DOM element hierarchy
  33225. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33226. */
  33227. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33228. /**
  33229. * Convert an angle in radians to degrees
  33230. * @param angle defines the angle to convert
  33231. * @returns the angle in degrees
  33232. */
  33233. static ToDegrees(angle: number): number;
  33234. /**
  33235. * Convert an angle in degrees to radians
  33236. * @param angle defines the angle to convert
  33237. * @returns the angle in radians
  33238. */
  33239. static ToRadians(angle: number): number;
  33240. /**
  33241. * Returns an array if obj is not an array
  33242. * @param obj defines the object to evaluate as an array
  33243. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33244. * @returns either obj directly if obj is an array or a new array containing obj
  33245. */
  33246. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33247. /**
  33248. * Gets the pointer prefix to use
  33249. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33250. */
  33251. static GetPointerPrefix(): string;
  33252. /**
  33253. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33254. * @param url define the url we are trying
  33255. * @param element define the dom element where to configure the cors policy
  33256. */
  33257. static SetCorsBehavior(url: string | string[], element: {
  33258. crossOrigin: string | null;
  33259. }): void;
  33260. /**
  33261. * Removes unwanted characters from an url
  33262. * @param url defines the url to clean
  33263. * @returns the cleaned url
  33264. */
  33265. static CleanUrl(url: string): string;
  33266. /**
  33267. * Gets or sets a function used to pre-process url before using them to load assets
  33268. */
  33269. static PreprocessUrl: (url: string) => string;
  33270. /**
  33271. * Loads an image as an HTMLImageElement.
  33272. * @param input url string, ArrayBuffer, or Blob to load
  33273. * @param onLoad callback called when the image successfully loads
  33274. * @param onError callback called when the image fails to load
  33275. * @param offlineProvider offline provider for caching
  33276. * @param mimeType optional mime type
  33277. * @returns the HTMLImageElement of the loaded image
  33278. */
  33279. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33280. /**
  33281. * Loads a file from a url
  33282. * @param url url string, ArrayBuffer, or Blob to load
  33283. * @param onSuccess callback called when the file successfully loads
  33284. * @param onProgress callback called while file is loading (if the server supports this mode)
  33285. * @param offlineProvider defines the offline provider for caching
  33286. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33287. * @param onError callback called when the file fails to load
  33288. * @returns a file request object
  33289. */
  33290. 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;
  33291. /**
  33292. * Loads a file from a url
  33293. * @param url the file url to load
  33294. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33295. */
  33296. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33297. /**
  33298. * Load a script (identified by an url). When the url returns, the
  33299. * content of this file is added into a new script element, attached to the DOM (body element)
  33300. * @param scriptUrl defines the url of the script to laod
  33301. * @param onSuccess defines the callback called when the script is loaded
  33302. * @param onError defines the callback to call if an error occurs
  33303. * @param scriptId defines the id of the script element
  33304. */
  33305. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33306. /**
  33307. * Load an asynchronous script (identified by an url). When the url returns, the
  33308. * content of this file is added into a new script element, attached to the DOM (body element)
  33309. * @param scriptUrl defines the url of the script to laod
  33310. * @param scriptId defines the id of the script element
  33311. * @returns a promise request object
  33312. */
  33313. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33314. /**
  33315. * Loads a file from a blob
  33316. * @param fileToLoad defines the blob to use
  33317. * @param callback defines the callback to call when data is loaded
  33318. * @param progressCallback defines the callback to call during loading process
  33319. * @returns a file request object
  33320. */
  33321. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33322. /**
  33323. * Reads a file from a File object
  33324. * @param file defines the file to load
  33325. * @param onSuccess defines the callback to call when data is loaded
  33326. * @param onProgress defines the callback to call during loading process
  33327. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33328. * @param onError defines the callback to call when an error occurs
  33329. * @returns a file request object
  33330. */
  33331. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33332. /**
  33333. * Creates a data url from a given string content
  33334. * @param content defines the content to convert
  33335. * @returns the new data url link
  33336. */
  33337. static FileAsURL(content: string): string;
  33338. /**
  33339. * Format the given number to a specific decimal format
  33340. * @param value defines the number to format
  33341. * @param decimals defines the number of decimals to use
  33342. * @returns the formatted string
  33343. */
  33344. static Format(value: number, decimals?: number): string;
  33345. /**
  33346. * Tries to copy an object by duplicating every property
  33347. * @param source defines the source object
  33348. * @param destination defines the target object
  33349. * @param doNotCopyList defines a list of properties to avoid
  33350. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33351. */
  33352. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33353. /**
  33354. * Gets a boolean indicating if the given object has no own property
  33355. * @param obj defines the object to test
  33356. * @returns true if object has no own property
  33357. */
  33358. static IsEmpty(obj: any): boolean;
  33359. /**
  33360. * Function used to register events at window level
  33361. * @param windowElement defines the Window object to use
  33362. * @param events defines the events to register
  33363. */
  33364. static RegisterTopRootEvents(windowElement: Window, events: {
  33365. name: string;
  33366. handler: Nullable<(e: FocusEvent) => any>;
  33367. }[]): void;
  33368. /**
  33369. * Function used to unregister events from window level
  33370. * @param windowElement defines the Window object to use
  33371. * @param events defines the events to unregister
  33372. */
  33373. static UnregisterTopRootEvents(windowElement: Window, events: {
  33374. name: string;
  33375. handler: Nullable<(e: FocusEvent) => any>;
  33376. }[]): void;
  33377. /**
  33378. * @ignore
  33379. */
  33380. static _ScreenshotCanvas: HTMLCanvasElement;
  33381. /**
  33382. * Dumps the current bound framebuffer
  33383. * @param width defines the rendering width
  33384. * @param height defines the rendering height
  33385. * @param engine defines the hosting engine
  33386. * @param successCallback defines the callback triggered once the data are available
  33387. * @param mimeType defines the mime type of the result
  33388. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33389. */
  33390. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33391. /**
  33392. * Converts the canvas data to blob.
  33393. * This acts as a polyfill for browsers not supporting the to blob function.
  33394. * @param canvas Defines the canvas to extract the data from
  33395. * @param successCallback Defines the callback triggered once the data are available
  33396. * @param mimeType Defines the mime type of the result
  33397. */
  33398. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33399. /**
  33400. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33401. * @param successCallback defines the callback triggered once the data are available
  33402. * @param mimeType defines the mime type of the result
  33403. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33404. */
  33405. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33406. /**
  33407. * Downloads a blob in the browser
  33408. * @param blob defines the blob to download
  33409. * @param fileName defines the name of the downloaded file
  33410. */
  33411. static Download(blob: Blob, fileName: string): void;
  33412. /**
  33413. * Captures a screenshot of the current rendering
  33414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33415. * @param engine defines the rendering engine
  33416. * @param camera defines the source camera
  33417. * @param size This parameter can be set to a single number or to an object with the
  33418. * following (optional) properties: precision, width, height. If a single number is passed,
  33419. * it will be used for both width and height. If an object is passed, the screenshot size
  33420. * will be derived from the parameters. The precision property is a multiplier allowing
  33421. * rendering at a higher or lower resolution
  33422. * @param successCallback defines the callback receives a single parameter which contains the
  33423. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33424. * src parameter of an <img> to display it
  33425. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33426. * Check your browser for supported MIME types
  33427. */
  33428. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33429. /**
  33430. * Captures a screenshot of the current rendering
  33431. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33432. * @param engine defines the rendering engine
  33433. * @param camera defines the source camera
  33434. * @param size This parameter can be set to a single number or to an object with the
  33435. * following (optional) properties: precision, width, height. If a single number is passed,
  33436. * it will be used for both width and height. If an object is passed, the screenshot size
  33437. * will be derived from the parameters. The precision property is a multiplier allowing
  33438. * rendering at a higher or lower resolution
  33439. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33440. * Check your browser for supported MIME types
  33441. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33442. * to the src parameter of an <img> to display it
  33443. */
  33444. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33445. /**
  33446. * Generates an image screenshot from the specified camera.
  33447. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33448. * @param engine The engine to use for rendering
  33449. * @param camera The camera to use for rendering
  33450. * @param size This parameter can be set to a single number or to an object with the
  33451. * following (optional) properties: precision, width, height. If a single number is passed,
  33452. * it will be used for both width and height. If an object is passed, the screenshot size
  33453. * will be derived from the parameters. The precision property is a multiplier allowing
  33454. * rendering at a higher or lower resolution
  33455. * @param successCallback The callback receives a single parameter which contains the
  33456. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33457. * src parameter of an <img> to display it
  33458. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33459. * Check your browser for supported MIME types
  33460. * @param samples Texture samples (default: 1)
  33461. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33462. * @param fileName A name for for the downloaded file.
  33463. */
  33464. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33465. /**
  33466. * Generates an image screenshot from the specified camera.
  33467. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33468. * @param engine The engine to use for rendering
  33469. * @param camera The camera to use for rendering
  33470. * @param size This parameter can be set to a single number or to an object with the
  33471. * following (optional) properties: precision, width, height. If a single number is passed,
  33472. * it will be used for both width and height. If an object is passed, the screenshot size
  33473. * will be derived from the parameters. The precision property is a multiplier allowing
  33474. * rendering at a higher or lower resolution
  33475. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33476. * Check your browser for supported MIME types
  33477. * @param samples Texture samples (default: 1)
  33478. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33479. * @param fileName A name for for the downloaded file.
  33480. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33481. * to the src parameter of an <img> to display it
  33482. */
  33483. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33484. /**
  33485. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33486. * Be aware Math.random() could cause collisions, but:
  33487. * "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"
  33488. * @returns a pseudo random id
  33489. */
  33490. static RandomId(): string;
  33491. /**
  33492. * Test if the given uri is a base64 string
  33493. * @param uri The uri to test
  33494. * @return True if the uri is a base64 string or false otherwise
  33495. */
  33496. static IsBase64(uri: string): boolean;
  33497. /**
  33498. * Decode the given base64 uri.
  33499. * @param uri The uri to decode
  33500. * @return The decoded base64 data.
  33501. */
  33502. static DecodeBase64(uri: string): ArrayBuffer;
  33503. /**
  33504. * Gets the absolute url.
  33505. * @param url the input url
  33506. * @return the absolute url
  33507. */
  33508. static GetAbsoluteUrl(url: string): string;
  33509. /**
  33510. * No log
  33511. */
  33512. static readonly NoneLogLevel: number;
  33513. /**
  33514. * Only message logs
  33515. */
  33516. static readonly MessageLogLevel: number;
  33517. /**
  33518. * Only warning logs
  33519. */
  33520. static readonly WarningLogLevel: number;
  33521. /**
  33522. * Only error logs
  33523. */
  33524. static readonly ErrorLogLevel: number;
  33525. /**
  33526. * All logs
  33527. */
  33528. static readonly AllLogLevel: number;
  33529. /**
  33530. * Gets a value indicating the number of loading errors
  33531. * @ignorenaming
  33532. */
  33533. static readonly errorsCount: number;
  33534. /**
  33535. * Callback called when a new log is added
  33536. */
  33537. static OnNewCacheEntry: (entry: string) => void;
  33538. /**
  33539. * Log a message to the console
  33540. * @param message defines the message to log
  33541. */
  33542. static Log(message: string): void;
  33543. /**
  33544. * Write a warning message to the console
  33545. * @param message defines the message to log
  33546. */
  33547. static Warn(message: string): void;
  33548. /**
  33549. * Write an error message to the console
  33550. * @param message defines the message to log
  33551. */
  33552. static Error(message: string): void;
  33553. /**
  33554. * Gets current log cache (list of logs)
  33555. */
  33556. static readonly LogCache: string;
  33557. /**
  33558. * Clears the log cache
  33559. */
  33560. static ClearLogCache(): void;
  33561. /**
  33562. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33563. */
  33564. static LogLevels: number;
  33565. /**
  33566. * Checks if the window object exists
  33567. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33568. */
  33569. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33570. /**
  33571. * No performance log
  33572. */
  33573. static readonly PerformanceNoneLogLevel: number;
  33574. /**
  33575. * Use user marks to log performance
  33576. */
  33577. static readonly PerformanceUserMarkLogLevel: number;
  33578. /**
  33579. * Log performance to the console
  33580. */
  33581. static readonly PerformanceConsoleLogLevel: number;
  33582. private static _performance;
  33583. /**
  33584. * Sets the current performance log level
  33585. */
  33586. static PerformanceLogLevel: number;
  33587. private static _StartPerformanceCounterDisabled;
  33588. private static _EndPerformanceCounterDisabled;
  33589. private static _StartUserMark;
  33590. private static _EndUserMark;
  33591. private static _StartPerformanceConsole;
  33592. private static _EndPerformanceConsole;
  33593. /**
  33594. * Starts a performance counter
  33595. */
  33596. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33597. /**
  33598. * Ends a specific performance coutner
  33599. */
  33600. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33601. /**
  33602. * Gets either window.performance.now() if supported or Date.now() else
  33603. */
  33604. static readonly Now: number;
  33605. /**
  33606. * This method will return the name of the class used to create the instance of the given object.
  33607. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33608. * @param object the object to get the class name from
  33609. * @param isType defines if the object is actually a type
  33610. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33611. */
  33612. static GetClassName(object: any, isType?: boolean): string;
  33613. /**
  33614. * Gets the first element of an array satisfying a given predicate
  33615. * @param array defines the array to browse
  33616. * @param predicate defines the predicate to use
  33617. * @returns null if not found or the element
  33618. */
  33619. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33620. /**
  33621. * This method will return the name of the full name of the class, including its owning module (if any).
  33622. * 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).
  33623. * @param object the object to get the class name from
  33624. * @param isType defines if the object is actually a type
  33625. * @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.
  33626. * @ignorenaming
  33627. */
  33628. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33629. /**
  33630. * Returns a promise that resolves after the given amount of time.
  33631. * @param delay Number of milliseconds to delay
  33632. * @returns Promise that resolves after the given amount of time
  33633. */
  33634. static DelayAsync(delay: number): Promise<void>;
  33635. }
  33636. /**
  33637. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33638. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33639. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33640. * @param name The name of the class, case should be preserved
  33641. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33642. */
  33643. export function className(name: string, module?: string): (target: Object) => void;
  33644. /**
  33645. * An implementation of a loop for asynchronous functions.
  33646. */
  33647. export class AsyncLoop {
  33648. /**
  33649. * Defines the number of iterations for the loop
  33650. */
  33651. iterations: number;
  33652. /**
  33653. * Defines the current index of the loop.
  33654. */
  33655. index: number;
  33656. private _done;
  33657. private _fn;
  33658. private _successCallback;
  33659. /**
  33660. * Constructor.
  33661. * @param iterations the number of iterations.
  33662. * @param func the function to run each iteration
  33663. * @param successCallback the callback that will be called upon succesful execution
  33664. * @param offset starting offset.
  33665. */
  33666. constructor(
  33667. /**
  33668. * Defines the number of iterations for the loop
  33669. */
  33670. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33671. /**
  33672. * Execute the next iteration. Must be called after the last iteration was finished.
  33673. */
  33674. executeNext(): void;
  33675. /**
  33676. * Break the loop and run the success callback.
  33677. */
  33678. breakLoop(): void;
  33679. /**
  33680. * Create and run an async loop.
  33681. * @param iterations the number of iterations.
  33682. * @param fn the function to run each iteration
  33683. * @param successCallback the callback that will be called upon succesful execution
  33684. * @param offset starting offset.
  33685. * @returns the created async loop object
  33686. */
  33687. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33688. /**
  33689. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33690. * @param iterations total number of iterations
  33691. * @param syncedIterations number of synchronous iterations in each async iteration.
  33692. * @param fn the function to call each iteration.
  33693. * @param callback a success call back that will be called when iterating stops.
  33694. * @param breakFunction a break condition (optional)
  33695. * @param timeout timeout settings for the setTimeout function. default - 0.
  33696. * @returns the created async loop object
  33697. */
  33698. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33699. }
  33700. }
  33701. declare module "babylonjs/Misc/stringDictionary" {
  33702. import { Nullable } from "babylonjs/types";
  33703. /**
  33704. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33705. * The underlying implementation relies on an associative array to ensure the best performances.
  33706. * The value can be anything including 'null' but except 'undefined'
  33707. */
  33708. export class StringDictionary<T> {
  33709. /**
  33710. * This will clear this dictionary and copy the content from the 'source' one.
  33711. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33712. * @param source the dictionary to take the content from and copy to this dictionary
  33713. */
  33714. copyFrom(source: StringDictionary<T>): void;
  33715. /**
  33716. * Get a value based from its key
  33717. * @param key the given key to get the matching value from
  33718. * @return the value if found, otherwise undefined is returned
  33719. */
  33720. get(key: string): T | undefined;
  33721. /**
  33722. * Get a value from its key or add it if it doesn't exist.
  33723. * This method will ensure you that a given key/data will be present in the dictionary.
  33724. * @param key the given key to get the matching value from
  33725. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33726. * The factory will only be invoked if there's no data for the given key.
  33727. * @return the value corresponding to the key.
  33728. */
  33729. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33730. /**
  33731. * Get a value from its key if present in the dictionary otherwise add it
  33732. * @param key the key to get the value from
  33733. * @param val if there's no such key/value pair in the dictionary add it with this value
  33734. * @return the value corresponding to the key
  33735. */
  33736. getOrAdd(key: string, val: T): T;
  33737. /**
  33738. * Check if there's a given key in the dictionary
  33739. * @param key the key to check for
  33740. * @return true if the key is present, false otherwise
  33741. */
  33742. contains(key: string): boolean;
  33743. /**
  33744. * Add a new key and its corresponding value
  33745. * @param key the key to add
  33746. * @param value the value corresponding to the key
  33747. * @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
  33748. */
  33749. add(key: string, value: T): boolean;
  33750. /**
  33751. * Update a specific value associated to a key
  33752. * @param key defines the key to use
  33753. * @param value defines the value to store
  33754. * @returns true if the value was updated (or false if the key was not found)
  33755. */
  33756. set(key: string, value: T): boolean;
  33757. /**
  33758. * Get the element of the given key and remove it from the dictionary
  33759. * @param key defines the key to search
  33760. * @returns the value associated with the key or null if not found
  33761. */
  33762. getAndRemove(key: string): Nullable<T>;
  33763. /**
  33764. * Remove a key/value from the dictionary.
  33765. * @param key the key to remove
  33766. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33767. */
  33768. remove(key: string): boolean;
  33769. /**
  33770. * Clear the whole content of the dictionary
  33771. */
  33772. clear(): void;
  33773. /**
  33774. * Gets the current count
  33775. */
  33776. readonly count: number;
  33777. /**
  33778. * Execute a callback on each key/val of the dictionary.
  33779. * Note that you can remove any element in this dictionary in the callback implementation
  33780. * @param callback the callback to execute on a given key/value pair
  33781. */
  33782. forEach(callback: (key: string, val: T) => void): void;
  33783. /**
  33784. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33785. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33786. * Note that you can remove any element in this dictionary in the callback implementation
  33787. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33788. * @returns the first item
  33789. */
  33790. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33791. private _count;
  33792. private _data;
  33793. }
  33794. }
  33795. declare module "babylonjs/Collisions/collisionCoordinator" {
  33796. import { Nullable } from "babylonjs/types";
  33797. import { Scene } from "babylonjs/scene";
  33798. import { Vector3 } from "babylonjs/Maths/math.vector";
  33799. import { Collider } from "babylonjs/Collisions/collider";
  33800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33801. /** @hidden */
  33802. export interface ICollisionCoordinator {
  33803. createCollider(): Collider;
  33804. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33805. init(scene: Scene): void;
  33806. }
  33807. /** @hidden */
  33808. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33809. private _scene;
  33810. private _scaledPosition;
  33811. private _scaledVelocity;
  33812. private _finalPosition;
  33813. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33814. createCollider(): Collider;
  33815. init(scene: Scene): void;
  33816. private _collideWithWorld;
  33817. }
  33818. }
  33819. declare module "babylonjs/Inputs/scene.inputManager" {
  33820. import { Nullable } from "babylonjs/types";
  33821. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33822. import { Vector2 } from "babylonjs/Maths/math.vector";
  33823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33824. import { Scene } from "babylonjs/scene";
  33825. /**
  33826. * Class used to manage all inputs for the scene.
  33827. */
  33828. export class InputManager {
  33829. /** The distance in pixel that you have to move to prevent some events */
  33830. static DragMovementThreshold: number;
  33831. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33832. static LongPressDelay: number;
  33833. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33834. static DoubleClickDelay: number;
  33835. /** If you need to check double click without raising a single click at first click, enable this flag */
  33836. static ExclusiveDoubleClickMode: boolean;
  33837. private _wheelEventName;
  33838. private _onPointerMove;
  33839. private _onPointerDown;
  33840. private _onPointerUp;
  33841. private _initClickEvent;
  33842. private _initActionManager;
  33843. private _delayedSimpleClick;
  33844. private _delayedSimpleClickTimeout;
  33845. private _previousDelayedSimpleClickTimeout;
  33846. private _meshPickProceed;
  33847. private _previousButtonPressed;
  33848. private _currentPickResult;
  33849. private _previousPickResult;
  33850. private _totalPointersPressed;
  33851. private _doubleClickOccured;
  33852. private _pointerOverMesh;
  33853. private _pickedDownMesh;
  33854. private _pickedUpMesh;
  33855. private _pointerX;
  33856. private _pointerY;
  33857. private _unTranslatedPointerX;
  33858. private _unTranslatedPointerY;
  33859. private _startingPointerPosition;
  33860. private _previousStartingPointerPosition;
  33861. private _startingPointerTime;
  33862. private _previousStartingPointerTime;
  33863. private _pointerCaptures;
  33864. private _onKeyDown;
  33865. private _onKeyUp;
  33866. private _onCanvasFocusObserver;
  33867. private _onCanvasBlurObserver;
  33868. private _scene;
  33869. /**
  33870. * Creates a new InputManager
  33871. * @param scene defines the hosting scene
  33872. */
  33873. constructor(scene: Scene);
  33874. /**
  33875. * Gets the mesh that is currently under the pointer
  33876. */
  33877. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33878. /**
  33879. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33880. */
  33881. readonly unTranslatedPointer: Vector2;
  33882. /**
  33883. * Gets or sets the current on-screen X position of the pointer
  33884. */
  33885. pointerX: number;
  33886. /**
  33887. * Gets or sets the current on-screen Y position of the pointer
  33888. */
  33889. pointerY: number;
  33890. private _updatePointerPosition;
  33891. private _processPointerMove;
  33892. private _setRayOnPointerInfo;
  33893. private _checkPrePointerObservable;
  33894. /**
  33895. * Use this method to simulate a pointer move on a mesh
  33896. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33897. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33898. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33899. */
  33900. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33901. /**
  33902. * Use this method to simulate a pointer down on a mesh
  33903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33904. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33905. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33906. */
  33907. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33908. private _processPointerDown;
  33909. /** @hidden */
  33910. _isPointerSwiping(): boolean;
  33911. /**
  33912. * Use this method to simulate a pointer up on a mesh
  33913. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33914. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33915. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33916. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33917. */
  33918. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33919. private _processPointerUp;
  33920. /**
  33921. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33922. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33923. * @returns true if the pointer was captured
  33924. */
  33925. isPointerCaptured(pointerId?: number): boolean;
  33926. /**
  33927. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33928. * @param attachUp defines if you want to attach events to pointerup
  33929. * @param attachDown defines if you want to attach events to pointerdown
  33930. * @param attachMove defines if you want to attach events to pointermove
  33931. */
  33932. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33933. /**
  33934. * Detaches all event handlers
  33935. */
  33936. detachControl(): void;
  33937. /**
  33938. * Force the value of meshUnderPointer
  33939. * @param mesh defines the mesh to use
  33940. */
  33941. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33942. /**
  33943. * Gets the mesh under the pointer
  33944. * @returns a Mesh or null if no mesh is under the pointer
  33945. */
  33946. getPointerOverMesh(): Nullable<AbstractMesh>;
  33947. }
  33948. }
  33949. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33950. /**
  33951. * Helper class used to generate session unique ID
  33952. */
  33953. export class UniqueIdGenerator {
  33954. private static _UniqueIdCounter;
  33955. /**
  33956. * Gets an unique (relatively to the current scene) Id
  33957. */
  33958. static readonly UniqueId: number;
  33959. }
  33960. }
  33961. declare module "babylonjs/Animations/animationGroup" {
  33962. import { Animatable } from "babylonjs/Animations/animatable";
  33963. import { Animation } from "babylonjs/Animations/animation";
  33964. import { Scene, IDisposable } from "babylonjs/scene";
  33965. import { Observable } from "babylonjs/Misc/observable";
  33966. import { Nullable } from "babylonjs/types";
  33967. import "babylonjs/Animations/animatable";
  33968. /**
  33969. * This class defines the direct association between an animation and a target
  33970. */
  33971. export class TargetedAnimation {
  33972. /**
  33973. * Animation to perform
  33974. */
  33975. animation: Animation;
  33976. /**
  33977. * Target to animate
  33978. */
  33979. target: any;
  33980. /**
  33981. * Serialize the object
  33982. * @returns the JSON object representing the current entity
  33983. */
  33984. serialize(): any;
  33985. }
  33986. /**
  33987. * Use this class to create coordinated animations on multiple targets
  33988. */
  33989. export class AnimationGroup implements IDisposable {
  33990. /** The name of the animation group */
  33991. name: string;
  33992. private _scene;
  33993. private _targetedAnimations;
  33994. private _animatables;
  33995. private _from;
  33996. private _to;
  33997. private _isStarted;
  33998. private _isPaused;
  33999. private _speedRatio;
  34000. private _loopAnimation;
  34001. /**
  34002. * Gets or sets the unique id of the node
  34003. */
  34004. uniqueId: number;
  34005. /**
  34006. * This observable will notify when one animation have ended
  34007. */
  34008. onAnimationEndObservable: Observable<TargetedAnimation>;
  34009. /**
  34010. * Observer raised when one animation loops
  34011. */
  34012. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34013. /**
  34014. * Observer raised when all animations have looped
  34015. */
  34016. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34017. /**
  34018. * This observable will notify when all animations have ended.
  34019. */
  34020. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34021. /**
  34022. * This observable will notify when all animations have paused.
  34023. */
  34024. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34025. /**
  34026. * This observable will notify when all animations are playing.
  34027. */
  34028. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34029. /**
  34030. * Gets the first frame
  34031. */
  34032. readonly from: number;
  34033. /**
  34034. * Gets the last frame
  34035. */
  34036. readonly to: number;
  34037. /**
  34038. * Define if the animations are started
  34039. */
  34040. readonly isStarted: boolean;
  34041. /**
  34042. * Gets a value indicating that the current group is playing
  34043. */
  34044. readonly isPlaying: boolean;
  34045. /**
  34046. * Gets or sets the speed ratio to use for all animations
  34047. */
  34048. /**
  34049. * Gets or sets the speed ratio to use for all animations
  34050. */
  34051. speedRatio: number;
  34052. /**
  34053. * Gets or sets if all animations should loop or not
  34054. */
  34055. loopAnimation: boolean;
  34056. /**
  34057. * Gets the targeted animations for this animation group
  34058. */
  34059. readonly targetedAnimations: Array<TargetedAnimation>;
  34060. /**
  34061. * returning the list of animatables controlled by this animation group.
  34062. */
  34063. readonly animatables: Array<Animatable>;
  34064. /**
  34065. * Instantiates a new Animation Group.
  34066. * This helps managing several animations at once.
  34067. * @see http://doc.babylonjs.com/how_to/group
  34068. * @param name Defines the name of the group
  34069. * @param scene Defines the scene the group belongs to
  34070. */
  34071. constructor(
  34072. /** The name of the animation group */
  34073. name: string, scene?: Nullable<Scene>);
  34074. /**
  34075. * Add an animation (with its target) in the group
  34076. * @param animation defines the animation we want to add
  34077. * @param target defines the target of the animation
  34078. * @returns the TargetedAnimation object
  34079. */
  34080. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34081. /**
  34082. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34083. * It can add constant keys at begin or end
  34084. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34085. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34086. * @returns the animation group
  34087. */
  34088. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34089. private _animationLoopCount;
  34090. private _animationLoopFlags;
  34091. private _processLoop;
  34092. /**
  34093. * Start all animations on given targets
  34094. * @param loop defines if animations must loop
  34095. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34096. * @param from defines the from key (optional)
  34097. * @param to defines the to key (optional)
  34098. * @returns the current animation group
  34099. */
  34100. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34101. /**
  34102. * Pause all animations
  34103. * @returns the animation group
  34104. */
  34105. pause(): AnimationGroup;
  34106. /**
  34107. * Play all animations to initial state
  34108. * This function will start() the animations if they were not started or will restart() them if they were paused
  34109. * @param loop defines if animations must loop
  34110. * @returns the animation group
  34111. */
  34112. play(loop?: boolean): AnimationGroup;
  34113. /**
  34114. * Reset all animations to initial state
  34115. * @returns the animation group
  34116. */
  34117. reset(): AnimationGroup;
  34118. /**
  34119. * Restart animations from key 0
  34120. * @returns the animation group
  34121. */
  34122. restart(): AnimationGroup;
  34123. /**
  34124. * Stop all animations
  34125. * @returns the animation group
  34126. */
  34127. stop(): AnimationGroup;
  34128. /**
  34129. * Set animation weight for all animatables
  34130. * @param weight defines the weight to use
  34131. * @return the animationGroup
  34132. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34133. */
  34134. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34135. /**
  34136. * Synchronize and normalize all animatables with a source animatable
  34137. * @param root defines the root animatable to synchronize with
  34138. * @return the animationGroup
  34139. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34140. */
  34141. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34142. /**
  34143. * Goes to a specific frame in this animation group
  34144. * @param frame the frame number to go to
  34145. * @return the animationGroup
  34146. */
  34147. goToFrame(frame: number): AnimationGroup;
  34148. /**
  34149. * Dispose all associated resources
  34150. */
  34151. dispose(): void;
  34152. private _checkAnimationGroupEnded;
  34153. /**
  34154. * Clone the current animation group and returns a copy
  34155. * @param newName defines the name of the new group
  34156. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34157. * @returns the new aniamtion group
  34158. */
  34159. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34160. /**
  34161. * Serializes the animationGroup to an object
  34162. * @returns Serialized object
  34163. */
  34164. serialize(): any;
  34165. /**
  34166. * Returns a new AnimationGroup object parsed from the source provided.
  34167. * @param parsedAnimationGroup defines the source
  34168. * @param scene defines the scene that will receive the animationGroup
  34169. * @returns a new AnimationGroup
  34170. */
  34171. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34172. /**
  34173. * Returns the string "AnimationGroup"
  34174. * @returns "AnimationGroup"
  34175. */
  34176. getClassName(): string;
  34177. /**
  34178. * Creates a detailled string about the object
  34179. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34180. * @returns a string representing the object
  34181. */
  34182. toString(fullDetails?: boolean): string;
  34183. }
  34184. }
  34185. declare module "babylonjs/scene" {
  34186. import { Nullable } from "babylonjs/types";
  34187. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34188. import { Observable } from "babylonjs/Misc/observable";
  34189. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34190. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34191. import { Geometry } from "babylonjs/Meshes/geometry";
  34192. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34193. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34195. import { Mesh } from "babylonjs/Meshes/mesh";
  34196. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34197. import { Bone } from "babylonjs/Bones/bone";
  34198. import { Skeleton } from "babylonjs/Bones/skeleton";
  34199. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34200. import { Camera } from "babylonjs/Cameras/camera";
  34201. import { AbstractScene } from "babylonjs/abstractScene";
  34202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34203. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34204. import { Material } from "babylonjs/Materials/material";
  34205. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34206. import { Effect } from "babylonjs/Materials/effect";
  34207. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34208. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34209. import { Light } from "babylonjs/Lights/light";
  34210. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34211. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34212. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34213. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34214. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34215. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34216. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34217. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34218. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34219. import { Engine } from "babylonjs/Engines/engine";
  34220. import { Node } from "babylonjs/node";
  34221. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34222. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34223. import { WebRequest } from "babylonjs/Misc/webRequest";
  34224. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34225. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34226. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34227. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34228. import { Plane } from "babylonjs/Maths/math.plane";
  34229. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34230. import { Ray } from "babylonjs/Culling/ray";
  34231. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34232. import { Animation } from "babylonjs/Animations/animation";
  34233. import { Animatable } from "babylonjs/Animations/animatable";
  34234. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34235. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34236. import { Collider } from "babylonjs/Collisions/collider";
  34237. /**
  34238. * Define an interface for all classes that will hold resources
  34239. */
  34240. export interface IDisposable {
  34241. /**
  34242. * Releases all held resources
  34243. */
  34244. dispose(): void;
  34245. }
  34246. /** Interface defining initialization parameters for Scene class */
  34247. export interface SceneOptions {
  34248. /**
  34249. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34250. * It will improve performance when the number of geometries becomes important.
  34251. */
  34252. useGeometryUniqueIdsMap?: boolean;
  34253. /**
  34254. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34255. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34256. */
  34257. useMaterialMeshMap?: boolean;
  34258. /**
  34259. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34260. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34261. */
  34262. useClonedMeshhMap?: boolean;
  34263. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34264. virtual?: boolean;
  34265. }
  34266. /**
  34267. * Represents a scene to be rendered by the engine.
  34268. * @see http://doc.babylonjs.com/features/scene
  34269. */
  34270. export class Scene extends AbstractScene implements IAnimatable {
  34271. /** The fog is deactivated */
  34272. static readonly FOGMODE_NONE: number;
  34273. /** The fog density is following an exponential function */
  34274. static readonly FOGMODE_EXP: number;
  34275. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34276. static readonly FOGMODE_EXP2: number;
  34277. /** The fog density is following a linear function. */
  34278. static readonly FOGMODE_LINEAR: number;
  34279. /**
  34280. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34282. */
  34283. static MinDeltaTime: number;
  34284. /**
  34285. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34287. */
  34288. static MaxDeltaTime: number;
  34289. /**
  34290. * Factory used to create the default material.
  34291. * @param name The name of the material to create
  34292. * @param scene The scene to create the material for
  34293. * @returns The default material
  34294. */
  34295. static DefaultMaterialFactory(scene: Scene): Material;
  34296. /**
  34297. * Factory used to create the a collision coordinator.
  34298. * @returns The collision coordinator
  34299. */
  34300. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34301. /** @hidden */
  34302. _inputManager: InputManager;
  34303. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34304. cameraToUseForPointers: Nullable<Camera>;
  34305. /** @hidden */
  34306. readonly _isScene: boolean;
  34307. /**
  34308. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34309. */
  34310. autoClear: boolean;
  34311. /**
  34312. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34313. */
  34314. autoClearDepthAndStencil: boolean;
  34315. /**
  34316. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34317. */
  34318. clearColor: Color4;
  34319. /**
  34320. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34321. */
  34322. ambientColor: Color3;
  34323. /**
  34324. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34325. * It should only be one of the following (if not the default embedded one):
  34326. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34327. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34328. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34329. * The material properties need to be setup according to the type of texture in use.
  34330. */
  34331. environmentBRDFTexture: BaseTexture;
  34332. /** @hidden */
  34333. protected _environmentTexture: Nullable<BaseTexture>;
  34334. /**
  34335. * Texture used in all pbr material as the reflection texture.
  34336. * As in the majority of the scene they are the same (exception for multi room and so on),
  34337. * this is easier to reference from here than from all the materials.
  34338. */
  34339. /**
  34340. * Texture used in all pbr material as the reflection texture.
  34341. * As in the majority of the scene they are the same (exception for multi room and so on),
  34342. * this is easier to set here than in all the materials.
  34343. */
  34344. environmentTexture: Nullable<BaseTexture>;
  34345. /** @hidden */
  34346. protected _environmentIntensity: number;
  34347. /**
  34348. * Intensity of the environment in all pbr material.
  34349. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34350. * As in the majority of the scene they are the same (exception for multi room and so on),
  34351. * this is easier to reference from here than from all the materials.
  34352. */
  34353. /**
  34354. * Intensity of the environment in all pbr material.
  34355. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34356. * As in the majority of the scene they are the same (exception for multi room and so on),
  34357. * this is easier to set here than in all the materials.
  34358. */
  34359. environmentIntensity: number;
  34360. /** @hidden */
  34361. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34362. /**
  34363. * Default image processing configuration used either in the rendering
  34364. * Forward main pass or through the imageProcessingPostProcess if present.
  34365. * As in the majority of the scene they are the same (exception for multi camera),
  34366. * this is easier to reference from here than from all the materials and post process.
  34367. *
  34368. * No setter as we it is a shared configuration, you can set the values instead.
  34369. */
  34370. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34371. private _forceWireframe;
  34372. /**
  34373. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34374. */
  34375. forceWireframe: boolean;
  34376. private _forcePointsCloud;
  34377. /**
  34378. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34379. */
  34380. forcePointsCloud: boolean;
  34381. /**
  34382. * Gets or sets the active clipplane 1
  34383. */
  34384. clipPlane: Nullable<Plane>;
  34385. /**
  34386. * Gets or sets the active clipplane 2
  34387. */
  34388. clipPlane2: Nullable<Plane>;
  34389. /**
  34390. * Gets or sets the active clipplane 3
  34391. */
  34392. clipPlane3: Nullable<Plane>;
  34393. /**
  34394. * Gets or sets the active clipplane 4
  34395. */
  34396. clipPlane4: Nullable<Plane>;
  34397. /**
  34398. * Gets or sets a boolean indicating if animations are enabled
  34399. */
  34400. animationsEnabled: boolean;
  34401. private _animationPropertiesOverride;
  34402. /**
  34403. * Gets or sets the animation properties override
  34404. */
  34405. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34406. /**
  34407. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34408. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34409. */
  34410. useConstantAnimationDeltaTime: boolean;
  34411. /**
  34412. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34413. * Please note that it requires to run a ray cast through the scene on every frame
  34414. */
  34415. constantlyUpdateMeshUnderPointer: boolean;
  34416. /**
  34417. * Defines the HTML cursor to use when hovering over interactive elements
  34418. */
  34419. hoverCursor: string;
  34420. /**
  34421. * Defines the HTML default cursor to use (empty by default)
  34422. */
  34423. defaultCursor: string;
  34424. /**
  34425. * Defines wether cursors are handled by the scene.
  34426. */
  34427. doNotHandleCursors: boolean;
  34428. /**
  34429. * This is used to call preventDefault() on pointer down
  34430. * in order to block unwanted artifacts like system double clicks
  34431. */
  34432. preventDefaultOnPointerDown: boolean;
  34433. /**
  34434. * This is used to call preventDefault() on pointer up
  34435. * in order to block unwanted artifacts like system double clicks
  34436. */
  34437. preventDefaultOnPointerUp: boolean;
  34438. /**
  34439. * Gets or sets user defined metadata
  34440. */
  34441. metadata: any;
  34442. /**
  34443. * For internal use only. Please do not use.
  34444. */
  34445. reservedDataStore: any;
  34446. /**
  34447. * Gets the name of the plugin used to load this scene (null by default)
  34448. */
  34449. loadingPluginName: string;
  34450. /**
  34451. * Use this array to add regular expressions used to disable offline support for specific urls
  34452. */
  34453. disableOfflineSupportExceptionRules: RegExp[];
  34454. /**
  34455. * An event triggered when the scene is disposed.
  34456. */
  34457. onDisposeObservable: Observable<Scene>;
  34458. private _onDisposeObserver;
  34459. /** Sets a function to be executed when this scene is disposed. */
  34460. onDispose: () => void;
  34461. /**
  34462. * An event triggered before rendering the scene (right after animations and physics)
  34463. */
  34464. onBeforeRenderObservable: Observable<Scene>;
  34465. private _onBeforeRenderObserver;
  34466. /** Sets a function to be executed before rendering this scene */
  34467. beforeRender: Nullable<() => void>;
  34468. /**
  34469. * An event triggered after rendering the scene
  34470. */
  34471. onAfterRenderObservable: Observable<Scene>;
  34472. /**
  34473. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34474. */
  34475. onAfterRenderCameraObservable: Observable<Camera>;
  34476. private _onAfterRenderObserver;
  34477. /** Sets a function to be executed after rendering this scene */
  34478. afterRender: Nullable<() => void>;
  34479. /**
  34480. * An event triggered before animating the scene
  34481. */
  34482. onBeforeAnimationsObservable: Observable<Scene>;
  34483. /**
  34484. * An event triggered after animations processing
  34485. */
  34486. onAfterAnimationsObservable: Observable<Scene>;
  34487. /**
  34488. * An event triggered before draw calls are ready to be sent
  34489. */
  34490. onBeforeDrawPhaseObservable: Observable<Scene>;
  34491. /**
  34492. * An event triggered after draw calls have been sent
  34493. */
  34494. onAfterDrawPhaseObservable: Observable<Scene>;
  34495. /**
  34496. * An event triggered when the scene is ready
  34497. */
  34498. onReadyObservable: Observable<Scene>;
  34499. /**
  34500. * An event triggered before rendering a camera
  34501. */
  34502. onBeforeCameraRenderObservable: Observable<Camera>;
  34503. private _onBeforeCameraRenderObserver;
  34504. /** Sets a function to be executed before rendering a camera*/
  34505. beforeCameraRender: () => void;
  34506. /**
  34507. * An event triggered after rendering a camera
  34508. */
  34509. onAfterCameraRenderObservable: Observable<Camera>;
  34510. private _onAfterCameraRenderObserver;
  34511. /** Sets a function to be executed after rendering a camera*/
  34512. afterCameraRender: () => void;
  34513. /**
  34514. * An event triggered when active meshes evaluation is about to start
  34515. */
  34516. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34517. /**
  34518. * An event triggered when active meshes evaluation is done
  34519. */
  34520. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34521. /**
  34522. * An event triggered when particles rendering is about to start
  34523. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34524. */
  34525. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34526. /**
  34527. * An event triggered when particles rendering is done
  34528. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34529. */
  34530. onAfterParticlesRenderingObservable: Observable<Scene>;
  34531. /**
  34532. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34533. */
  34534. onDataLoadedObservable: Observable<Scene>;
  34535. /**
  34536. * An event triggered when a camera is created
  34537. */
  34538. onNewCameraAddedObservable: Observable<Camera>;
  34539. /**
  34540. * An event triggered when a camera is removed
  34541. */
  34542. onCameraRemovedObservable: Observable<Camera>;
  34543. /**
  34544. * An event triggered when a light is created
  34545. */
  34546. onNewLightAddedObservable: Observable<Light>;
  34547. /**
  34548. * An event triggered when a light is removed
  34549. */
  34550. onLightRemovedObservable: Observable<Light>;
  34551. /**
  34552. * An event triggered when a geometry is created
  34553. */
  34554. onNewGeometryAddedObservable: Observable<Geometry>;
  34555. /**
  34556. * An event triggered when a geometry is removed
  34557. */
  34558. onGeometryRemovedObservable: Observable<Geometry>;
  34559. /**
  34560. * An event triggered when a transform node is created
  34561. */
  34562. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34563. /**
  34564. * An event triggered when a transform node is removed
  34565. */
  34566. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34567. /**
  34568. * An event triggered when a mesh is created
  34569. */
  34570. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34571. /**
  34572. * An event triggered when a mesh is removed
  34573. */
  34574. onMeshRemovedObservable: Observable<AbstractMesh>;
  34575. /**
  34576. * An event triggered when a skeleton is created
  34577. */
  34578. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34579. /**
  34580. * An event triggered when a skeleton is removed
  34581. */
  34582. onSkeletonRemovedObservable: Observable<Skeleton>;
  34583. /**
  34584. * An event triggered when a material is created
  34585. */
  34586. onNewMaterialAddedObservable: Observable<Material>;
  34587. /**
  34588. * An event triggered when a material is removed
  34589. */
  34590. onMaterialRemovedObservable: Observable<Material>;
  34591. /**
  34592. * An event triggered when a texture is created
  34593. */
  34594. onNewTextureAddedObservable: Observable<BaseTexture>;
  34595. /**
  34596. * An event triggered when a texture is removed
  34597. */
  34598. onTextureRemovedObservable: Observable<BaseTexture>;
  34599. /**
  34600. * An event triggered when render targets are about to be rendered
  34601. * Can happen multiple times per frame.
  34602. */
  34603. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34604. /**
  34605. * An event triggered when render targets were rendered.
  34606. * Can happen multiple times per frame.
  34607. */
  34608. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34609. /**
  34610. * An event triggered before calculating deterministic simulation step
  34611. */
  34612. onBeforeStepObservable: Observable<Scene>;
  34613. /**
  34614. * An event triggered after calculating deterministic simulation step
  34615. */
  34616. onAfterStepObservable: Observable<Scene>;
  34617. /**
  34618. * An event triggered when the activeCamera property is updated
  34619. */
  34620. onActiveCameraChanged: Observable<Scene>;
  34621. /**
  34622. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34623. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34624. * 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)
  34625. */
  34626. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34627. /**
  34628. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34629. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34630. * 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)
  34631. */
  34632. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34633. /**
  34634. * This Observable will when a mesh has been imported into the scene.
  34635. */
  34636. onMeshImportedObservable: Observable<AbstractMesh>;
  34637. /**
  34638. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34639. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34640. */
  34641. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34642. /** @hidden */
  34643. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34644. /**
  34645. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34646. */
  34647. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34648. /**
  34649. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34650. */
  34651. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34652. /**
  34653. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34654. */
  34655. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34656. /** Callback called when a pointer move is detected */
  34657. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34658. /** Callback called when a pointer down is detected */
  34659. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34660. /** Callback called when a pointer up is detected */
  34661. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34662. /** Callback called when a pointer pick is detected */
  34663. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34664. /**
  34665. * 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).
  34666. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34667. */
  34668. onPrePointerObservable: Observable<PointerInfoPre>;
  34669. /**
  34670. * Observable event triggered each time an input event is received from the rendering canvas
  34671. */
  34672. onPointerObservable: Observable<PointerInfo>;
  34673. /**
  34674. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34675. */
  34676. readonly unTranslatedPointer: Vector2;
  34677. /**
  34678. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34679. */
  34680. static DragMovementThreshold: number;
  34681. /**
  34682. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34683. */
  34684. static LongPressDelay: number;
  34685. /**
  34686. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34687. */
  34688. static DoubleClickDelay: number;
  34689. /** If you need to check double click without raising a single click at first click, enable this flag */
  34690. static ExclusiveDoubleClickMode: boolean;
  34691. /** @hidden */
  34692. _mirroredCameraPosition: Nullable<Vector3>;
  34693. /**
  34694. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34695. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34696. */
  34697. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34698. /**
  34699. * Observable event triggered each time an keyboard event is received from the hosting window
  34700. */
  34701. onKeyboardObservable: Observable<KeyboardInfo>;
  34702. private _useRightHandedSystem;
  34703. /**
  34704. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34705. */
  34706. useRightHandedSystem: boolean;
  34707. private _timeAccumulator;
  34708. private _currentStepId;
  34709. private _currentInternalStep;
  34710. /**
  34711. * Sets the step Id used by deterministic lock step
  34712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34713. * @param newStepId defines the step Id
  34714. */
  34715. setStepId(newStepId: number): void;
  34716. /**
  34717. * Gets the step Id used by deterministic lock step
  34718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34719. * @returns the step Id
  34720. */
  34721. getStepId(): number;
  34722. /**
  34723. * Gets the internal step used by deterministic lock step
  34724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34725. * @returns the internal step
  34726. */
  34727. getInternalStep(): number;
  34728. private _fogEnabled;
  34729. /**
  34730. * Gets or sets a boolean indicating if fog is enabled on this scene
  34731. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34732. * (Default is true)
  34733. */
  34734. fogEnabled: boolean;
  34735. private _fogMode;
  34736. /**
  34737. * Gets or sets the fog mode to use
  34738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34739. * | mode | value |
  34740. * | --- | --- |
  34741. * | FOGMODE_NONE | 0 |
  34742. * | FOGMODE_EXP | 1 |
  34743. * | FOGMODE_EXP2 | 2 |
  34744. * | FOGMODE_LINEAR | 3 |
  34745. */
  34746. fogMode: number;
  34747. /**
  34748. * Gets or sets the fog color to use
  34749. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34750. * (Default is Color3(0.2, 0.2, 0.3))
  34751. */
  34752. fogColor: Color3;
  34753. /**
  34754. * Gets or sets the fog density to use
  34755. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34756. * (Default is 0.1)
  34757. */
  34758. fogDensity: number;
  34759. /**
  34760. * Gets or sets the fog start distance to use
  34761. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34762. * (Default is 0)
  34763. */
  34764. fogStart: number;
  34765. /**
  34766. * Gets or sets the fog end distance to use
  34767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34768. * (Default is 1000)
  34769. */
  34770. fogEnd: number;
  34771. private _shadowsEnabled;
  34772. /**
  34773. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34774. */
  34775. shadowsEnabled: boolean;
  34776. private _lightsEnabled;
  34777. /**
  34778. * Gets or sets a boolean indicating if lights are enabled on this scene
  34779. */
  34780. lightsEnabled: boolean;
  34781. /** All of the active cameras added to this scene. */
  34782. activeCameras: Camera[];
  34783. /** @hidden */
  34784. _activeCamera: Nullable<Camera>;
  34785. /** Gets or sets the current active camera */
  34786. activeCamera: Nullable<Camera>;
  34787. private _defaultMaterial;
  34788. /** The default material used on meshes when no material is affected */
  34789. /** The default material used on meshes when no material is affected */
  34790. defaultMaterial: Material;
  34791. private _texturesEnabled;
  34792. /**
  34793. * Gets or sets a boolean indicating if textures are enabled on this scene
  34794. */
  34795. texturesEnabled: boolean;
  34796. /**
  34797. * Gets or sets a boolean indicating if particles are enabled on this scene
  34798. */
  34799. particlesEnabled: boolean;
  34800. /**
  34801. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34802. */
  34803. spritesEnabled: boolean;
  34804. private _skeletonsEnabled;
  34805. /**
  34806. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34807. */
  34808. skeletonsEnabled: boolean;
  34809. /**
  34810. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34811. */
  34812. lensFlaresEnabled: boolean;
  34813. /**
  34814. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34816. */
  34817. collisionsEnabled: boolean;
  34818. private _collisionCoordinator;
  34819. /** @hidden */
  34820. readonly collisionCoordinator: ICollisionCoordinator;
  34821. /**
  34822. * Defines the gravity applied to this scene (used only for collisions)
  34823. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34824. */
  34825. gravity: Vector3;
  34826. /**
  34827. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34828. */
  34829. postProcessesEnabled: boolean;
  34830. /**
  34831. * The list of postprocesses added to the scene
  34832. */
  34833. postProcesses: PostProcess[];
  34834. /**
  34835. * Gets the current postprocess manager
  34836. */
  34837. postProcessManager: PostProcessManager;
  34838. /**
  34839. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34840. */
  34841. renderTargetsEnabled: boolean;
  34842. /**
  34843. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34844. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34845. */
  34846. dumpNextRenderTargets: boolean;
  34847. /**
  34848. * The list of user defined render targets added to the scene
  34849. */
  34850. customRenderTargets: RenderTargetTexture[];
  34851. /**
  34852. * Defines if texture loading must be delayed
  34853. * If true, textures will only be loaded when they need to be rendered
  34854. */
  34855. useDelayedTextureLoading: boolean;
  34856. /**
  34857. * Gets the list of meshes imported to the scene through SceneLoader
  34858. */
  34859. importedMeshesFiles: String[];
  34860. /**
  34861. * Gets or sets a boolean indicating if probes are enabled on this scene
  34862. */
  34863. probesEnabled: boolean;
  34864. /**
  34865. * Gets or sets the current offline provider to use to store scene data
  34866. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34867. */
  34868. offlineProvider: IOfflineProvider;
  34869. /**
  34870. * Gets or sets the action manager associated with the scene
  34871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34872. */
  34873. actionManager: AbstractActionManager;
  34874. private _meshesForIntersections;
  34875. /**
  34876. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34877. */
  34878. proceduralTexturesEnabled: boolean;
  34879. private _engine;
  34880. private _totalVertices;
  34881. /** @hidden */
  34882. _activeIndices: PerfCounter;
  34883. /** @hidden */
  34884. _activeParticles: PerfCounter;
  34885. /** @hidden */
  34886. _activeBones: PerfCounter;
  34887. private _animationRatio;
  34888. /** @hidden */
  34889. _animationTimeLast: number;
  34890. /** @hidden */
  34891. _animationTime: number;
  34892. /**
  34893. * Gets or sets a general scale for animation speed
  34894. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34895. */
  34896. animationTimeScale: number;
  34897. /** @hidden */
  34898. _cachedMaterial: Nullable<Material>;
  34899. /** @hidden */
  34900. _cachedEffect: Nullable<Effect>;
  34901. /** @hidden */
  34902. _cachedVisibility: Nullable<number>;
  34903. private _renderId;
  34904. private _frameId;
  34905. private _executeWhenReadyTimeoutId;
  34906. private _intermediateRendering;
  34907. private _viewUpdateFlag;
  34908. private _projectionUpdateFlag;
  34909. /** @hidden */
  34910. _toBeDisposed: Nullable<IDisposable>[];
  34911. private _activeRequests;
  34912. /** @hidden */
  34913. _pendingData: any[];
  34914. private _isDisposed;
  34915. /**
  34916. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34917. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34918. */
  34919. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34920. private _activeMeshes;
  34921. private _processedMaterials;
  34922. private _renderTargets;
  34923. /** @hidden */
  34924. _activeParticleSystems: SmartArray<IParticleSystem>;
  34925. private _activeSkeletons;
  34926. private _softwareSkinnedMeshes;
  34927. private _renderingManager;
  34928. /** @hidden */
  34929. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34930. private _transformMatrix;
  34931. private _sceneUbo;
  34932. /** @hidden */
  34933. _viewMatrix: Matrix;
  34934. private _projectionMatrix;
  34935. /** @hidden */
  34936. _forcedViewPosition: Nullable<Vector3>;
  34937. /** @hidden */
  34938. _frustumPlanes: Plane[];
  34939. /**
  34940. * Gets the list of frustum planes (built from the active camera)
  34941. */
  34942. readonly frustumPlanes: Plane[];
  34943. /**
  34944. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34945. * This is useful if there are more lights that the maximum simulteanous authorized
  34946. */
  34947. requireLightSorting: boolean;
  34948. /** @hidden */
  34949. readonly useMaterialMeshMap: boolean;
  34950. /** @hidden */
  34951. readonly useClonedMeshhMap: boolean;
  34952. private _externalData;
  34953. private _uid;
  34954. /**
  34955. * @hidden
  34956. * Backing store of defined scene components.
  34957. */
  34958. _components: ISceneComponent[];
  34959. /**
  34960. * @hidden
  34961. * Backing store of defined scene components.
  34962. */
  34963. _serializableComponents: ISceneSerializableComponent[];
  34964. /**
  34965. * List of components to register on the next registration step.
  34966. */
  34967. private _transientComponents;
  34968. /**
  34969. * Registers the transient components if needed.
  34970. */
  34971. private _registerTransientComponents;
  34972. /**
  34973. * @hidden
  34974. * Add a component to the scene.
  34975. * Note that the ccomponent could be registered on th next frame if this is called after
  34976. * the register component stage.
  34977. * @param component Defines the component to add to the scene
  34978. */
  34979. _addComponent(component: ISceneComponent): void;
  34980. /**
  34981. * @hidden
  34982. * Gets a component from the scene.
  34983. * @param name defines the name of the component to retrieve
  34984. * @returns the component or null if not present
  34985. */
  34986. _getComponent(name: string): Nullable<ISceneComponent>;
  34987. /**
  34988. * @hidden
  34989. * Defines the actions happening before camera updates.
  34990. */
  34991. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34992. /**
  34993. * @hidden
  34994. * Defines the actions happening before clear the canvas.
  34995. */
  34996. _beforeClearStage: Stage<SimpleStageAction>;
  34997. /**
  34998. * @hidden
  34999. * Defines the actions when collecting render targets for the frame.
  35000. */
  35001. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35002. /**
  35003. * @hidden
  35004. * Defines the actions happening for one camera in the frame.
  35005. */
  35006. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35007. /**
  35008. * @hidden
  35009. * Defines the actions happening during the per mesh ready checks.
  35010. */
  35011. _isReadyForMeshStage: Stage<MeshStageAction>;
  35012. /**
  35013. * @hidden
  35014. * Defines the actions happening before evaluate active mesh checks.
  35015. */
  35016. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35017. /**
  35018. * @hidden
  35019. * Defines the actions happening during the evaluate sub mesh checks.
  35020. */
  35021. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35022. /**
  35023. * @hidden
  35024. * Defines the actions happening during the active mesh stage.
  35025. */
  35026. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35027. /**
  35028. * @hidden
  35029. * Defines the actions happening during the per camera render target step.
  35030. */
  35031. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35032. /**
  35033. * @hidden
  35034. * Defines the actions happening just before the active camera is drawing.
  35035. */
  35036. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35037. /**
  35038. * @hidden
  35039. * Defines the actions happening just before a render target is drawing.
  35040. */
  35041. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35042. /**
  35043. * @hidden
  35044. * Defines the actions happening just before a rendering group is drawing.
  35045. */
  35046. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35047. /**
  35048. * @hidden
  35049. * Defines the actions happening just before a mesh is drawing.
  35050. */
  35051. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35052. /**
  35053. * @hidden
  35054. * Defines the actions happening just after a mesh has been drawn.
  35055. */
  35056. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35057. /**
  35058. * @hidden
  35059. * Defines the actions happening just after a rendering group has been drawn.
  35060. */
  35061. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35062. /**
  35063. * @hidden
  35064. * Defines the actions happening just after the active camera has been drawn.
  35065. */
  35066. _afterCameraDrawStage: Stage<CameraStageAction>;
  35067. /**
  35068. * @hidden
  35069. * Defines the actions happening just after a render target has been drawn.
  35070. */
  35071. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35072. /**
  35073. * @hidden
  35074. * Defines the actions happening just after rendering all cameras and computing intersections.
  35075. */
  35076. _afterRenderStage: Stage<SimpleStageAction>;
  35077. /**
  35078. * @hidden
  35079. * Defines the actions happening when a pointer move event happens.
  35080. */
  35081. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35082. /**
  35083. * @hidden
  35084. * Defines the actions happening when a pointer down event happens.
  35085. */
  35086. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35087. /**
  35088. * @hidden
  35089. * Defines the actions happening when a pointer up event happens.
  35090. */
  35091. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35092. /**
  35093. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35094. */
  35095. private geometriesByUniqueId;
  35096. /**
  35097. * Creates a new Scene
  35098. * @param engine defines the engine to use to render this scene
  35099. * @param options defines the scene options
  35100. */
  35101. constructor(engine: Engine, options?: SceneOptions);
  35102. /**
  35103. * Gets a string idenfifying the name of the class
  35104. * @returns "Scene" string
  35105. */
  35106. getClassName(): string;
  35107. private _defaultMeshCandidates;
  35108. /**
  35109. * @hidden
  35110. */
  35111. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35112. private _defaultSubMeshCandidates;
  35113. /**
  35114. * @hidden
  35115. */
  35116. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35117. /**
  35118. * Sets the default candidate providers for the scene.
  35119. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35120. * and getCollidingSubMeshCandidates to their default function
  35121. */
  35122. setDefaultCandidateProviders(): void;
  35123. /**
  35124. * Gets the mesh that is currently under the pointer
  35125. */
  35126. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35127. /**
  35128. * Gets or sets the current on-screen X position of the pointer
  35129. */
  35130. pointerX: number;
  35131. /**
  35132. * Gets or sets the current on-screen Y position of the pointer
  35133. */
  35134. pointerY: number;
  35135. /**
  35136. * Gets the cached material (ie. the latest rendered one)
  35137. * @returns the cached material
  35138. */
  35139. getCachedMaterial(): Nullable<Material>;
  35140. /**
  35141. * Gets the cached effect (ie. the latest rendered one)
  35142. * @returns the cached effect
  35143. */
  35144. getCachedEffect(): Nullable<Effect>;
  35145. /**
  35146. * Gets the cached visibility state (ie. the latest rendered one)
  35147. * @returns the cached visibility state
  35148. */
  35149. getCachedVisibility(): Nullable<number>;
  35150. /**
  35151. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35152. * @param material defines the current material
  35153. * @param effect defines the current effect
  35154. * @param visibility defines the current visibility state
  35155. * @returns true if one parameter is not cached
  35156. */
  35157. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35158. /**
  35159. * Gets the engine associated with the scene
  35160. * @returns an Engine
  35161. */
  35162. getEngine(): Engine;
  35163. /**
  35164. * Gets the total number of vertices rendered per frame
  35165. * @returns the total number of vertices rendered per frame
  35166. */
  35167. getTotalVertices(): number;
  35168. /**
  35169. * Gets the performance counter for total vertices
  35170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35171. */
  35172. readonly totalVerticesPerfCounter: PerfCounter;
  35173. /**
  35174. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35175. * @returns the total number of active indices rendered per frame
  35176. */
  35177. getActiveIndices(): number;
  35178. /**
  35179. * Gets the performance counter for active indices
  35180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35181. */
  35182. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35183. /**
  35184. * Gets the total number of active particles rendered per frame
  35185. * @returns the total number of active particles rendered per frame
  35186. */
  35187. getActiveParticles(): number;
  35188. /**
  35189. * Gets the performance counter for active particles
  35190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35191. */
  35192. readonly activeParticlesPerfCounter: PerfCounter;
  35193. /**
  35194. * Gets the total number of active bones rendered per frame
  35195. * @returns the total number of active bones rendered per frame
  35196. */
  35197. getActiveBones(): number;
  35198. /**
  35199. * Gets the performance counter for active bones
  35200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35201. */
  35202. readonly activeBonesPerfCounter: PerfCounter;
  35203. /**
  35204. * Gets the array of active meshes
  35205. * @returns an array of AbstractMesh
  35206. */
  35207. getActiveMeshes(): SmartArray<AbstractMesh>;
  35208. /**
  35209. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35210. * @returns a number
  35211. */
  35212. getAnimationRatio(): number;
  35213. /**
  35214. * Gets an unique Id for the current render phase
  35215. * @returns a number
  35216. */
  35217. getRenderId(): number;
  35218. /**
  35219. * Gets an unique Id for the current frame
  35220. * @returns a number
  35221. */
  35222. getFrameId(): number;
  35223. /** Call this function if you want to manually increment the render Id*/
  35224. incrementRenderId(): void;
  35225. private _createUbo;
  35226. /**
  35227. * Use this method to simulate a pointer move on a mesh
  35228. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35229. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35230. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35231. * @returns the current scene
  35232. */
  35233. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35234. /**
  35235. * Use this method to simulate a pointer down on a mesh
  35236. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35237. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35238. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35239. * @returns the current scene
  35240. */
  35241. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35242. /**
  35243. * Use this method to simulate a pointer up on a mesh
  35244. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35245. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35246. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35247. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35248. * @returns the current scene
  35249. */
  35250. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35251. /**
  35252. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35253. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35254. * @returns true if the pointer was captured
  35255. */
  35256. isPointerCaptured(pointerId?: number): boolean;
  35257. /**
  35258. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35259. * @param attachUp defines if you want to attach events to pointerup
  35260. * @param attachDown defines if you want to attach events to pointerdown
  35261. * @param attachMove defines if you want to attach events to pointermove
  35262. */
  35263. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35264. /** Detaches all event handlers*/
  35265. detachControl(): void;
  35266. /**
  35267. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35268. * Delay loaded resources are not taking in account
  35269. * @return true if all required resources are ready
  35270. */
  35271. isReady(): boolean;
  35272. /** Resets all cached information relative to material (including effect and visibility) */
  35273. resetCachedMaterial(): void;
  35274. /**
  35275. * Registers a function to be called before every frame render
  35276. * @param func defines the function to register
  35277. */
  35278. registerBeforeRender(func: () => void): void;
  35279. /**
  35280. * Unregisters a function called before every frame render
  35281. * @param func defines the function to unregister
  35282. */
  35283. unregisterBeforeRender(func: () => void): void;
  35284. /**
  35285. * Registers a function to be called after every frame render
  35286. * @param func defines the function to register
  35287. */
  35288. registerAfterRender(func: () => void): void;
  35289. /**
  35290. * Unregisters a function called after every frame render
  35291. * @param func defines the function to unregister
  35292. */
  35293. unregisterAfterRender(func: () => void): void;
  35294. private _executeOnceBeforeRender;
  35295. /**
  35296. * The provided function will run before render once and will be disposed afterwards.
  35297. * A timeout delay can be provided so that the function will be executed in N ms.
  35298. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35299. * @param func The function to be executed.
  35300. * @param timeout optional delay in ms
  35301. */
  35302. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35303. /** @hidden */
  35304. _addPendingData(data: any): void;
  35305. /** @hidden */
  35306. _removePendingData(data: any): void;
  35307. /**
  35308. * Returns the number of items waiting to be loaded
  35309. * @returns the number of items waiting to be loaded
  35310. */
  35311. getWaitingItemsCount(): number;
  35312. /**
  35313. * Returns a boolean indicating if the scene is still loading data
  35314. */
  35315. readonly isLoading: boolean;
  35316. /**
  35317. * Registers a function to be executed when the scene is ready
  35318. * @param {Function} func - the function to be executed
  35319. */
  35320. executeWhenReady(func: () => void): void;
  35321. /**
  35322. * Returns a promise that resolves when the scene is ready
  35323. * @returns A promise that resolves when the scene is ready
  35324. */
  35325. whenReadyAsync(): Promise<void>;
  35326. /** @hidden */
  35327. _checkIsReady(): void;
  35328. /**
  35329. * Gets all animatable attached to the scene
  35330. */
  35331. readonly animatables: Animatable[];
  35332. /**
  35333. * Resets the last animation time frame.
  35334. * Useful to override when animations start running when loading a scene for the first time.
  35335. */
  35336. resetLastAnimationTimeFrame(): void;
  35337. /**
  35338. * Gets the current view matrix
  35339. * @returns a Matrix
  35340. */
  35341. getViewMatrix(): Matrix;
  35342. /**
  35343. * Gets the current projection matrix
  35344. * @returns a Matrix
  35345. */
  35346. getProjectionMatrix(): Matrix;
  35347. /**
  35348. * Gets the current transform matrix
  35349. * @returns a Matrix made of View * Projection
  35350. */
  35351. getTransformMatrix(): Matrix;
  35352. /**
  35353. * Sets the current transform matrix
  35354. * @param viewL defines the View matrix to use
  35355. * @param projectionL defines the Projection matrix to use
  35356. * @param viewR defines the right View matrix to use (if provided)
  35357. * @param projectionR defines the right Projection matrix to use (if provided)
  35358. */
  35359. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35360. /**
  35361. * Gets the uniform buffer used to store scene data
  35362. * @returns a UniformBuffer
  35363. */
  35364. getSceneUniformBuffer(): UniformBuffer;
  35365. /**
  35366. * Gets an unique (relatively to the current scene) Id
  35367. * @returns an unique number for the scene
  35368. */
  35369. getUniqueId(): number;
  35370. /**
  35371. * Add a mesh to the list of scene's meshes
  35372. * @param newMesh defines the mesh to add
  35373. * @param recursive if all child meshes should also be added to the scene
  35374. */
  35375. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35376. /**
  35377. * Remove a mesh for the list of scene's meshes
  35378. * @param toRemove defines the mesh to remove
  35379. * @param recursive if all child meshes should also be removed from the scene
  35380. * @returns the index where the mesh was in the mesh list
  35381. */
  35382. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35383. /**
  35384. * Add a transform node to the list of scene's transform nodes
  35385. * @param newTransformNode defines the transform node to add
  35386. */
  35387. addTransformNode(newTransformNode: TransformNode): void;
  35388. /**
  35389. * Remove a transform node for the list of scene's transform nodes
  35390. * @param toRemove defines the transform node to remove
  35391. * @returns the index where the transform node was in the transform node list
  35392. */
  35393. removeTransformNode(toRemove: TransformNode): number;
  35394. /**
  35395. * Remove a skeleton for the list of scene's skeletons
  35396. * @param toRemove defines the skeleton to remove
  35397. * @returns the index where the skeleton was in the skeleton list
  35398. */
  35399. removeSkeleton(toRemove: Skeleton): number;
  35400. /**
  35401. * Remove a morph target for the list of scene's morph targets
  35402. * @param toRemove defines the morph target to remove
  35403. * @returns the index where the morph target was in the morph target list
  35404. */
  35405. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35406. /**
  35407. * Remove a light for the list of scene's lights
  35408. * @param toRemove defines the light to remove
  35409. * @returns the index where the light was in the light list
  35410. */
  35411. removeLight(toRemove: Light): number;
  35412. /**
  35413. * Remove a camera for the list of scene's cameras
  35414. * @param toRemove defines the camera to remove
  35415. * @returns the index where the camera was in the camera list
  35416. */
  35417. removeCamera(toRemove: Camera): number;
  35418. /**
  35419. * Remove a particle system for the list of scene's particle systems
  35420. * @param toRemove defines the particle system to remove
  35421. * @returns the index where the particle system was in the particle system list
  35422. */
  35423. removeParticleSystem(toRemove: IParticleSystem): number;
  35424. /**
  35425. * Remove a animation for the list of scene's animations
  35426. * @param toRemove defines the animation to remove
  35427. * @returns the index where the animation was in the animation list
  35428. */
  35429. removeAnimation(toRemove: Animation): number;
  35430. /**
  35431. * Will stop the animation of the given target
  35432. * @param target - the target
  35433. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35434. * @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)
  35435. */
  35436. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35437. /**
  35438. * Removes the given animation group from this scene.
  35439. * @param toRemove The animation group to remove
  35440. * @returns The index of the removed animation group
  35441. */
  35442. removeAnimationGroup(toRemove: AnimationGroup): number;
  35443. /**
  35444. * Removes the given multi-material from this scene.
  35445. * @param toRemove The multi-material to remove
  35446. * @returns The index of the removed multi-material
  35447. */
  35448. removeMultiMaterial(toRemove: MultiMaterial): number;
  35449. /**
  35450. * Removes the given material from this scene.
  35451. * @param toRemove The material to remove
  35452. * @returns The index of the removed material
  35453. */
  35454. removeMaterial(toRemove: Material): number;
  35455. /**
  35456. * Removes the given action manager from this scene.
  35457. * @param toRemove The action manager to remove
  35458. * @returns The index of the removed action manager
  35459. */
  35460. removeActionManager(toRemove: AbstractActionManager): number;
  35461. /**
  35462. * Removes the given texture from this scene.
  35463. * @param toRemove The texture to remove
  35464. * @returns The index of the removed texture
  35465. */
  35466. removeTexture(toRemove: BaseTexture): number;
  35467. /**
  35468. * Adds the given light to this scene
  35469. * @param newLight The light to add
  35470. */
  35471. addLight(newLight: Light): void;
  35472. /**
  35473. * Sorts the list list based on light priorities
  35474. */
  35475. sortLightsByPriority(): void;
  35476. /**
  35477. * Adds the given camera to this scene
  35478. * @param newCamera The camera to add
  35479. */
  35480. addCamera(newCamera: Camera): void;
  35481. /**
  35482. * Adds the given skeleton to this scene
  35483. * @param newSkeleton The skeleton to add
  35484. */
  35485. addSkeleton(newSkeleton: Skeleton): void;
  35486. /**
  35487. * Adds the given particle system to this scene
  35488. * @param newParticleSystem The particle system to add
  35489. */
  35490. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35491. /**
  35492. * Adds the given animation to this scene
  35493. * @param newAnimation The animation to add
  35494. */
  35495. addAnimation(newAnimation: Animation): void;
  35496. /**
  35497. * Adds the given animation group to this scene.
  35498. * @param newAnimationGroup The animation group to add
  35499. */
  35500. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35501. /**
  35502. * Adds the given multi-material to this scene
  35503. * @param newMultiMaterial The multi-material to add
  35504. */
  35505. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35506. /**
  35507. * Adds the given material to this scene
  35508. * @param newMaterial The material to add
  35509. */
  35510. addMaterial(newMaterial: Material): void;
  35511. /**
  35512. * Adds the given morph target to this scene
  35513. * @param newMorphTargetManager The morph target to add
  35514. */
  35515. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35516. /**
  35517. * Adds the given geometry to this scene
  35518. * @param newGeometry The geometry to add
  35519. */
  35520. addGeometry(newGeometry: Geometry): void;
  35521. /**
  35522. * Adds the given action manager to this scene
  35523. * @param newActionManager The action manager to add
  35524. */
  35525. addActionManager(newActionManager: AbstractActionManager): void;
  35526. /**
  35527. * Adds the given texture to this scene.
  35528. * @param newTexture The texture to add
  35529. */
  35530. addTexture(newTexture: BaseTexture): void;
  35531. /**
  35532. * Switch active camera
  35533. * @param newCamera defines the new active camera
  35534. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35535. */
  35536. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35537. /**
  35538. * sets the active camera of the scene using its ID
  35539. * @param id defines the camera's ID
  35540. * @return the new active camera or null if none found.
  35541. */
  35542. setActiveCameraByID(id: string): Nullable<Camera>;
  35543. /**
  35544. * sets the active camera of the scene using its name
  35545. * @param name defines the camera's name
  35546. * @returns the new active camera or null if none found.
  35547. */
  35548. setActiveCameraByName(name: string): Nullable<Camera>;
  35549. /**
  35550. * get an animation group using its name
  35551. * @param name defines the material's name
  35552. * @return the animation group or null if none found.
  35553. */
  35554. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35555. /**
  35556. * Get a material using its unique id
  35557. * @param uniqueId defines the material's unique id
  35558. * @return the material or null if none found.
  35559. */
  35560. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35561. /**
  35562. * get a material using its id
  35563. * @param id defines the material's ID
  35564. * @return the material or null if none found.
  35565. */
  35566. getMaterialByID(id: string): Nullable<Material>;
  35567. /**
  35568. * Gets a the last added material using a given id
  35569. * @param id defines the material's ID
  35570. * @return the last material with the given id or null if none found.
  35571. */
  35572. getLastMaterialByID(id: string): Nullable<Material>;
  35573. /**
  35574. * Gets a material using its name
  35575. * @param name defines the material's name
  35576. * @return the material or null if none found.
  35577. */
  35578. getMaterialByName(name: string): Nullable<Material>;
  35579. /**
  35580. * Get a texture using its unique id
  35581. * @param uniqueId defines the texture's unique id
  35582. * @return the texture or null if none found.
  35583. */
  35584. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35585. /**
  35586. * Gets a camera using its id
  35587. * @param id defines the id to look for
  35588. * @returns the camera or null if not found
  35589. */
  35590. getCameraByID(id: string): Nullable<Camera>;
  35591. /**
  35592. * Gets a camera using its unique id
  35593. * @param uniqueId defines the unique id to look for
  35594. * @returns the camera or null if not found
  35595. */
  35596. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35597. /**
  35598. * Gets a camera using its name
  35599. * @param name defines the camera's name
  35600. * @return the camera or null if none found.
  35601. */
  35602. getCameraByName(name: string): Nullable<Camera>;
  35603. /**
  35604. * Gets a bone using its id
  35605. * @param id defines the bone's id
  35606. * @return the bone or null if not found
  35607. */
  35608. getBoneByID(id: string): Nullable<Bone>;
  35609. /**
  35610. * Gets a bone using its id
  35611. * @param name defines the bone's name
  35612. * @return the bone or null if not found
  35613. */
  35614. getBoneByName(name: string): Nullable<Bone>;
  35615. /**
  35616. * Gets a light node using its name
  35617. * @param name defines the the light's name
  35618. * @return the light or null if none found.
  35619. */
  35620. getLightByName(name: string): Nullable<Light>;
  35621. /**
  35622. * Gets a light node using its id
  35623. * @param id defines the light's id
  35624. * @return the light or null if none found.
  35625. */
  35626. getLightByID(id: string): Nullable<Light>;
  35627. /**
  35628. * Gets a light node using its scene-generated unique ID
  35629. * @param uniqueId defines the light's unique id
  35630. * @return the light or null if none found.
  35631. */
  35632. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35633. /**
  35634. * Gets a particle system by id
  35635. * @param id defines the particle system id
  35636. * @return the corresponding system or null if none found
  35637. */
  35638. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35639. /**
  35640. * Gets a geometry using its ID
  35641. * @param id defines the geometry's id
  35642. * @return the geometry or null if none found.
  35643. */
  35644. getGeometryByID(id: string): Nullable<Geometry>;
  35645. private _getGeometryByUniqueID;
  35646. /**
  35647. * Add a new geometry to this scene
  35648. * @param geometry defines the geometry to be added to the scene.
  35649. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35650. * @return a boolean defining if the geometry was added or not
  35651. */
  35652. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35653. /**
  35654. * Removes an existing geometry
  35655. * @param geometry defines the geometry to be removed from the scene
  35656. * @return a boolean defining if the geometry was removed or not
  35657. */
  35658. removeGeometry(geometry: Geometry): boolean;
  35659. /**
  35660. * Gets the list of geometries attached to the scene
  35661. * @returns an array of Geometry
  35662. */
  35663. getGeometries(): Geometry[];
  35664. /**
  35665. * Gets the first added mesh found of a given ID
  35666. * @param id defines the id to search for
  35667. * @return the mesh found or null if not found at all
  35668. */
  35669. getMeshByID(id: string): Nullable<AbstractMesh>;
  35670. /**
  35671. * Gets a list of meshes using their id
  35672. * @param id defines the id to search for
  35673. * @returns a list of meshes
  35674. */
  35675. getMeshesByID(id: string): Array<AbstractMesh>;
  35676. /**
  35677. * Gets the first added transform node found of a given ID
  35678. * @param id defines the id to search for
  35679. * @return the found transform node or null if not found at all.
  35680. */
  35681. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35682. /**
  35683. * Gets a transform node with its auto-generated unique id
  35684. * @param uniqueId efines the unique id to search for
  35685. * @return the found transform node or null if not found at all.
  35686. */
  35687. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35688. /**
  35689. * Gets a list of transform nodes using their id
  35690. * @param id defines the id to search for
  35691. * @returns a list of transform nodes
  35692. */
  35693. getTransformNodesByID(id: string): Array<TransformNode>;
  35694. /**
  35695. * Gets a mesh with its auto-generated unique id
  35696. * @param uniqueId defines the unique id to search for
  35697. * @return the found mesh or null if not found at all.
  35698. */
  35699. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35700. /**
  35701. * Gets a the last added mesh using a given id
  35702. * @param id defines the id to search for
  35703. * @return the found mesh or null if not found at all.
  35704. */
  35705. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35706. /**
  35707. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35708. * @param id defines the id to search for
  35709. * @return the found node or null if not found at all
  35710. */
  35711. getLastEntryByID(id: string): Nullable<Node>;
  35712. /**
  35713. * Gets a node (Mesh, Camera, Light) using a given id
  35714. * @param id defines the id to search for
  35715. * @return the found node or null if not found at all
  35716. */
  35717. getNodeByID(id: string): Nullable<Node>;
  35718. /**
  35719. * Gets a node (Mesh, Camera, Light) using a given name
  35720. * @param name defines the name to search for
  35721. * @return the found node or null if not found at all.
  35722. */
  35723. getNodeByName(name: string): Nullable<Node>;
  35724. /**
  35725. * Gets a mesh using a given name
  35726. * @param name defines the name to search for
  35727. * @return the found mesh or null if not found at all.
  35728. */
  35729. getMeshByName(name: string): Nullable<AbstractMesh>;
  35730. /**
  35731. * Gets a transform node using a given name
  35732. * @param name defines the name to search for
  35733. * @return the found transform node or null if not found at all.
  35734. */
  35735. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35736. /**
  35737. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35738. * @param id defines the id to search for
  35739. * @return the found skeleton or null if not found at all.
  35740. */
  35741. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35742. /**
  35743. * Gets a skeleton using a given auto generated unique id
  35744. * @param uniqueId defines the unique id to search for
  35745. * @return the found skeleton or null if not found at all.
  35746. */
  35747. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35748. /**
  35749. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35750. * @param id defines the id to search for
  35751. * @return the found skeleton or null if not found at all.
  35752. */
  35753. getSkeletonById(id: string): Nullable<Skeleton>;
  35754. /**
  35755. * Gets a skeleton using a given name
  35756. * @param name defines the name to search for
  35757. * @return the found skeleton or null if not found at all.
  35758. */
  35759. getSkeletonByName(name: string): Nullable<Skeleton>;
  35760. /**
  35761. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35762. * @param id defines the id to search for
  35763. * @return the found morph target manager or null if not found at all.
  35764. */
  35765. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35766. /**
  35767. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35768. * @param id defines the id to search for
  35769. * @return the found morph target or null if not found at all.
  35770. */
  35771. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35772. /**
  35773. * Gets a boolean indicating if the given mesh is active
  35774. * @param mesh defines the mesh to look for
  35775. * @returns true if the mesh is in the active list
  35776. */
  35777. isActiveMesh(mesh: AbstractMesh): boolean;
  35778. /**
  35779. * Return a unique id as a string which can serve as an identifier for the scene
  35780. */
  35781. readonly uid: string;
  35782. /**
  35783. * Add an externaly attached data from its key.
  35784. * This method call will fail and return false, if such key already exists.
  35785. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35786. * @param key the unique key that identifies the data
  35787. * @param data the data object to associate to the key for this Engine instance
  35788. * @return true if no such key were already present and the data was added successfully, false otherwise
  35789. */
  35790. addExternalData<T>(key: string, data: T): boolean;
  35791. /**
  35792. * Get an externaly attached data from its key
  35793. * @param key the unique key that identifies the data
  35794. * @return the associated data, if present (can be null), or undefined if not present
  35795. */
  35796. getExternalData<T>(key: string): Nullable<T>;
  35797. /**
  35798. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35799. * @param key the unique key that identifies the data
  35800. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35801. * @return the associated data, can be null if the factory returned null.
  35802. */
  35803. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35804. /**
  35805. * Remove an externaly attached data from the Engine instance
  35806. * @param key the unique key that identifies the data
  35807. * @return true if the data was successfully removed, false if it doesn't exist
  35808. */
  35809. removeExternalData(key: string): boolean;
  35810. private _evaluateSubMesh;
  35811. /**
  35812. * Clear the processed materials smart array preventing retention point in material dispose.
  35813. */
  35814. freeProcessedMaterials(): void;
  35815. private _preventFreeActiveMeshesAndRenderingGroups;
  35816. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35817. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35818. * when disposing several meshes in a row or a hierarchy of meshes.
  35819. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35820. */
  35821. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35822. /**
  35823. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35824. */
  35825. freeActiveMeshes(): void;
  35826. /**
  35827. * Clear the info related to rendering groups preventing retention points during dispose.
  35828. */
  35829. freeRenderingGroups(): void;
  35830. /** @hidden */
  35831. _isInIntermediateRendering(): boolean;
  35832. /**
  35833. * Lambda returning the list of potentially active meshes.
  35834. */
  35835. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35836. /**
  35837. * Lambda returning the list of potentially active sub meshes.
  35838. */
  35839. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35840. /**
  35841. * Lambda returning the list of potentially intersecting sub meshes.
  35842. */
  35843. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35844. /**
  35845. * Lambda returning the list of potentially colliding sub meshes.
  35846. */
  35847. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35848. private _activeMeshesFrozen;
  35849. /**
  35850. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35851. * @returns the current scene
  35852. */
  35853. freezeActiveMeshes(): Scene;
  35854. /**
  35855. * Use this function to restart evaluating active meshes on every frame
  35856. * @returns the current scene
  35857. */
  35858. unfreezeActiveMeshes(): Scene;
  35859. private _evaluateActiveMeshes;
  35860. private _activeMesh;
  35861. /**
  35862. * Update the transform matrix to update from the current active camera
  35863. * @param force defines a boolean used to force the update even if cache is up to date
  35864. */
  35865. updateTransformMatrix(force?: boolean): void;
  35866. private _bindFrameBuffer;
  35867. /** @hidden */
  35868. _allowPostProcessClearColor: boolean;
  35869. /** @hidden */
  35870. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35871. private _processSubCameras;
  35872. private _checkIntersections;
  35873. /** @hidden */
  35874. _advancePhysicsEngineStep(step: number): void;
  35875. /**
  35876. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35877. */
  35878. getDeterministicFrameTime: () => number;
  35879. /** @hidden */
  35880. _animate(): void;
  35881. /** Execute all animations (for a frame) */
  35882. animate(): void;
  35883. /**
  35884. * Render the scene
  35885. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35886. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35887. */
  35888. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35889. /**
  35890. * Freeze all materials
  35891. * A frozen material will not be updatable but should be faster to render
  35892. */
  35893. freezeMaterials(): void;
  35894. /**
  35895. * Unfreeze all materials
  35896. * A frozen material will not be updatable but should be faster to render
  35897. */
  35898. unfreezeMaterials(): void;
  35899. /**
  35900. * Releases all held ressources
  35901. */
  35902. dispose(): void;
  35903. /**
  35904. * Gets if the scene is already disposed
  35905. */
  35906. readonly isDisposed: boolean;
  35907. /**
  35908. * Call this function to reduce memory footprint of the scene.
  35909. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35910. */
  35911. clearCachedVertexData(): void;
  35912. /**
  35913. * This function will remove the local cached buffer data from texture.
  35914. * It will save memory but will prevent the texture from being rebuilt
  35915. */
  35916. cleanCachedTextureBuffer(): void;
  35917. /**
  35918. * Get the world extend vectors with an optional filter
  35919. *
  35920. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35921. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35922. */
  35923. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35924. min: Vector3;
  35925. max: Vector3;
  35926. };
  35927. /**
  35928. * Creates a ray that can be used to pick in the scene
  35929. * @param x defines the x coordinate of the origin (on-screen)
  35930. * @param y defines the y coordinate of the origin (on-screen)
  35931. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35932. * @param camera defines the camera to use for the picking
  35933. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35934. * @returns a Ray
  35935. */
  35936. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35937. /**
  35938. * Creates a ray that can be used to pick in the scene
  35939. * @param x defines the x coordinate of the origin (on-screen)
  35940. * @param y defines the y coordinate of the origin (on-screen)
  35941. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35942. * @param result defines the ray where to store the picking ray
  35943. * @param camera defines the camera to use for the picking
  35944. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35945. * @returns the current scene
  35946. */
  35947. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35948. /**
  35949. * Creates a ray that can be used to pick in the scene
  35950. * @param x defines the x coordinate of the origin (on-screen)
  35951. * @param y defines the y coordinate of the origin (on-screen)
  35952. * @param camera defines the camera to use for the picking
  35953. * @returns a Ray
  35954. */
  35955. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35956. /**
  35957. * Creates a ray that can be used to pick in the scene
  35958. * @param x defines the x coordinate of the origin (on-screen)
  35959. * @param y defines the y coordinate of the origin (on-screen)
  35960. * @param result defines the ray where to store the picking ray
  35961. * @param camera defines the camera to use for the picking
  35962. * @returns the current scene
  35963. */
  35964. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35965. /** Launch a ray to try to pick a mesh in the scene
  35966. * @param x position on screen
  35967. * @param y position on screen
  35968. * @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
  35969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35970. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35971. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35972. * @returns a PickingInfo
  35973. */
  35974. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35975. /** Use the given ray to pick a mesh in the scene
  35976. * @param ray The ray to use to pick meshes
  35977. * @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
  35978. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35979. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35980. * @returns a PickingInfo
  35981. */
  35982. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35983. /**
  35984. * Launch a ray to try to pick a mesh in the scene
  35985. * @param x X position on screen
  35986. * @param y Y position on screen
  35987. * @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
  35988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35989. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35990. * @returns an array of PickingInfo
  35991. */
  35992. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35993. /**
  35994. * Launch a ray to try to pick a mesh in the scene
  35995. * @param ray Ray to use
  35996. * @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
  35997. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35998. * @returns an array of PickingInfo
  35999. */
  36000. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36001. /**
  36002. * Force the value of meshUnderPointer
  36003. * @param mesh defines the mesh to use
  36004. */
  36005. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36006. /**
  36007. * Gets the mesh under the pointer
  36008. * @returns a Mesh or null if no mesh is under the pointer
  36009. */
  36010. getPointerOverMesh(): Nullable<AbstractMesh>;
  36011. /** @hidden */
  36012. _rebuildGeometries(): void;
  36013. /** @hidden */
  36014. _rebuildTextures(): void;
  36015. private _getByTags;
  36016. /**
  36017. * Get a list of meshes by tags
  36018. * @param tagsQuery defines the tags query to use
  36019. * @param forEach defines a predicate used to filter results
  36020. * @returns an array of Mesh
  36021. */
  36022. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36023. /**
  36024. * Get a list of cameras by tags
  36025. * @param tagsQuery defines the tags query to use
  36026. * @param forEach defines a predicate used to filter results
  36027. * @returns an array of Camera
  36028. */
  36029. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36030. /**
  36031. * Get a list of lights by tags
  36032. * @param tagsQuery defines the tags query to use
  36033. * @param forEach defines a predicate used to filter results
  36034. * @returns an array of Light
  36035. */
  36036. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36037. /**
  36038. * Get a list of materials by tags
  36039. * @param tagsQuery defines the tags query to use
  36040. * @param forEach defines a predicate used to filter results
  36041. * @returns an array of Material
  36042. */
  36043. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36044. /**
  36045. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36046. * This allowed control for front to back rendering or reversly depending of the special needs.
  36047. *
  36048. * @param renderingGroupId The rendering group id corresponding to its index
  36049. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36050. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36051. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36052. */
  36053. 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;
  36054. /**
  36055. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36056. *
  36057. * @param renderingGroupId The rendering group id corresponding to its index
  36058. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36059. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36060. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36061. */
  36062. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36063. /**
  36064. * Gets the current auto clear configuration for one rendering group of the rendering
  36065. * manager.
  36066. * @param index the rendering group index to get the information for
  36067. * @returns The auto clear setup for the requested rendering group
  36068. */
  36069. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36070. private _blockMaterialDirtyMechanism;
  36071. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36072. blockMaterialDirtyMechanism: boolean;
  36073. /**
  36074. * Will flag all materials as dirty to trigger new shader compilation
  36075. * @param flag defines the flag used to specify which material part must be marked as dirty
  36076. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36077. */
  36078. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36079. /** @hidden */
  36080. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36081. /** @hidden */
  36082. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36083. /** @hidden */
  36084. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36085. /** @hidden */
  36086. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36087. /** @hidden */
  36088. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36089. /** @hidden */
  36090. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36091. }
  36092. }
  36093. declare module "babylonjs/assetContainer" {
  36094. import { AbstractScene } from "babylonjs/abstractScene";
  36095. import { Scene } from "babylonjs/scene";
  36096. import { Mesh } from "babylonjs/Meshes/mesh";
  36097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36098. import { Skeleton } from "babylonjs/Bones/skeleton";
  36099. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36100. /**
  36101. * Set of assets to keep when moving a scene into an asset container.
  36102. */
  36103. export class KeepAssets extends AbstractScene {
  36104. }
  36105. /**
  36106. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36107. */
  36108. export class InstantiatedEntries {
  36109. /**
  36110. * List of new root nodes (eg. nodes with no parent)
  36111. */
  36112. rootNodes: TransformNode[];
  36113. /**
  36114. * List of new skeletons
  36115. */
  36116. skeletons: Skeleton[];
  36117. /**
  36118. * List of new animation groups
  36119. */
  36120. animationGroups: AnimationGroup[];
  36121. }
  36122. /**
  36123. * Container with a set of assets that can be added or removed from a scene.
  36124. */
  36125. export class AssetContainer extends AbstractScene {
  36126. /**
  36127. * The scene the AssetContainer belongs to.
  36128. */
  36129. scene: Scene;
  36130. /**
  36131. * Instantiates an AssetContainer.
  36132. * @param scene The scene the AssetContainer belongs to.
  36133. */
  36134. constructor(scene: Scene);
  36135. /**
  36136. * Instantiate or clone all meshes and add the new ones to the scene.
  36137. * Skeletons and animation groups will all be cloned
  36138. * @param nameFunction defines an optional function used to get new names for clones
  36139. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36140. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36141. */
  36142. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36143. /**
  36144. * Adds all the assets from the container to the scene.
  36145. */
  36146. addAllToScene(): void;
  36147. /**
  36148. * Removes all the assets in the container from the scene
  36149. */
  36150. removeAllFromScene(): void;
  36151. /**
  36152. * Disposes all the assets in the container
  36153. */
  36154. dispose(): void;
  36155. private _moveAssets;
  36156. /**
  36157. * Removes all the assets contained in the scene and adds them to the container.
  36158. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36159. */
  36160. moveAllFromScene(keepAssets?: KeepAssets): void;
  36161. /**
  36162. * 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.
  36163. * @returns the root mesh
  36164. */
  36165. createRootMesh(): Mesh;
  36166. }
  36167. }
  36168. declare module "babylonjs/abstractScene" {
  36169. import { Scene } from "babylonjs/scene";
  36170. import { Nullable } from "babylonjs/types";
  36171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36173. import { Geometry } from "babylonjs/Meshes/geometry";
  36174. import { Skeleton } from "babylonjs/Bones/skeleton";
  36175. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36176. import { AssetContainer } from "babylonjs/assetContainer";
  36177. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36178. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36180. import { Material } from "babylonjs/Materials/material";
  36181. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36182. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36183. import { Camera } from "babylonjs/Cameras/camera";
  36184. import { Light } from "babylonjs/Lights/light";
  36185. import { Node } from "babylonjs/node";
  36186. import { Animation } from "babylonjs/Animations/animation";
  36187. /**
  36188. * Defines how the parser contract is defined.
  36189. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36190. */
  36191. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36192. /**
  36193. * Defines how the individual parser contract is defined.
  36194. * These parser can parse an individual asset
  36195. */
  36196. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36197. /**
  36198. * Base class of the scene acting as a container for the different elements composing a scene.
  36199. * This class is dynamically extended by the different components of the scene increasing
  36200. * flexibility and reducing coupling
  36201. */
  36202. export abstract class AbstractScene {
  36203. /**
  36204. * Stores the list of available parsers in the application.
  36205. */
  36206. private static _BabylonFileParsers;
  36207. /**
  36208. * Stores the list of available individual parsers in the application.
  36209. */
  36210. private static _IndividualBabylonFileParsers;
  36211. /**
  36212. * Adds a parser in the list of available ones
  36213. * @param name Defines the name of the parser
  36214. * @param parser Defines the parser to add
  36215. */
  36216. static AddParser(name: string, parser: BabylonFileParser): void;
  36217. /**
  36218. * Gets a general parser from the list of avaialble ones
  36219. * @param name Defines the name of the parser
  36220. * @returns the requested parser or null
  36221. */
  36222. static GetParser(name: string): Nullable<BabylonFileParser>;
  36223. /**
  36224. * Adds n individual parser in the list of available ones
  36225. * @param name Defines the name of the parser
  36226. * @param parser Defines the parser to add
  36227. */
  36228. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36229. /**
  36230. * Gets an individual parser from the list of avaialble ones
  36231. * @param name Defines the name of the parser
  36232. * @returns the requested parser or null
  36233. */
  36234. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36235. /**
  36236. * Parser json data and populate both a scene and its associated container object
  36237. * @param jsonData Defines the data to parse
  36238. * @param scene Defines the scene to parse the data for
  36239. * @param container Defines the container attached to the parsing sequence
  36240. * @param rootUrl Defines the root url of the data
  36241. */
  36242. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36243. /**
  36244. * Gets the list of root nodes (ie. nodes with no parent)
  36245. */
  36246. rootNodes: Node[];
  36247. /** All of the cameras added to this scene
  36248. * @see http://doc.babylonjs.com/babylon101/cameras
  36249. */
  36250. cameras: Camera[];
  36251. /**
  36252. * All of the lights added to this scene
  36253. * @see http://doc.babylonjs.com/babylon101/lights
  36254. */
  36255. lights: Light[];
  36256. /**
  36257. * All of the (abstract) meshes added to this scene
  36258. */
  36259. meshes: AbstractMesh[];
  36260. /**
  36261. * The list of skeletons added to the scene
  36262. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36263. */
  36264. skeletons: Skeleton[];
  36265. /**
  36266. * All of the particle systems added to this scene
  36267. * @see http://doc.babylonjs.com/babylon101/particles
  36268. */
  36269. particleSystems: IParticleSystem[];
  36270. /**
  36271. * Gets a list of Animations associated with the scene
  36272. */
  36273. animations: Animation[];
  36274. /**
  36275. * All of the animation groups added to this scene
  36276. * @see http://doc.babylonjs.com/how_to/group
  36277. */
  36278. animationGroups: AnimationGroup[];
  36279. /**
  36280. * All of the multi-materials added to this scene
  36281. * @see http://doc.babylonjs.com/how_to/multi_materials
  36282. */
  36283. multiMaterials: MultiMaterial[];
  36284. /**
  36285. * All of the materials added to this scene
  36286. * In the context of a Scene, it is not supposed to be modified manually.
  36287. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36288. * Note also that the order of the Material within the array is not significant and might change.
  36289. * @see http://doc.babylonjs.com/babylon101/materials
  36290. */
  36291. materials: Material[];
  36292. /**
  36293. * The list of morph target managers added to the scene
  36294. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36295. */
  36296. morphTargetManagers: MorphTargetManager[];
  36297. /**
  36298. * The list of geometries used in the scene.
  36299. */
  36300. geometries: Geometry[];
  36301. /**
  36302. * All of the tranform nodes added to this scene
  36303. * In the context of a Scene, it is not supposed to be modified manually.
  36304. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36305. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36306. * @see http://doc.babylonjs.com/how_to/transformnode
  36307. */
  36308. transformNodes: TransformNode[];
  36309. /**
  36310. * ActionManagers available on the scene.
  36311. */
  36312. actionManagers: AbstractActionManager[];
  36313. /**
  36314. * Textures to keep.
  36315. */
  36316. textures: BaseTexture[];
  36317. /**
  36318. * Environment texture for the scene
  36319. */
  36320. environmentTexture: Nullable<BaseTexture>;
  36321. }
  36322. }
  36323. declare module "babylonjs/Audio/sound" {
  36324. import { Observable } from "babylonjs/Misc/observable";
  36325. import { Vector3 } from "babylonjs/Maths/math.vector";
  36326. import { Nullable } from "babylonjs/types";
  36327. import { Scene } from "babylonjs/scene";
  36328. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36329. /**
  36330. * Interface used to define options for Sound class
  36331. */
  36332. export interface ISoundOptions {
  36333. /**
  36334. * Does the sound autoplay once loaded.
  36335. */
  36336. autoplay?: boolean;
  36337. /**
  36338. * Does the sound loop after it finishes playing once.
  36339. */
  36340. loop?: boolean;
  36341. /**
  36342. * Sound's volume
  36343. */
  36344. volume?: number;
  36345. /**
  36346. * Is it a spatial sound?
  36347. */
  36348. spatialSound?: boolean;
  36349. /**
  36350. * Maximum distance to hear that sound
  36351. */
  36352. maxDistance?: number;
  36353. /**
  36354. * Uses user defined attenuation function
  36355. */
  36356. useCustomAttenuation?: boolean;
  36357. /**
  36358. * Define the roll off factor of spatial sounds.
  36359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36360. */
  36361. rolloffFactor?: number;
  36362. /**
  36363. * Define the reference distance the sound should be heard perfectly.
  36364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36365. */
  36366. refDistance?: number;
  36367. /**
  36368. * Define the distance attenuation model the sound will follow.
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36370. */
  36371. distanceModel?: string;
  36372. /**
  36373. * Defines the playback speed (1 by default)
  36374. */
  36375. playbackRate?: number;
  36376. /**
  36377. * Defines if the sound is from a streaming source
  36378. */
  36379. streaming?: boolean;
  36380. /**
  36381. * Defines an optional length (in seconds) inside the sound file
  36382. */
  36383. length?: number;
  36384. /**
  36385. * Defines an optional offset (in seconds) inside the sound file
  36386. */
  36387. offset?: number;
  36388. /**
  36389. * If true, URLs will not be required to state the audio file codec to use.
  36390. */
  36391. skipCodecCheck?: boolean;
  36392. }
  36393. /**
  36394. * Defines a sound that can be played in the application.
  36395. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36397. */
  36398. export class Sound {
  36399. /**
  36400. * The name of the sound in the scene.
  36401. */
  36402. name: string;
  36403. /**
  36404. * Does the sound autoplay once loaded.
  36405. */
  36406. autoplay: boolean;
  36407. /**
  36408. * Does the sound loop after it finishes playing once.
  36409. */
  36410. loop: boolean;
  36411. /**
  36412. * Does the sound use a custom attenuation curve to simulate the falloff
  36413. * happening when the source gets further away from the camera.
  36414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36415. */
  36416. useCustomAttenuation: boolean;
  36417. /**
  36418. * The sound track id this sound belongs to.
  36419. */
  36420. soundTrackId: number;
  36421. /**
  36422. * Is this sound currently played.
  36423. */
  36424. isPlaying: boolean;
  36425. /**
  36426. * Is this sound currently paused.
  36427. */
  36428. isPaused: boolean;
  36429. /**
  36430. * Does this sound enables spatial sound.
  36431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36432. */
  36433. spatialSound: boolean;
  36434. /**
  36435. * Define the reference distance the sound should be heard perfectly.
  36436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36437. */
  36438. refDistance: number;
  36439. /**
  36440. * Define the roll off factor of spatial sounds.
  36441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36442. */
  36443. rolloffFactor: number;
  36444. /**
  36445. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36447. */
  36448. maxDistance: number;
  36449. /**
  36450. * Define the distance attenuation model the sound will follow.
  36451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36452. */
  36453. distanceModel: string;
  36454. /**
  36455. * @hidden
  36456. * Back Compat
  36457. **/
  36458. onended: () => any;
  36459. /**
  36460. * Observable event when the current playing sound finishes.
  36461. */
  36462. onEndedObservable: Observable<Sound>;
  36463. private _panningModel;
  36464. private _playbackRate;
  36465. private _streaming;
  36466. private _startTime;
  36467. private _startOffset;
  36468. private _position;
  36469. /** @hidden */
  36470. _positionInEmitterSpace: boolean;
  36471. private _localDirection;
  36472. private _volume;
  36473. private _isReadyToPlay;
  36474. private _isDirectional;
  36475. private _readyToPlayCallback;
  36476. private _audioBuffer;
  36477. private _soundSource;
  36478. private _streamingSource;
  36479. private _soundPanner;
  36480. private _soundGain;
  36481. private _inputAudioNode;
  36482. private _outputAudioNode;
  36483. private _coneInnerAngle;
  36484. private _coneOuterAngle;
  36485. private _coneOuterGain;
  36486. private _scene;
  36487. private _connectedTransformNode;
  36488. private _customAttenuationFunction;
  36489. private _registerFunc;
  36490. private _isOutputConnected;
  36491. private _htmlAudioElement;
  36492. private _urlType;
  36493. private _length?;
  36494. private _offset?;
  36495. /** @hidden */
  36496. static _SceneComponentInitialization: (scene: Scene) => void;
  36497. /**
  36498. * Create a sound and attach it to a scene
  36499. * @param name Name of your sound
  36500. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36501. * @param scene defines the scene the sound belongs to
  36502. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36503. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36504. */
  36505. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36506. /**
  36507. * Release the sound and its associated resources
  36508. */
  36509. dispose(): void;
  36510. /**
  36511. * Gets if the sounds is ready to be played or not.
  36512. * @returns true if ready, otherwise false
  36513. */
  36514. isReady(): boolean;
  36515. private _soundLoaded;
  36516. /**
  36517. * Sets the data of the sound from an audiobuffer
  36518. * @param audioBuffer The audioBuffer containing the data
  36519. */
  36520. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36521. /**
  36522. * Updates the current sounds options such as maxdistance, loop...
  36523. * @param options A JSON object containing values named as the object properties
  36524. */
  36525. updateOptions(options: ISoundOptions): void;
  36526. private _createSpatialParameters;
  36527. private _updateSpatialParameters;
  36528. /**
  36529. * Switch the panning model to HRTF:
  36530. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36532. */
  36533. switchPanningModelToHRTF(): void;
  36534. /**
  36535. * Switch the panning model to Equal Power:
  36536. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36538. */
  36539. switchPanningModelToEqualPower(): void;
  36540. private _switchPanningModel;
  36541. /**
  36542. * Connect this sound to a sound track audio node like gain...
  36543. * @param soundTrackAudioNode the sound track audio node to connect to
  36544. */
  36545. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36546. /**
  36547. * Transform this sound into a directional source
  36548. * @param coneInnerAngle Size of the inner cone in degree
  36549. * @param coneOuterAngle Size of the outer cone in degree
  36550. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36551. */
  36552. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36553. /**
  36554. * Gets or sets the inner angle for the directional cone.
  36555. */
  36556. /**
  36557. * Gets or sets the inner angle for the directional cone.
  36558. */
  36559. directionalConeInnerAngle: number;
  36560. /**
  36561. * Gets or sets the outer angle for the directional cone.
  36562. */
  36563. /**
  36564. * Gets or sets the outer angle for the directional cone.
  36565. */
  36566. directionalConeOuterAngle: number;
  36567. /**
  36568. * Sets the position of the emitter if spatial sound is enabled
  36569. * @param newPosition Defines the new posisiton
  36570. */
  36571. setPosition(newPosition: Vector3): void;
  36572. /**
  36573. * Sets the local direction of the emitter if spatial sound is enabled
  36574. * @param newLocalDirection Defines the new local direction
  36575. */
  36576. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36577. private _updateDirection;
  36578. /** @hidden */
  36579. updateDistanceFromListener(): void;
  36580. /**
  36581. * Sets a new custom attenuation function for the sound.
  36582. * @param callback Defines the function used for the attenuation
  36583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36584. */
  36585. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36586. /**
  36587. * Play the sound
  36588. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36589. * @param offset (optional) Start the sound at a specific time in seconds
  36590. * @param length (optional) Sound duration (in seconds)
  36591. */
  36592. play(time?: number, offset?: number, length?: number): void;
  36593. private _onended;
  36594. /**
  36595. * Stop the sound
  36596. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36597. */
  36598. stop(time?: number): void;
  36599. /**
  36600. * Put the sound in pause
  36601. */
  36602. pause(): void;
  36603. /**
  36604. * Sets a dedicated volume for this sounds
  36605. * @param newVolume Define the new volume of the sound
  36606. * @param time Define time for gradual change to new volume
  36607. */
  36608. setVolume(newVolume: number, time?: number): void;
  36609. /**
  36610. * Set the sound play back rate
  36611. * @param newPlaybackRate Define the playback rate the sound should be played at
  36612. */
  36613. setPlaybackRate(newPlaybackRate: number): void;
  36614. /**
  36615. * Gets the volume of the sound.
  36616. * @returns the volume of the sound
  36617. */
  36618. getVolume(): number;
  36619. /**
  36620. * Attach the sound to a dedicated mesh
  36621. * @param transformNode The transform node to connect the sound with
  36622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36623. */
  36624. attachToMesh(transformNode: TransformNode): void;
  36625. /**
  36626. * Detach the sound from the previously attached mesh
  36627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36628. */
  36629. detachFromMesh(): void;
  36630. private _onRegisterAfterWorldMatrixUpdate;
  36631. /**
  36632. * Clone the current sound in the scene.
  36633. * @returns the new sound clone
  36634. */
  36635. clone(): Nullable<Sound>;
  36636. /**
  36637. * Gets the current underlying audio buffer containing the data
  36638. * @returns the audio buffer
  36639. */
  36640. getAudioBuffer(): Nullable<AudioBuffer>;
  36641. /**
  36642. * Serializes the Sound in a JSON representation
  36643. * @returns the JSON representation of the sound
  36644. */
  36645. serialize(): any;
  36646. /**
  36647. * Parse a JSON representation of a sound to innstantiate in a given scene
  36648. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36649. * @param scene Define the scene the new parsed sound should be created in
  36650. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36651. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36652. * @returns the newly parsed sound
  36653. */
  36654. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36655. }
  36656. }
  36657. declare module "babylonjs/Actions/directAudioActions" {
  36658. import { Action } from "babylonjs/Actions/action";
  36659. import { Condition } from "babylonjs/Actions/condition";
  36660. import { Sound } from "babylonjs/Audio/sound";
  36661. /**
  36662. * This defines an action helpful to play a defined sound on a triggered action.
  36663. */
  36664. export class PlaySoundAction extends Action {
  36665. private _sound;
  36666. /**
  36667. * Instantiate the action
  36668. * @param triggerOptions defines the trigger options
  36669. * @param sound defines the sound to play
  36670. * @param condition defines the trigger related conditions
  36671. */
  36672. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36673. /** @hidden */
  36674. _prepare(): void;
  36675. /**
  36676. * Execute the action and play the sound.
  36677. */
  36678. execute(): void;
  36679. /**
  36680. * Serializes the actions and its related information.
  36681. * @param parent defines the object to serialize in
  36682. * @returns the serialized object
  36683. */
  36684. serialize(parent: any): any;
  36685. }
  36686. /**
  36687. * This defines an action helpful to stop a defined sound on a triggered action.
  36688. */
  36689. export class StopSoundAction extends Action {
  36690. private _sound;
  36691. /**
  36692. * Instantiate the action
  36693. * @param triggerOptions defines the trigger options
  36694. * @param sound defines the sound to stop
  36695. * @param condition defines the trigger related conditions
  36696. */
  36697. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36698. /** @hidden */
  36699. _prepare(): void;
  36700. /**
  36701. * Execute the action and stop the sound.
  36702. */
  36703. execute(): void;
  36704. /**
  36705. * Serializes the actions and its related information.
  36706. * @param parent defines the object to serialize in
  36707. * @returns the serialized object
  36708. */
  36709. serialize(parent: any): any;
  36710. }
  36711. }
  36712. declare module "babylonjs/Actions/interpolateValueAction" {
  36713. import { Action } from "babylonjs/Actions/action";
  36714. import { Condition } from "babylonjs/Actions/condition";
  36715. import { Observable } from "babylonjs/Misc/observable";
  36716. /**
  36717. * This defines an action responsible to change the value of a property
  36718. * by interpolating between its current value and the newly set one once triggered.
  36719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36720. */
  36721. export class InterpolateValueAction extends Action {
  36722. /**
  36723. * Defines the path of the property where the value should be interpolated
  36724. */
  36725. propertyPath: string;
  36726. /**
  36727. * Defines the target value at the end of the interpolation.
  36728. */
  36729. value: any;
  36730. /**
  36731. * Defines the time it will take for the property to interpolate to the value.
  36732. */
  36733. duration: number;
  36734. /**
  36735. * Defines if the other scene animations should be stopped when the action has been triggered
  36736. */
  36737. stopOtherAnimations?: boolean;
  36738. /**
  36739. * Defines a callback raised once the interpolation animation has been done.
  36740. */
  36741. onInterpolationDone?: () => void;
  36742. /**
  36743. * Observable triggered once the interpolation animation has been done.
  36744. */
  36745. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36746. private _target;
  36747. private _effectiveTarget;
  36748. private _property;
  36749. /**
  36750. * Instantiate the action
  36751. * @param triggerOptions defines the trigger options
  36752. * @param target defines the object containing the value to interpolate
  36753. * @param propertyPath defines the path to the property in the target object
  36754. * @param value defines the target value at the end of the interpolation
  36755. * @param duration deines the time it will take for the property to interpolate to the value.
  36756. * @param condition defines the trigger related conditions
  36757. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36758. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36759. */
  36760. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36761. /** @hidden */
  36762. _prepare(): void;
  36763. /**
  36764. * Execute the action starts the value interpolation.
  36765. */
  36766. execute(): void;
  36767. /**
  36768. * Serializes the actions and its related information.
  36769. * @param parent defines the object to serialize in
  36770. * @returns the serialized object
  36771. */
  36772. serialize(parent: any): any;
  36773. }
  36774. }
  36775. declare module "babylonjs/Actions/index" {
  36776. export * from "babylonjs/Actions/abstractActionManager";
  36777. export * from "babylonjs/Actions/action";
  36778. export * from "babylonjs/Actions/actionEvent";
  36779. export * from "babylonjs/Actions/actionManager";
  36780. export * from "babylonjs/Actions/condition";
  36781. export * from "babylonjs/Actions/directActions";
  36782. export * from "babylonjs/Actions/directAudioActions";
  36783. export * from "babylonjs/Actions/interpolateValueAction";
  36784. }
  36785. declare module "babylonjs/Animations/index" {
  36786. export * from "babylonjs/Animations/animatable";
  36787. export * from "babylonjs/Animations/animation";
  36788. export * from "babylonjs/Animations/animationGroup";
  36789. export * from "babylonjs/Animations/animationPropertiesOverride";
  36790. export * from "babylonjs/Animations/easing";
  36791. export * from "babylonjs/Animations/runtimeAnimation";
  36792. export * from "babylonjs/Animations/animationEvent";
  36793. export * from "babylonjs/Animations/animationGroup";
  36794. export * from "babylonjs/Animations/animationKey";
  36795. export * from "babylonjs/Animations/animationRange";
  36796. export * from "babylonjs/Animations/animatable.interface";
  36797. }
  36798. declare module "babylonjs/Audio/soundTrack" {
  36799. import { Sound } from "babylonjs/Audio/sound";
  36800. import { Analyser } from "babylonjs/Audio/analyser";
  36801. import { Scene } from "babylonjs/scene";
  36802. /**
  36803. * Options allowed during the creation of a sound track.
  36804. */
  36805. export interface ISoundTrackOptions {
  36806. /**
  36807. * The volume the sound track should take during creation
  36808. */
  36809. volume?: number;
  36810. /**
  36811. * Define if the sound track is the main sound track of the scene
  36812. */
  36813. mainTrack?: boolean;
  36814. }
  36815. /**
  36816. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36817. * It will be also used in a future release to apply effects on a specific track.
  36818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36819. */
  36820. export class SoundTrack {
  36821. /**
  36822. * The unique identifier of the sound track in the scene.
  36823. */
  36824. id: number;
  36825. /**
  36826. * The list of sounds included in the sound track.
  36827. */
  36828. soundCollection: Array<Sound>;
  36829. private _outputAudioNode;
  36830. private _scene;
  36831. private _isMainTrack;
  36832. private _connectedAnalyser;
  36833. private _options;
  36834. private _isInitialized;
  36835. /**
  36836. * Creates a new sound track.
  36837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36838. * @param scene Define the scene the sound track belongs to
  36839. * @param options
  36840. */
  36841. constructor(scene: Scene, options?: ISoundTrackOptions);
  36842. private _initializeSoundTrackAudioGraph;
  36843. /**
  36844. * Release the sound track and its associated resources
  36845. */
  36846. dispose(): void;
  36847. /**
  36848. * Adds a sound to this sound track
  36849. * @param sound define the cound to add
  36850. * @ignoreNaming
  36851. */
  36852. AddSound(sound: Sound): void;
  36853. /**
  36854. * Removes a sound to this sound track
  36855. * @param sound define the cound to remove
  36856. * @ignoreNaming
  36857. */
  36858. RemoveSound(sound: Sound): void;
  36859. /**
  36860. * Set a global volume for the full sound track.
  36861. * @param newVolume Define the new volume of the sound track
  36862. */
  36863. setVolume(newVolume: number): void;
  36864. /**
  36865. * Switch the panning model to HRTF:
  36866. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36868. */
  36869. switchPanningModelToHRTF(): void;
  36870. /**
  36871. * Switch the panning model to Equal Power:
  36872. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36874. */
  36875. switchPanningModelToEqualPower(): void;
  36876. /**
  36877. * Connect the sound track to an audio analyser allowing some amazing
  36878. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36880. * @param analyser The analyser to connect to the engine
  36881. */
  36882. connectToAnalyser(analyser: Analyser): void;
  36883. }
  36884. }
  36885. declare module "babylonjs/Audio/audioSceneComponent" {
  36886. import { Sound } from "babylonjs/Audio/sound";
  36887. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36888. import { Nullable } from "babylonjs/types";
  36889. import { Vector3 } from "babylonjs/Maths/math.vector";
  36890. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36891. import { Scene } from "babylonjs/scene";
  36892. import { AbstractScene } from "babylonjs/abstractScene";
  36893. import "babylonjs/Audio/audioEngine";
  36894. module "babylonjs/abstractScene" {
  36895. interface AbstractScene {
  36896. /**
  36897. * The list of sounds used in the scene.
  36898. */
  36899. sounds: Nullable<Array<Sound>>;
  36900. }
  36901. }
  36902. module "babylonjs/scene" {
  36903. interface Scene {
  36904. /**
  36905. * @hidden
  36906. * Backing field
  36907. */
  36908. _mainSoundTrack: SoundTrack;
  36909. /**
  36910. * The main sound track played by the scene.
  36911. * It cotains your primary collection of sounds.
  36912. */
  36913. mainSoundTrack: SoundTrack;
  36914. /**
  36915. * The list of sound tracks added to the scene
  36916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36917. */
  36918. soundTracks: Nullable<Array<SoundTrack>>;
  36919. /**
  36920. * Gets a sound using a given name
  36921. * @param name defines the name to search for
  36922. * @return the found sound or null if not found at all.
  36923. */
  36924. getSoundByName(name: string): Nullable<Sound>;
  36925. /**
  36926. * Gets or sets if audio support is enabled
  36927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36928. */
  36929. audioEnabled: boolean;
  36930. /**
  36931. * Gets or sets if audio will be output to headphones
  36932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36933. */
  36934. headphone: boolean;
  36935. /**
  36936. * Gets or sets custom audio listener position provider
  36937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36938. */
  36939. audioListenerPositionProvider: Nullable<() => Vector3>;
  36940. /**
  36941. * Gets or sets a refresh rate when using 3D audio positioning
  36942. */
  36943. audioPositioningRefreshRate: number;
  36944. }
  36945. }
  36946. /**
  36947. * Defines the sound scene component responsible to manage any sounds
  36948. * in a given scene.
  36949. */
  36950. export class AudioSceneComponent implements ISceneSerializableComponent {
  36951. /**
  36952. * The component name helpfull to identify the component in the list of scene components.
  36953. */
  36954. readonly name: string;
  36955. /**
  36956. * The scene the component belongs to.
  36957. */
  36958. scene: Scene;
  36959. private _audioEnabled;
  36960. /**
  36961. * Gets whether audio is enabled or not.
  36962. * Please use related enable/disable method to switch state.
  36963. */
  36964. readonly audioEnabled: boolean;
  36965. private _headphone;
  36966. /**
  36967. * Gets whether audio is outputing to headphone or not.
  36968. * Please use the according Switch methods to change output.
  36969. */
  36970. readonly headphone: boolean;
  36971. /**
  36972. * Gets or sets a refresh rate when using 3D audio positioning
  36973. */
  36974. audioPositioningRefreshRate: number;
  36975. private _audioListenerPositionProvider;
  36976. /**
  36977. * Gets the current audio listener position provider
  36978. */
  36979. /**
  36980. * Sets a custom listener position for all sounds in the scene
  36981. * By default, this is the position of the first active camera
  36982. */
  36983. audioListenerPositionProvider: Nullable<() => Vector3>;
  36984. /**
  36985. * Creates a new instance of the component for the given scene
  36986. * @param scene Defines the scene to register the component in
  36987. */
  36988. constructor(scene: Scene);
  36989. /**
  36990. * Registers the component in a given scene
  36991. */
  36992. register(): void;
  36993. /**
  36994. * Rebuilds the elements related to this component in case of
  36995. * context lost for instance.
  36996. */
  36997. rebuild(): void;
  36998. /**
  36999. * Serializes the component data to the specified json object
  37000. * @param serializationObject The object to serialize to
  37001. */
  37002. serialize(serializationObject: any): void;
  37003. /**
  37004. * Adds all the elements from the container to the scene
  37005. * @param container the container holding the elements
  37006. */
  37007. addFromContainer(container: AbstractScene): void;
  37008. /**
  37009. * Removes all the elements in the container from the scene
  37010. * @param container contains the elements to remove
  37011. * @param dispose if the removed element should be disposed (default: false)
  37012. */
  37013. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37014. /**
  37015. * Disposes the component and the associated ressources.
  37016. */
  37017. dispose(): void;
  37018. /**
  37019. * Disables audio in the associated scene.
  37020. */
  37021. disableAudio(): void;
  37022. /**
  37023. * Enables audio in the associated scene.
  37024. */
  37025. enableAudio(): void;
  37026. /**
  37027. * Switch audio to headphone output.
  37028. */
  37029. switchAudioModeForHeadphones(): void;
  37030. /**
  37031. * Switch audio to normal speakers.
  37032. */
  37033. switchAudioModeForNormalSpeakers(): void;
  37034. private _cachedCameraDirection;
  37035. private _cachedCameraPosition;
  37036. private _lastCheck;
  37037. private _afterRender;
  37038. }
  37039. }
  37040. declare module "babylonjs/Audio/weightedsound" {
  37041. import { Sound } from "babylonjs/Audio/sound";
  37042. /**
  37043. * Wraps one or more Sound objects and selects one with random weight for playback.
  37044. */
  37045. export class WeightedSound {
  37046. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37047. loop: boolean;
  37048. private _coneInnerAngle;
  37049. private _coneOuterAngle;
  37050. private _volume;
  37051. /** A Sound is currently playing. */
  37052. isPlaying: boolean;
  37053. /** A Sound is currently paused. */
  37054. isPaused: boolean;
  37055. private _sounds;
  37056. private _weights;
  37057. private _currentIndex?;
  37058. /**
  37059. * Creates a new WeightedSound from the list of sounds given.
  37060. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37061. * @param sounds Array of Sounds that will be selected from.
  37062. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37063. */
  37064. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37065. /**
  37066. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37067. */
  37068. /**
  37069. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37070. */
  37071. directionalConeInnerAngle: number;
  37072. /**
  37073. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37074. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37075. */
  37076. /**
  37077. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37078. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37079. */
  37080. directionalConeOuterAngle: number;
  37081. /**
  37082. * Playback volume.
  37083. */
  37084. /**
  37085. * Playback volume.
  37086. */
  37087. volume: number;
  37088. private _onended;
  37089. /**
  37090. * Suspend playback
  37091. */
  37092. pause(): void;
  37093. /**
  37094. * Stop playback
  37095. */
  37096. stop(): void;
  37097. /**
  37098. * Start playback.
  37099. * @param startOffset Position the clip head at a specific time in seconds.
  37100. */
  37101. play(startOffset?: number): void;
  37102. }
  37103. }
  37104. declare module "babylonjs/Audio/index" {
  37105. export * from "babylonjs/Audio/analyser";
  37106. export * from "babylonjs/Audio/audioEngine";
  37107. export * from "babylonjs/Audio/audioSceneComponent";
  37108. export * from "babylonjs/Audio/sound";
  37109. export * from "babylonjs/Audio/soundTrack";
  37110. export * from "babylonjs/Audio/weightedsound";
  37111. }
  37112. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37113. import { Behavior } from "babylonjs/Behaviors/behavior";
  37114. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37115. import { BackEase } from "babylonjs/Animations/easing";
  37116. /**
  37117. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37119. */
  37120. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37121. /**
  37122. * Gets the name of the behavior.
  37123. */
  37124. readonly name: string;
  37125. /**
  37126. * The easing function used by animations
  37127. */
  37128. static EasingFunction: BackEase;
  37129. /**
  37130. * The easing mode used by animations
  37131. */
  37132. static EasingMode: number;
  37133. /**
  37134. * The duration of the animation, in milliseconds
  37135. */
  37136. transitionDuration: number;
  37137. /**
  37138. * Length of the distance animated by the transition when lower radius is reached
  37139. */
  37140. lowerRadiusTransitionRange: number;
  37141. /**
  37142. * Length of the distance animated by the transition when upper radius is reached
  37143. */
  37144. upperRadiusTransitionRange: number;
  37145. private _autoTransitionRange;
  37146. /**
  37147. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37148. */
  37149. /**
  37150. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37151. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37152. */
  37153. autoTransitionRange: boolean;
  37154. private _attachedCamera;
  37155. private _onAfterCheckInputsObserver;
  37156. private _onMeshTargetChangedObserver;
  37157. /**
  37158. * Initializes the behavior.
  37159. */
  37160. init(): void;
  37161. /**
  37162. * Attaches the behavior to its arc rotate camera.
  37163. * @param camera Defines the camera to attach the behavior to
  37164. */
  37165. attach(camera: ArcRotateCamera): void;
  37166. /**
  37167. * Detaches the behavior from its current arc rotate camera.
  37168. */
  37169. detach(): void;
  37170. private _radiusIsAnimating;
  37171. private _radiusBounceTransition;
  37172. private _animatables;
  37173. private _cachedWheelPrecision;
  37174. /**
  37175. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37176. * @param radiusLimit The limit to check against.
  37177. * @return Bool to indicate if at limit.
  37178. */
  37179. private _isRadiusAtLimit;
  37180. /**
  37181. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37182. * @param radiusDelta The delta by which to animate to. Can be negative.
  37183. */
  37184. private _applyBoundRadiusAnimation;
  37185. /**
  37186. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37187. */
  37188. protected _clearAnimationLocks(): void;
  37189. /**
  37190. * Stops and removes all animations that have been applied to the camera
  37191. */
  37192. stopAllAnimations(): void;
  37193. }
  37194. }
  37195. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37196. import { Behavior } from "babylonjs/Behaviors/behavior";
  37197. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37198. import { ExponentialEase } from "babylonjs/Animations/easing";
  37199. import { Nullable } from "babylonjs/types";
  37200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37201. import { Vector3 } from "babylonjs/Maths/math.vector";
  37202. /**
  37203. * 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.
  37204. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37205. */
  37206. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37207. /**
  37208. * Gets the name of the behavior.
  37209. */
  37210. readonly name: string;
  37211. private _mode;
  37212. private _radiusScale;
  37213. private _positionScale;
  37214. private _defaultElevation;
  37215. private _elevationReturnTime;
  37216. private _elevationReturnWaitTime;
  37217. private _zoomStopsAnimation;
  37218. private _framingTime;
  37219. /**
  37220. * The easing function used by animations
  37221. */
  37222. static EasingFunction: ExponentialEase;
  37223. /**
  37224. * The easing mode used by animations
  37225. */
  37226. static EasingMode: number;
  37227. /**
  37228. * Sets the current mode used by the behavior
  37229. */
  37230. /**
  37231. * Gets current mode used by the behavior.
  37232. */
  37233. mode: number;
  37234. /**
  37235. * Sets the scale applied to the radius (1 by default)
  37236. */
  37237. /**
  37238. * Gets the scale applied to the radius
  37239. */
  37240. radiusScale: number;
  37241. /**
  37242. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37243. */
  37244. /**
  37245. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37246. */
  37247. positionScale: number;
  37248. /**
  37249. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37250. * behaviour is triggered, in radians.
  37251. */
  37252. /**
  37253. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37254. * behaviour is triggered, in radians.
  37255. */
  37256. defaultElevation: number;
  37257. /**
  37258. * Sets the time (in milliseconds) taken to return to the default beta position.
  37259. * Negative value indicates camera should not return to default.
  37260. */
  37261. /**
  37262. * Gets the time (in milliseconds) taken to return to the default beta position.
  37263. * Negative value indicates camera should not return to default.
  37264. */
  37265. elevationReturnTime: number;
  37266. /**
  37267. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37268. */
  37269. /**
  37270. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37271. */
  37272. elevationReturnWaitTime: number;
  37273. /**
  37274. * Sets the flag that indicates if user zooming should stop animation.
  37275. */
  37276. /**
  37277. * Gets the flag that indicates if user zooming should stop animation.
  37278. */
  37279. zoomStopsAnimation: boolean;
  37280. /**
  37281. * Sets the transition time when framing the mesh, in milliseconds
  37282. */
  37283. /**
  37284. * Gets the transition time when framing the mesh, in milliseconds
  37285. */
  37286. framingTime: number;
  37287. /**
  37288. * Define if the behavior should automatically change the configured
  37289. * camera limits and sensibilities.
  37290. */
  37291. autoCorrectCameraLimitsAndSensibility: boolean;
  37292. private _onPrePointerObservableObserver;
  37293. private _onAfterCheckInputsObserver;
  37294. private _onMeshTargetChangedObserver;
  37295. private _attachedCamera;
  37296. private _isPointerDown;
  37297. private _lastInteractionTime;
  37298. /**
  37299. * Initializes the behavior.
  37300. */
  37301. init(): void;
  37302. /**
  37303. * Attaches the behavior to its arc rotate camera.
  37304. * @param camera Defines the camera to attach the behavior to
  37305. */
  37306. attach(camera: ArcRotateCamera): void;
  37307. /**
  37308. * Detaches the behavior from its current arc rotate camera.
  37309. */
  37310. detach(): void;
  37311. private _animatables;
  37312. private _betaIsAnimating;
  37313. private _betaTransition;
  37314. private _radiusTransition;
  37315. private _vectorTransition;
  37316. /**
  37317. * Targets the given mesh and updates zoom level accordingly.
  37318. * @param mesh The mesh to target.
  37319. * @param radius Optional. If a cached radius position already exists, overrides default.
  37320. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37321. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37322. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37323. */
  37324. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37325. /**
  37326. * Targets the given mesh with its children and updates zoom level accordingly.
  37327. * @param mesh The mesh to target.
  37328. * @param radius Optional. If a cached radius position already exists, overrides default.
  37329. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37330. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37331. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37332. */
  37333. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37334. /**
  37335. * Targets the given meshes with their children and updates zoom level accordingly.
  37336. * @param meshes The mesh to target.
  37337. * @param radius Optional. If a cached radius position already exists, overrides default.
  37338. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37339. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37340. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37341. */
  37342. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37343. /**
  37344. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37345. * @param minimumWorld Determines the smaller position of the bounding box extend
  37346. * @param maximumWorld Determines the bigger position of the bounding box extend
  37347. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37348. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37349. */
  37350. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37351. /**
  37352. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37353. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37354. * frustum width.
  37355. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37356. * to fully enclose the mesh in the viewing frustum.
  37357. */
  37358. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37359. /**
  37360. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37361. * is automatically returned to its default position (expected to be above ground plane).
  37362. */
  37363. private _maintainCameraAboveGround;
  37364. /**
  37365. * Returns the frustum slope based on the canvas ratio and camera FOV
  37366. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37367. */
  37368. private _getFrustumSlope;
  37369. /**
  37370. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37371. */
  37372. private _clearAnimationLocks;
  37373. /**
  37374. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37375. */
  37376. private _applyUserInteraction;
  37377. /**
  37378. * Stops and removes all animations that have been applied to the camera
  37379. */
  37380. stopAllAnimations(): void;
  37381. /**
  37382. * Gets a value indicating if the user is moving the camera
  37383. */
  37384. readonly isUserIsMoving: boolean;
  37385. /**
  37386. * The camera can move all the way towards the mesh.
  37387. */
  37388. static IgnoreBoundsSizeMode: number;
  37389. /**
  37390. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37391. */
  37392. static FitFrustumSidesMode: number;
  37393. }
  37394. }
  37395. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37396. import { Nullable } from "babylonjs/types";
  37397. import { Camera } from "babylonjs/Cameras/camera";
  37398. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37399. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37400. /**
  37401. * Base class for Camera Pointer Inputs.
  37402. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37403. * for example usage.
  37404. */
  37405. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37406. /**
  37407. * Defines the camera the input is attached to.
  37408. */
  37409. abstract camera: Camera;
  37410. /**
  37411. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37412. */
  37413. protected _altKey: boolean;
  37414. protected _ctrlKey: boolean;
  37415. protected _metaKey: boolean;
  37416. protected _shiftKey: boolean;
  37417. /**
  37418. * Which mouse buttons were pressed at time of last mouse event.
  37419. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37420. */
  37421. protected _buttonsPressed: number;
  37422. /**
  37423. * Defines the buttons associated with the input to handle camera move.
  37424. */
  37425. buttons: number[];
  37426. /**
  37427. * Attach the input controls to a specific dom element to get the input from.
  37428. * @param element Defines the element the controls should be listened from
  37429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37430. */
  37431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37432. /**
  37433. * Detach the current controls from the specified dom element.
  37434. * @param element Defines the element to stop listening the inputs from
  37435. */
  37436. detachControl(element: Nullable<HTMLElement>): void;
  37437. /**
  37438. * Gets the class name of the current input.
  37439. * @returns the class name
  37440. */
  37441. getClassName(): string;
  37442. /**
  37443. * Get the friendly name associated with the input class.
  37444. * @returns the input friendly name
  37445. */
  37446. getSimpleName(): string;
  37447. /**
  37448. * Called on pointer POINTERDOUBLETAP event.
  37449. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37450. */
  37451. protected onDoubleTap(type: string): void;
  37452. /**
  37453. * Called on pointer POINTERMOVE event if only a single touch is active.
  37454. * Override this method to provide functionality.
  37455. */
  37456. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37457. /**
  37458. * Called on pointer POINTERMOVE event if multiple touches are active.
  37459. * Override this method to provide functionality.
  37460. */
  37461. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37462. /**
  37463. * Called on JS contextmenu event.
  37464. * Override this method to provide functionality.
  37465. */
  37466. protected onContextMenu(evt: PointerEvent): void;
  37467. /**
  37468. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37469. * press.
  37470. * Override this method to provide functionality.
  37471. */
  37472. protected onButtonDown(evt: PointerEvent): void;
  37473. /**
  37474. * Called each time a new POINTERUP event occurs. Ie, for each button
  37475. * release.
  37476. * Override this method to provide functionality.
  37477. */
  37478. protected onButtonUp(evt: PointerEvent): void;
  37479. /**
  37480. * Called when window becomes inactive.
  37481. * Override this method to provide functionality.
  37482. */
  37483. protected onLostFocus(): void;
  37484. private _pointerInput;
  37485. private _observer;
  37486. private _onLostFocus;
  37487. private pointA;
  37488. private pointB;
  37489. }
  37490. }
  37491. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37492. import { Nullable } from "babylonjs/types";
  37493. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37494. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37495. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37496. /**
  37497. * Manage the pointers inputs to control an arc rotate camera.
  37498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37499. */
  37500. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37501. /**
  37502. * Defines the camera the input is attached to.
  37503. */
  37504. camera: ArcRotateCamera;
  37505. /**
  37506. * Gets the class name of the current input.
  37507. * @returns the class name
  37508. */
  37509. getClassName(): string;
  37510. /**
  37511. * Defines the buttons associated with the input to handle camera move.
  37512. */
  37513. buttons: number[];
  37514. /**
  37515. * Defines the pointer angular sensibility along the X axis or how fast is
  37516. * the camera rotating.
  37517. */
  37518. angularSensibilityX: number;
  37519. /**
  37520. * Defines the pointer angular sensibility along the Y axis or how fast is
  37521. * the camera rotating.
  37522. */
  37523. angularSensibilityY: number;
  37524. /**
  37525. * Defines the pointer pinch precision or how fast is the camera zooming.
  37526. */
  37527. pinchPrecision: number;
  37528. /**
  37529. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37530. * from 0.
  37531. * It defines the percentage of current camera.radius to use as delta when
  37532. * pinch zoom is used.
  37533. */
  37534. pinchDeltaPercentage: number;
  37535. /**
  37536. * Defines the pointer panning sensibility or how fast is the camera moving.
  37537. */
  37538. panningSensibility: number;
  37539. /**
  37540. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37541. */
  37542. multiTouchPanning: boolean;
  37543. /**
  37544. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37545. * zoom (pinch) through multitouch.
  37546. */
  37547. multiTouchPanAndZoom: boolean;
  37548. /**
  37549. * Revers pinch action direction.
  37550. */
  37551. pinchInwards: boolean;
  37552. private _isPanClick;
  37553. private _twoFingerActivityCount;
  37554. private _isPinching;
  37555. /**
  37556. * Called on pointer POINTERMOVE event if only a single touch is active.
  37557. */
  37558. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37559. /**
  37560. * Called on pointer POINTERDOUBLETAP event.
  37561. */
  37562. protected onDoubleTap(type: string): void;
  37563. /**
  37564. * Called on pointer POINTERMOVE event if multiple touches are active.
  37565. */
  37566. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37567. /**
  37568. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37569. * press.
  37570. */
  37571. protected onButtonDown(evt: PointerEvent): void;
  37572. /**
  37573. * Called each time a new POINTERUP event occurs. Ie, for each button
  37574. * release.
  37575. */
  37576. protected onButtonUp(evt: PointerEvent): void;
  37577. /**
  37578. * Called when window becomes inactive.
  37579. */
  37580. protected onLostFocus(): void;
  37581. }
  37582. }
  37583. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37584. import { Nullable } from "babylonjs/types";
  37585. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37587. /**
  37588. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37590. */
  37591. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37592. /**
  37593. * Defines the camera the input is attached to.
  37594. */
  37595. camera: ArcRotateCamera;
  37596. /**
  37597. * Defines the list of key codes associated with the up action (increase alpha)
  37598. */
  37599. keysUp: number[];
  37600. /**
  37601. * Defines the list of key codes associated with the down action (decrease alpha)
  37602. */
  37603. keysDown: number[];
  37604. /**
  37605. * Defines the list of key codes associated with the left action (increase beta)
  37606. */
  37607. keysLeft: number[];
  37608. /**
  37609. * Defines the list of key codes associated with the right action (decrease beta)
  37610. */
  37611. keysRight: number[];
  37612. /**
  37613. * Defines the list of key codes associated with the reset action.
  37614. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37615. */
  37616. keysReset: number[];
  37617. /**
  37618. * Defines the panning sensibility of the inputs.
  37619. * (How fast is the camera paning)
  37620. */
  37621. panningSensibility: number;
  37622. /**
  37623. * Defines the zooming sensibility of the inputs.
  37624. * (How fast is the camera zooming)
  37625. */
  37626. zoomingSensibility: number;
  37627. /**
  37628. * Defines wether maintaining the alt key down switch the movement mode from
  37629. * orientation to zoom.
  37630. */
  37631. useAltToZoom: boolean;
  37632. /**
  37633. * Rotation speed of the camera
  37634. */
  37635. angularSpeed: number;
  37636. private _keys;
  37637. private _ctrlPressed;
  37638. private _altPressed;
  37639. private _onCanvasBlurObserver;
  37640. private _onKeyboardObserver;
  37641. private _engine;
  37642. private _scene;
  37643. /**
  37644. * Attach the input controls to a specific dom element to get the input from.
  37645. * @param element Defines the element the controls should be listened from
  37646. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37647. */
  37648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37649. /**
  37650. * Detach the current controls from the specified dom element.
  37651. * @param element Defines the element to stop listening the inputs from
  37652. */
  37653. detachControl(element: Nullable<HTMLElement>): void;
  37654. /**
  37655. * Update the current camera state depending on the inputs that have been used this frame.
  37656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37657. */
  37658. checkInputs(): void;
  37659. /**
  37660. * Gets the class name of the current intput.
  37661. * @returns the class name
  37662. */
  37663. getClassName(): string;
  37664. /**
  37665. * Get the friendly name associated with the input class.
  37666. * @returns the input friendly name
  37667. */
  37668. getSimpleName(): string;
  37669. }
  37670. }
  37671. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37672. import { Nullable } from "babylonjs/types";
  37673. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37674. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37675. /**
  37676. * Manage the mouse wheel inputs to control an arc rotate camera.
  37677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37678. */
  37679. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37680. /**
  37681. * Defines the camera the input is attached to.
  37682. */
  37683. camera: ArcRotateCamera;
  37684. /**
  37685. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37686. */
  37687. wheelPrecision: number;
  37688. /**
  37689. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37690. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37691. */
  37692. wheelDeltaPercentage: number;
  37693. private _wheel;
  37694. private _observer;
  37695. private computeDeltaFromMouseWheelLegacyEvent;
  37696. /**
  37697. * Attach the input controls to a specific dom element to get the input from.
  37698. * @param element Defines the element the controls should be listened from
  37699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37700. */
  37701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37702. /**
  37703. * Detach the current controls from the specified dom element.
  37704. * @param element Defines the element to stop listening the inputs from
  37705. */
  37706. detachControl(element: Nullable<HTMLElement>): void;
  37707. /**
  37708. * Gets the class name of the current intput.
  37709. * @returns the class name
  37710. */
  37711. getClassName(): string;
  37712. /**
  37713. * Get the friendly name associated with the input class.
  37714. * @returns the input friendly name
  37715. */
  37716. getSimpleName(): string;
  37717. }
  37718. }
  37719. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37720. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37721. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37722. /**
  37723. * Default Inputs manager for the ArcRotateCamera.
  37724. * It groups all the default supported inputs for ease of use.
  37725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37726. */
  37727. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37728. /**
  37729. * Instantiates a new ArcRotateCameraInputsManager.
  37730. * @param camera Defines the camera the inputs belong to
  37731. */
  37732. constructor(camera: ArcRotateCamera);
  37733. /**
  37734. * Add mouse wheel input support to the input manager.
  37735. * @returns the current input manager
  37736. */
  37737. addMouseWheel(): ArcRotateCameraInputsManager;
  37738. /**
  37739. * Add pointers input support to the input manager.
  37740. * @returns the current input manager
  37741. */
  37742. addPointers(): ArcRotateCameraInputsManager;
  37743. /**
  37744. * Add keyboard input support to the input manager.
  37745. * @returns the current input manager
  37746. */
  37747. addKeyboard(): ArcRotateCameraInputsManager;
  37748. }
  37749. }
  37750. declare module "babylonjs/Cameras/arcRotateCamera" {
  37751. import { Observable } from "babylonjs/Misc/observable";
  37752. import { Nullable } from "babylonjs/types";
  37753. import { Scene } from "babylonjs/scene";
  37754. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37756. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37757. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37758. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37759. import { Camera } from "babylonjs/Cameras/camera";
  37760. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37761. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37762. import { Collider } from "babylonjs/Collisions/collider";
  37763. /**
  37764. * This represents an orbital type of camera.
  37765. *
  37766. * 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.
  37767. * 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.
  37768. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37769. */
  37770. export class ArcRotateCamera extends TargetCamera {
  37771. /**
  37772. * Defines the rotation angle of the camera along the longitudinal axis.
  37773. */
  37774. alpha: number;
  37775. /**
  37776. * Defines the rotation angle of the camera along the latitudinal axis.
  37777. */
  37778. beta: number;
  37779. /**
  37780. * Defines the radius of the camera from it s target point.
  37781. */
  37782. radius: number;
  37783. protected _target: Vector3;
  37784. protected _targetHost: Nullable<AbstractMesh>;
  37785. /**
  37786. * Defines the target point of the camera.
  37787. * The camera looks towards it form the radius distance.
  37788. */
  37789. target: Vector3;
  37790. /**
  37791. * Define the current local position of the camera in the scene
  37792. */
  37793. position: Vector3;
  37794. protected _upVector: Vector3;
  37795. protected _upToYMatrix: Matrix;
  37796. protected _YToUpMatrix: Matrix;
  37797. /**
  37798. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37799. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37800. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37801. */
  37802. upVector: Vector3;
  37803. /**
  37804. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37805. */
  37806. setMatUp(): void;
  37807. /**
  37808. * Current inertia value on the longitudinal axis.
  37809. * The bigger this number the longer it will take for the camera to stop.
  37810. */
  37811. inertialAlphaOffset: number;
  37812. /**
  37813. * Current inertia value on the latitudinal axis.
  37814. * The bigger this number the longer it will take for the camera to stop.
  37815. */
  37816. inertialBetaOffset: number;
  37817. /**
  37818. * Current inertia value on the radius axis.
  37819. * The bigger this number the longer it will take for the camera to stop.
  37820. */
  37821. inertialRadiusOffset: number;
  37822. /**
  37823. * Minimum allowed angle on the longitudinal axis.
  37824. * This can help limiting how the Camera is able to move in the scene.
  37825. */
  37826. lowerAlphaLimit: Nullable<number>;
  37827. /**
  37828. * Maximum allowed angle on the longitudinal axis.
  37829. * This can help limiting how the Camera is able to move in the scene.
  37830. */
  37831. upperAlphaLimit: Nullable<number>;
  37832. /**
  37833. * Minimum allowed angle on the latitudinal axis.
  37834. * This can help limiting how the Camera is able to move in the scene.
  37835. */
  37836. lowerBetaLimit: number;
  37837. /**
  37838. * Maximum allowed angle on the latitudinal axis.
  37839. * This can help limiting how the Camera is able to move in the scene.
  37840. */
  37841. upperBetaLimit: number;
  37842. /**
  37843. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37844. * This can help limiting how the Camera is able to move in the scene.
  37845. */
  37846. lowerRadiusLimit: Nullable<number>;
  37847. /**
  37848. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37849. * This can help limiting how the Camera is able to move in the scene.
  37850. */
  37851. upperRadiusLimit: Nullable<number>;
  37852. /**
  37853. * Defines the current inertia value used during panning of the camera along the X axis.
  37854. */
  37855. inertialPanningX: number;
  37856. /**
  37857. * Defines the current inertia value used during panning of the camera along the Y axis.
  37858. */
  37859. inertialPanningY: number;
  37860. /**
  37861. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37862. * Basically if your fingers moves away from more than this distance you will be considered
  37863. * in pinch mode.
  37864. */
  37865. pinchToPanMaxDistance: number;
  37866. /**
  37867. * Defines the maximum distance the camera can pan.
  37868. * This could help keeping the cammera always in your scene.
  37869. */
  37870. panningDistanceLimit: Nullable<number>;
  37871. /**
  37872. * Defines the target of the camera before paning.
  37873. */
  37874. panningOriginTarget: Vector3;
  37875. /**
  37876. * Defines the value of the inertia used during panning.
  37877. * 0 would mean stop inertia and one would mean no decelleration at all.
  37878. */
  37879. panningInertia: number;
  37880. /**
  37881. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37882. */
  37883. angularSensibilityX: number;
  37884. /**
  37885. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37886. */
  37887. angularSensibilityY: number;
  37888. /**
  37889. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37890. */
  37891. pinchPrecision: number;
  37892. /**
  37893. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37894. * It will be used instead of pinchDeltaPrecision if different from 0.
  37895. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37896. */
  37897. pinchDeltaPercentage: number;
  37898. /**
  37899. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37900. */
  37901. panningSensibility: number;
  37902. /**
  37903. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37904. */
  37905. keysUp: number[];
  37906. /**
  37907. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37908. */
  37909. keysDown: number[];
  37910. /**
  37911. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37912. */
  37913. keysLeft: number[];
  37914. /**
  37915. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37916. */
  37917. keysRight: number[];
  37918. /**
  37919. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37920. */
  37921. wheelPrecision: number;
  37922. /**
  37923. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37924. * It will be used instead of pinchDeltaPrecision if different from 0.
  37925. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37926. */
  37927. wheelDeltaPercentage: number;
  37928. /**
  37929. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37930. */
  37931. zoomOnFactor: number;
  37932. /**
  37933. * Defines a screen offset for the camera position.
  37934. */
  37935. targetScreenOffset: Vector2;
  37936. /**
  37937. * Allows the camera to be completely reversed.
  37938. * If false the camera can not arrive upside down.
  37939. */
  37940. allowUpsideDown: boolean;
  37941. /**
  37942. * Define if double tap/click is used to restore the previously saved state of the camera.
  37943. */
  37944. useInputToRestoreState: boolean;
  37945. /** @hidden */
  37946. _viewMatrix: Matrix;
  37947. /** @hidden */
  37948. _useCtrlForPanning: boolean;
  37949. /** @hidden */
  37950. _panningMouseButton: number;
  37951. /**
  37952. * Defines the input associated to the camera.
  37953. */
  37954. inputs: ArcRotateCameraInputsManager;
  37955. /** @hidden */
  37956. _reset: () => void;
  37957. /**
  37958. * Defines the allowed panning axis.
  37959. */
  37960. panningAxis: Vector3;
  37961. protected _localDirection: Vector3;
  37962. protected _transformedDirection: Vector3;
  37963. private _bouncingBehavior;
  37964. /**
  37965. * Gets the bouncing behavior of the camera if it has been enabled.
  37966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37967. */
  37968. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37969. /**
  37970. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37972. */
  37973. useBouncingBehavior: boolean;
  37974. private _framingBehavior;
  37975. /**
  37976. * Gets the framing behavior of the camera if it has been enabled.
  37977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37978. */
  37979. readonly framingBehavior: Nullable<FramingBehavior>;
  37980. /**
  37981. * Defines if the framing behavior of the camera is enabled on the camera.
  37982. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37983. */
  37984. useFramingBehavior: boolean;
  37985. private _autoRotationBehavior;
  37986. /**
  37987. * Gets the auto rotation behavior of the camera if it has been enabled.
  37988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37989. */
  37990. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37991. /**
  37992. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37994. */
  37995. useAutoRotationBehavior: boolean;
  37996. /**
  37997. * Observable triggered when the mesh target has been changed on the camera.
  37998. */
  37999. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38000. /**
  38001. * Event raised when the camera is colliding with a mesh.
  38002. */
  38003. onCollide: (collidedMesh: AbstractMesh) => void;
  38004. /**
  38005. * Defines whether the camera should check collision with the objects oh the scene.
  38006. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38007. */
  38008. checkCollisions: boolean;
  38009. /**
  38010. * Defines the collision radius of the camera.
  38011. * This simulates a sphere around the camera.
  38012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38013. */
  38014. collisionRadius: Vector3;
  38015. protected _collider: Collider;
  38016. protected _previousPosition: Vector3;
  38017. protected _collisionVelocity: Vector3;
  38018. protected _newPosition: Vector3;
  38019. protected _previousAlpha: number;
  38020. protected _previousBeta: number;
  38021. protected _previousRadius: number;
  38022. protected _collisionTriggered: boolean;
  38023. protected _targetBoundingCenter: Nullable<Vector3>;
  38024. private _computationVector;
  38025. /**
  38026. * Instantiates a new ArcRotateCamera in a given scene
  38027. * @param name Defines the name of the camera
  38028. * @param alpha Defines the camera rotation along the logitudinal axis
  38029. * @param beta Defines the camera rotation along the latitudinal axis
  38030. * @param radius Defines the camera distance from its target
  38031. * @param target Defines the camera target
  38032. * @param scene Defines the scene the camera belongs to
  38033. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38034. */
  38035. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38036. /** @hidden */
  38037. _initCache(): void;
  38038. /** @hidden */
  38039. _updateCache(ignoreParentClass?: boolean): void;
  38040. protected _getTargetPosition(): Vector3;
  38041. private _storedAlpha;
  38042. private _storedBeta;
  38043. private _storedRadius;
  38044. private _storedTarget;
  38045. private _storedTargetScreenOffset;
  38046. /**
  38047. * Stores the current state of the camera (alpha, beta, radius and target)
  38048. * @returns the camera itself
  38049. */
  38050. storeState(): Camera;
  38051. /**
  38052. * @hidden
  38053. * Restored camera state. You must call storeState() first
  38054. */
  38055. _restoreStateValues(): boolean;
  38056. /** @hidden */
  38057. _isSynchronizedViewMatrix(): boolean;
  38058. /**
  38059. * Attached controls to the current camera.
  38060. * @param element Defines the element the controls should be listened from
  38061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38062. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38063. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38064. */
  38065. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38066. /**
  38067. * Detach the current controls from the camera.
  38068. * The camera will stop reacting to inputs.
  38069. * @param element Defines the element to stop listening the inputs from
  38070. */
  38071. detachControl(element: HTMLElement): void;
  38072. /** @hidden */
  38073. _checkInputs(): void;
  38074. protected _checkLimits(): void;
  38075. /**
  38076. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38077. */
  38078. rebuildAnglesAndRadius(): void;
  38079. /**
  38080. * Use a position to define the current camera related information like alpha, beta and radius
  38081. * @param position Defines the position to set the camera at
  38082. */
  38083. setPosition(position: Vector3): void;
  38084. /**
  38085. * Defines the target the camera should look at.
  38086. * This will automatically adapt alpha beta and radius to fit within the new target.
  38087. * @param target Defines the new target as a Vector or a mesh
  38088. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38089. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38090. */
  38091. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38092. /** @hidden */
  38093. _getViewMatrix(): Matrix;
  38094. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38095. /**
  38096. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38097. * @param meshes Defines the mesh to zoom on
  38098. * @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)
  38099. */
  38100. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38101. /**
  38102. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38103. * The target will be changed but the radius
  38104. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38105. * @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)
  38106. */
  38107. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38108. min: Vector3;
  38109. max: Vector3;
  38110. distance: number;
  38111. }, doNotUpdateMaxZ?: boolean): void;
  38112. /**
  38113. * @override
  38114. * Override Camera.createRigCamera
  38115. */
  38116. createRigCamera(name: string, cameraIndex: number): Camera;
  38117. /**
  38118. * @hidden
  38119. * @override
  38120. * Override Camera._updateRigCameras
  38121. */
  38122. _updateRigCameras(): void;
  38123. /**
  38124. * Destroy the camera and release the current resources hold by it.
  38125. */
  38126. dispose(): void;
  38127. /**
  38128. * Gets the current object class name.
  38129. * @return the class name
  38130. */
  38131. getClassName(): string;
  38132. }
  38133. }
  38134. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38135. import { Behavior } from "babylonjs/Behaviors/behavior";
  38136. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38137. /**
  38138. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38139. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38140. */
  38141. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38142. /**
  38143. * Gets the name of the behavior.
  38144. */
  38145. readonly name: string;
  38146. private _zoomStopsAnimation;
  38147. private _idleRotationSpeed;
  38148. private _idleRotationWaitTime;
  38149. private _idleRotationSpinupTime;
  38150. /**
  38151. * Sets the flag that indicates if user zooming should stop animation.
  38152. */
  38153. /**
  38154. * Gets the flag that indicates if user zooming should stop animation.
  38155. */
  38156. zoomStopsAnimation: boolean;
  38157. /**
  38158. * Sets the default speed at which the camera rotates around the model.
  38159. */
  38160. /**
  38161. * Gets the default speed at which the camera rotates around the model.
  38162. */
  38163. idleRotationSpeed: number;
  38164. /**
  38165. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38166. */
  38167. /**
  38168. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38169. */
  38170. idleRotationWaitTime: number;
  38171. /**
  38172. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38173. */
  38174. /**
  38175. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38176. */
  38177. idleRotationSpinupTime: number;
  38178. /**
  38179. * Gets a value indicating if the camera is currently rotating because of this behavior
  38180. */
  38181. readonly rotationInProgress: boolean;
  38182. private _onPrePointerObservableObserver;
  38183. private _onAfterCheckInputsObserver;
  38184. private _attachedCamera;
  38185. private _isPointerDown;
  38186. private _lastFrameTime;
  38187. private _lastInteractionTime;
  38188. private _cameraRotationSpeed;
  38189. /**
  38190. * Initializes the behavior.
  38191. */
  38192. init(): void;
  38193. /**
  38194. * Attaches the behavior to its arc rotate camera.
  38195. * @param camera Defines the camera to attach the behavior to
  38196. */
  38197. attach(camera: ArcRotateCamera): void;
  38198. /**
  38199. * Detaches the behavior from its current arc rotate camera.
  38200. */
  38201. detach(): void;
  38202. /**
  38203. * Returns true if user is scrolling.
  38204. * @return true if user is scrolling.
  38205. */
  38206. private _userIsZooming;
  38207. private _lastFrameRadius;
  38208. private _shouldAnimationStopForInteraction;
  38209. /**
  38210. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38211. */
  38212. private _applyUserInteraction;
  38213. private _userIsMoving;
  38214. }
  38215. }
  38216. declare module "babylonjs/Behaviors/Cameras/index" {
  38217. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38218. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38219. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38220. }
  38221. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38222. import { Mesh } from "babylonjs/Meshes/mesh";
  38223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38224. import { Behavior } from "babylonjs/Behaviors/behavior";
  38225. /**
  38226. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38227. */
  38228. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38229. private ui;
  38230. /**
  38231. * The name of the behavior
  38232. */
  38233. name: string;
  38234. /**
  38235. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38236. */
  38237. distanceAwayFromFace: number;
  38238. /**
  38239. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38240. */
  38241. distanceAwayFromBottomOfFace: number;
  38242. private _faceVectors;
  38243. private _target;
  38244. private _scene;
  38245. private _onRenderObserver;
  38246. private _tmpMatrix;
  38247. private _tmpVector;
  38248. /**
  38249. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38250. * @param ui The transform node that should be attched to the mesh
  38251. */
  38252. constructor(ui: TransformNode);
  38253. /**
  38254. * Initializes the behavior
  38255. */
  38256. init(): void;
  38257. private _closestFace;
  38258. private _zeroVector;
  38259. private _lookAtTmpMatrix;
  38260. private _lookAtToRef;
  38261. /**
  38262. * Attaches the AttachToBoxBehavior to the passed in mesh
  38263. * @param target The mesh that the specified node will be attached to
  38264. */
  38265. attach(target: Mesh): void;
  38266. /**
  38267. * Detaches the behavior from the mesh
  38268. */
  38269. detach(): void;
  38270. }
  38271. }
  38272. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38273. import { Behavior } from "babylonjs/Behaviors/behavior";
  38274. import { Mesh } from "babylonjs/Meshes/mesh";
  38275. /**
  38276. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38277. */
  38278. export class FadeInOutBehavior implements Behavior<Mesh> {
  38279. /**
  38280. * Time in milliseconds to delay before fading in (Default: 0)
  38281. */
  38282. delay: number;
  38283. /**
  38284. * Time in milliseconds for the mesh to fade in (Default: 300)
  38285. */
  38286. fadeInTime: number;
  38287. private _millisecondsPerFrame;
  38288. private _hovered;
  38289. private _hoverValue;
  38290. private _ownerNode;
  38291. /**
  38292. * Instatiates the FadeInOutBehavior
  38293. */
  38294. constructor();
  38295. /**
  38296. * The name of the behavior
  38297. */
  38298. readonly name: string;
  38299. /**
  38300. * Initializes the behavior
  38301. */
  38302. init(): void;
  38303. /**
  38304. * Attaches the fade behavior on the passed in mesh
  38305. * @param ownerNode The mesh that will be faded in/out once attached
  38306. */
  38307. attach(ownerNode: Mesh): void;
  38308. /**
  38309. * Detaches the behavior from the mesh
  38310. */
  38311. detach(): void;
  38312. /**
  38313. * Triggers the mesh to begin fading in or out
  38314. * @param value if the object should fade in or out (true to fade in)
  38315. */
  38316. fadeIn(value: boolean): void;
  38317. private _update;
  38318. private _setAllVisibility;
  38319. }
  38320. }
  38321. declare module "babylonjs/Misc/pivotTools" {
  38322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38323. /**
  38324. * Class containing a set of static utilities functions for managing Pivots
  38325. * @hidden
  38326. */
  38327. export class PivotTools {
  38328. private static _PivotCached;
  38329. private static _OldPivotPoint;
  38330. private static _PivotTranslation;
  38331. private static _PivotTmpVector;
  38332. /** @hidden */
  38333. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38334. /** @hidden */
  38335. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38336. }
  38337. }
  38338. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38339. import { Scene } from "babylonjs/scene";
  38340. import { Vector4 } from "babylonjs/Maths/math.vector";
  38341. import { Mesh } from "babylonjs/Meshes/mesh";
  38342. import { Nullable } from "babylonjs/types";
  38343. import { Plane } from "babylonjs/Maths/math.plane";
  38344. /**
  38345. * Class containing static functions to help procedurally build meshes
  38346. */
  38347. export class PlaneBuilder {
  38348. /**
  38349. * Creates a plane mesh
  38350. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38351. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38352. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38356. * @param name defines the name of the mesh
  38357. * @param options defines the options used to create the mesh
  38358. * @param scene defines the hosting scene
  38359. * @returns the plane mesh
  38360. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38361. */
  38362. static CreatePlane(name: string, options: {
  38363. size?: number;
  38364. width?: number;
  38365. height?: number;
  38366. sideOrientation?: number;
  38367. frontUVs?: Vector4;
  38368. backUVs?: Vector4;
  38369. updatable?: boolean;
  38370. sourcePlane?: Plane;
  38371. }, scene?: Nullable<Scene>): Mesh;
  38372. }
  38373. }
  38374. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38375. import { Behavior } from "babylonjs/Behaviors/behavior";
  38376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38377. import { Observable } from "babylonjs/Misc/observable";
  38378. import { Vector3 } from "babylonjs/Maths/math.vector";
  38379. import { Ray } from "babylonjs/Culling/ray";
  38380. import "babylonjs/Meshes/Builders/planeBuilder";
  38381. /**
  38382. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38383. */
  38384. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38385. private static _AnyMouseID;
  38386. /**
  38387. * Abstract mesh the behavior is set on
  38388. */
  38389. attachedNode: AbstractMesh;
  38390. private _dragPlane;
  38391. private _scene;
  38392. private _pointerObserver;
  38393. private _beforeRenderObserver;
  38394. private static _planeScene;
  38395. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38396. /**
  38397. * 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)
  38398. */
  38399. maxDragAngle: number;
  38400. /**
  38401. * @hidden
  38402. */
  38403. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38404. /**
  38405. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38406. */
  38407. currentDraggingPointerID: number;
  38408. /**
  38409. * The last position where the pointer hit the drag plane in world space
  38410. */
  38411. lastDragPosition: Vector3;
  38412. /**
  38413. * If the behavior is currently in a dragging state
  38414. */
  38415. dragging: boolean;
  38416. /**
  38417. * 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)
  38418. */
  38419. dragDeltaRatio: number;
  38420. /**
  38421. * If the drag plane orientation should be updated during the dragging (Default: true)
  38422. */
  38423. updateDragPlane: boolean;
  38424. private _debugMode;
  38425. private _moving;
  38426. /**
  38427. * Fires each time the attached mesh is dragged with the pointer
  38428. * * delta between last drag position and current drag position in world space
  38429. * * dragDistance along the drag axis
  38430. * * dragPlaneNormal normal of the current drag plane used during the drag
  38431. * * dragPlanePoint in world space where the drag intersects the drag plane
  38432. */
  38433. onDragObservable: Observable<{
  38434. delta: Vector3;
  38435. dragPlanePoint: Vector3;
  38436. dragPlaneNormal: Vector3;
  38437. dragDistance: number;
  38438. pointerId: number;
  38439. }>;
  38440. /**
  38441. * Fires each time a drag begins (eg. mouse down on mesh)
  38442. */
  38443. onDragStartObservable: Observable<{
  38444. dragPlanePoint: Vector3;
  38445. pointerId: number;
  38446. }>;
  38447. /**
  38448. * Fires each time a drag ends (eg. mouse release after drag)
  38449. */
  38450. onDragEndObservable: Observable<{
  38451. dragPlanePoint: Vector3;
  38452. pointerId: number;
  38453. }>;
  38454. /**
  38455. * If the attached mesh should be moved when dragged
  38456. */
  38457. moveAttached: boolean;
  38458. /**
  38459. * If the drag behavior will react to drag events (Default: true)
  38460. */
  38461. enabled: boolean;
  38462. /**
  38463. * If pointer events should start and release the drag (Default: true)
  38464. */
  38465. startAndReleaseDragOnPointerEvents: boolean;
  38466. /**
  38467. * If camera controls should be detached during the drag
  38468. */
  38469. detachCameraControls: boolean;
  38470. /**
  38471. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38472. */
  38473. useObjectOrienationForDragging: boolean;
  38474. private _options;
  38475. /**
  38476. * Creates a pointer drag behavior that can be attached to a mesh
  38477. * @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)
  38478. */
  38479. constructor(options?: {
  38480. dragAxis?: Vector3;
  38481. dragPlaneNormal?: Vector3;
  38482. });
  38483. /**
  38484. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38485. */
  38486. validateDrag: (targetPosition: Vector3) => boolean;
  38487. /**
  38488. * The name of the behavior
  38489. */
  38490. readonly name: string;
  38491. /**
  38492. * Initializes the behavior
  38493. */
  38494. init(): void;
  38495. private _tmpVector;
  38496. private _alternatePickedPoint;
  38497. private _worldDragAxis;
  38498. private _targetPosition;
  38499. private _attachedElement;
  38500. /**
  38501. * Attaches the drag behavior the passed in mesh
  38502. * @param ownerNode The mesh that will be dragged around once attached
  38503. * @param predicate Predicate to use for pick filtering
  38504. */
  38505. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38506. /**
  38507. * Force relase the drag action by code.
  38508. */
  38509. releaseDrag(): void;
  38510. private _startDragRay;
  38511. private _lastPointerRay;
  38512. /**
  38513. * Simulates the start of a pointer drag event on the behavior
  38514. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38515. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38516. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38517. */
  38518. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38519. private _startDrag;
  38520. private _dragDelta;
  38521. private _moveDrag;
  38522. private _pickWithRayOnDragPlane;
  38523. private _pointA;
  38524. private _pointB;
  38525. private _pointC;
  38526. private _lineA;
  38527. private _lineB;
  38528. private _localAxis;
  38529. private _lookAt;
  38530. private _updateDragPlanePosition;
  38531. /**
  38532. * Detaches the behavior from the mesh
  38533. */
  38534. detach(): void;
  38535. }
  38536. }
  38537. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38538. import { Mesh } from "babylonjs/Meshes/mesh";
  38539. import { Behavior } from "babylonjs/Behaviors/behavior";
  38540. /**
  38541. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38542. */
  38543. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38544. private _dragBehaviorA;
  38545. private _dragBehaviorB;
  38546. private _startDistance;
  38547. private _initialScale;
  38548. private _targetScale;
  38549. private _ownerNode;
  38550. private _sceneRenderObserver;
  38551. /**
  38552. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38553. */
  38554. constructor();
  38555. /**
  38556. * The name of the behavior
  38557. */
  38558. readonly name: string;
  38559. /**
  38560. * Initializes the behavior
  38561. */
  38562. init(): void;
  38563. private _getCurrentDistance;
  38564. /**
  38565. * Attaches the scale behavior the passed in mesh
  38566. * @param ownerNode The mesh that will be scaled around once attached
  38567. */
  38568. attach(ownerNode: Mesh): void;
  38569. /**
  38570. * Detaches the behavior from the mesh
  38571. */
  38572. detach(): void;
  38573. }
  38574. }
  38575. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38576. import { Behavior } from "babylonjs/Behaviors/behavior";
  38577. import { Mesh } from "babylonjs/Meshes/mesh";
  38578. import { Observable } from "babylonjs/Misc/observable";
  38579. /**
  38580. * 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
  38581. */
  38582. export class SixDofDragBehavior implements Behavior<Mesh> {
  38583. private static _virtualScene;
  38584. private _ownerNode;
  38585. private _sceneRenderObserver;
  38586. private _scene;
  38587. private _targetPosition;
  38588. private _virtualOriginMesh;
  38589. private _virtualDragMesh;
  38590. private _pointerObserver;
  38591. private _moving;
  38592. private _startingOrientation;
  38593. /**
  38594. * 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)
  38595. */
  38596. private zDragFactor;
  38597. /**
  38598. * If the object should rotate to face the drag origin
  38599. */
  38600. rotateDraggedObject: boolean;
  38601. /**
  38602. * If the behavior is currently in a dragging state
  38603. */
  38604. dragging: boolean;
  38605. /**
  38606. * 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)
  38607. */
  38608. dragDeltaRatio: number;
  38609. /**
  38610. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38611. */
  38612. currentDraggingPointerID: number;
  38613. /**
  38614. * If camera controls should be detached during the drag
  38615. */
  38616. detachCameraControls: boolean;
  38617. /**
  38618. * Fires each time a drag starts
  38619. */
  38620. onDragStartObservable: Observable<{}>;
  38621. /**
  38622. * Fires each time a drag ends (eg. mouse release after drag)
  38623. */
  38624. onDragEndObservable: Observable<{}>;
  38625. /**
  38626. * 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
  38627. */
  38628. constructor();
  38629. /**
  38630. * The name of the behavior
  38631. */
  38632. readonly name: string;
  38633. /**
  38634. * Initializes the behavior
  38635. */
  38636. init(): void;
  38637. /**
  38638. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38639. */
  38640. private readonly _pointerCamera;
  38641. /**
  38642. * Attaches the scale behavior the passed in mesh
  38643. * @param ownerNode The mesh that will be scaled around once attached
  38644. */
  38645. attach(ownerNode: Mesh): void;
  38646. /**
  38647. * Detaches the behavior from the mesh
  38648. */
  38649. detach(): void;
  38650. }
  38651. }
  38652. declare module "babylonjs/Behaviors/Meshes/index" {
  38653. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38654. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38655. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38656. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38657. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38658. }
  38659. declare module "babylonjs/Behaviors/index" {
  38660. export * from "babylonjs/Behaviors/behavior";
  38661. export * from "babylonjs/Behaviors/Cameras/index";
  38662. export * from "babylonjs/Behaviors/Meshes/index";
  38663. }
  38664. declare module "babylonjs/Bones/boneIKController" {
  38665. import { Bone } from "babylonjs/Bones/bone";
  38666. import { Vector3 } from "babylonjs/Maths/math.vector";
  38667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38668. import { Nullable } from "babylonjs/types";
  38669. /**
  38670. * Class used to apply inverse kinematics to bones
  38671. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38672. */
  38673. export class BoneIKController {
  38674. private static _tmpVecs;
  38675. private static _tmpQuat;
  38676. private static _tmpMats;
  38677. /**
  38678. * Gets or sets the target mesh
  38679. */
  38680. targetMesh: AbstractMesh;
  38681. /** Gets or sets the mesh used as pole */
  38682. poleTargetMesh: AbstractMesh;
  38683. /**
  38684. * Gets or sets the bone used as pole
  38685. */
  38686. poleTargetBone: Nullable<Bone>;
  38687. /**
  38688. * Gets or sets the target position
  38689. */
  38690. targetPosition: Vector3;
  38691. /**
  38692. * Gets or sets the pole target position
  38693. */
  38694. poleTargetPosition: Vector3;
  38695. /**
  38696. * Gets or sets the pole target local offset
  38697. */
  38698. poleTargetLocalOffset: Vector3;
  38699. /**
  38700. * Gets or sets the pole angle
  38701. */
  38702. poleAngle: number;
  38703. /**
  38704. * Gets or sets the mesh associated with the controller
  38705. */
  38706. mesh: AbstractMesh;
  38707. /**
  38708. * 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)
  38709. */
  38710. slerpAmount: number;
  38711. private _bone1Quat;
  38712. private _bone1Mat;
  38713. private _bone2Ang;
  38714. private _bone1;
  38715. private _bone2;
  38716. private _bone1Length;
  38717. private _bone2Length;
  38718. private _maxAngle;
  38719. private _maxReach;
  38720. private _rightHandedSystem;
  38721. private _bendAxis;
  38722. private _slerping;
  38723. private _adjustRoll;
  38724. /**
  38725. * Gets or sets maximum allowed angle
  38726. */
  38727. maxAngle: number;
  38728. /**
  38729. * Creates a new BoneIKController
  38730. * @param mesh defines the mesh to control
  38731. * @param bone defines the bone to control
  38732. * @param options defines options to set up the controller
  38733. */
  38734. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38735. targetMesh?: AbstractMesh;
  38736. poleTargetMesh?: AbstractMesh;
  38737. poleTargetBone?: Bone;
  38738. poleTargetLocalOffset?: Vector3;
  38739. poleAngle?: number;
  38740. bendAxis?: Vector3;
  38741. maxAngle?: number;
  38742. slerpAmount?: number;
  38743. });
  38744. private _setMaxAngle;
  38745. /**
  38746. * Force the controller to update the bones
  38747. */
  38748. update(): void;
  38749. }
  38750. }
  38751. declare module "babylonjs/Bones/boneLookController" {
  38752. import { Vector3 } from "babylonjs/Maths/math.vector";
  38753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38754. import { Bone } from "babylonjs/Bones/bone";
  38755. import { Space } from "babylonjs/Maths/math.axis";
  38756. /**
  38757. * Class used to make a bone look toward a point in space
  38758. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38759. */
  38760. export class BoneLookController {
  38761. private static _tmpVecs;
  38762. private static _tmpQuat;
  38763. private static _tmpMats;
  38764. /**
  38765. * The target Vector3 that the bone will look at
  38766. */
  38767. target: Vector3;
  38768. /**
  38769. * The mesh that the bone is attached to
  38770. */
  38771. mesh: AbstractMesh;
  38772. /**
  38773. * The bone that will be looking to the target
  38774. */
  38775. bone: Bone;
  38776. /**
  38777. * The up axis of the coordinate system that is used when the bone is rotated
  38778. */
  38779. upAxis: Vector3;
  38780. /**
  38781. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38782. */
  38783. upAxisSpace: Space;
  38784. /**
  38785. * Used to make an adjustment to the yaw of the bone
  38786. */
  38787. adjustYaw: number;
  38788. /**
  38789. * Used to make an adjustment to the pitch of the bone
  38790. */
  38791. adjustPitch: number;
  38792. /**
  38793. * Used to make an adjustment to the roll of the bone
  38794. */
  38795. adjustRoll: number;
  38796. /**
  38797. * 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)
  38798. */
  38799. slerpAmount: number;
  38800. private _minYaw;
  38801. private _maxYaw;
  38802. private _minPitch;
  38803. private _maxPitch;
  38804. private _minYawSin;
  38805. private _minYawCos;
  38806. private _maxYawSin;
  38807. private _maxYawCos;
  38808. private _midYawConstraint;
  38809. private _minPitchTan;
  38810. private _maxPitchTan;
  38811. private _boneQuat;
  38812. private _slerping;
  38813. private _transformYawPitch;
  38814. private _transformYawPitchInv;
  38815. private _firstFrameSkipped;
  38816. private _yawRange;
  38817. private _fowardAxis;
  38818. /**
  38819. * Gets or sets the minimum yaw angle that the bone can look to
  38820. */
  38821. minYaw: number;
  38822. /**
  38823. * Gets or sets the maximum yaw angle that the bone can look to
  38824. */
  38825. maxYaw: number;
  38826. /**
  38827. * Gets or sets the minimum pitch angle that the bone can look to
  38828. */
  38829. minPitch: number;
  38830. /**
  38831. * Gets or sets the maximum pitch angle that the bone can look to
  38832. */
  38833. maxPitch: number;
  38834. /**
  38835. * Create a BoneLookController
  38836. * @param mesh the mesh that the bone belongs to
  38837. * @param bone the bone that will be looking to the target
  38838. * @param target the target Vector3 to look at
  38839. * @param options optional settings:
  38840. * * maxYaw: the maximum angle the bone will yaw to
  38841. * * minYaw: the minimum angle the bone will yaw to
  38842. * * maxPitch: the maximum angle the bone will pitch to
  38843. * * minPitch: the minimum angle the bone will yaw to
  38844. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38845. * * upAxis: the up axis of the coordinate system
  38846. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38847. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38848. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38849. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38850. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38851. * * adjustRoll: used to make an adjustment to the roll of the bone
  38852. **/
  38853. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38854. maxYaw?: number;
  38855. minYaw?: number;
  38856. maxPitch?: number;
  38857. minPitch?: number;
  38858. slerpAmount?: number;
  38859. upAxis?: Vector3;
  38860. upAxisSpace?: Space;
  38861. yawAxis?: Vector3;
  38862. pitchAxis?: Vector3;
  38863. adjustYaw?: number;
  38864. adjustPitch?: number;
  38865. adjustRoll?: number;
  38866. });
  38867. /**
  38868. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38869. */
  38870. update(): void;
  38871. private _getAngleDiff;
  38872. private _getAngleBetween;
  38873. private _isAngleBetween;
  38874. }
  38875. }
  38876. declare module "babylonjs/Bones/index" {
  38877. export * from "babylonjs/Bones/bone";
  38878. export * from "babylonjs/Bones/boneIKController";
  38879. export * from "babylonjs/Bones/boneLookController";
  38880. export * from "babylonjs/Bones/skeleton";
  38881. }
  38882. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38883. import { Nullable } from "babylonjs/types";
  38884. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38885. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38886. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38887. /**
  38888. * Manage the gamepad inputs to control an arc rotate camera.
  38889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38890. */
  38891. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38892. /**
  38893. * Defines the camera the input is attached to.
  38894. */
  38895. camera: ArcRotateCamera;
  38896. /**
  38897. * Defines the gamepad the input is gathering event from.
  38898. */
  38899. gamepad: Nullable<Gamepad>;
  38900. /**
  38901. * Defines the gamepad rotation sensiblity.
  38902. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38903. */
  38904. gamepadRotationSensibility: number;
  38905. /**
  38906. * Defines the gamepad move sensiblity.
  38907. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38908. */
  38909. gamepadMoveSensibility: number;
  38910. private _yAxisScale;
  38911. /**
  38912. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38913. */
  38914. invertYAxis: boolean;
  38915. private _onGamepadConnectedObserver;
  38916. private _onGamepadDisconnectedObserver;
  38917. /**
  38918. * Attach the input controls to a specific dom element to get the input from.
  38919. * @param element Defines the element the controls should be listened from
  38920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38921. */
  38922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38923. /**
  38924. * Detach the current controls from the specified dom element.
  38925. * @param element Defines the element to stop listening the inputs from
  38926. */
  38927. detachControl(element: Nullable<HTMLElement>): void;
  38928. /**
  38929. * Update the current camera state depending on the inputs that have been used this frame.
  38930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38931. */
  38932. checkInputs(): void;
  38933. /**
  38934. * Gets the class name of the current intput.
  38935. * @returns the class name
  38936. */
  38937. getClassName(): string;
  38938. /**
  38939. * Get the friendly name associated with the input class.
  38940. * @returns the input friendly name
  38941. */
  38942. getSimpleName(): string;
  38943. }
  38944. }
  38945. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38946. import { Nullable } from "babylonjs/types";
  38947. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38949. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38950. interface ArcRotateCameraInputsManager {
  38951. /**
  38952. * Add orientation input support to the input manager.
  38953. * @returns the current input manager
  38954. */
  38955. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38956. }
  38957. }
  38958. /**
  38959. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38961. */
  38962. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38963. /**
  38964. * Defines the camera the input is attached to.
  38965. */
  38966. camera: ArcRotateCamera;
  38967. /**
  38968. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38969. */
  38970. alphaCorrection: number;
  38971. /**
  38972. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38973. */
  38974. gammaCorrection: number;
  38975. private _alpha;
  38976. private _gamma;
  38977. private _dirty;
  38978. private _deviceOrientationHandler;
  38979. /**
  38980. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38981. */
  38982. constructor();
  38983. /**
  38984. * Attach the input controls to a specific dom element to get the input from.
  38985. * @param element Defines the element the controls should be listened from
  38986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38987. */
  38988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38989. /** @hidden */
  38990. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38991. /**
  38992. * Update the current camera state depending on the inputs that have been used this frame.
  38993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38994. */
  38995. checkInputs(): void;
  38996. /**
  38997. * Detach the current controls from the specified dom element.
  38998. * @param element Defines the element to stop listening the inputs from
  38999. */
  39000. detachControl(element: Nullable<HTMLElement>): void;
  39001. /**
  39002. * Gets the class name of the current intput.
  39003. * @returns the class name
  39004. */
  39005. getClassName(): string;
  39006. /**
  39007. * Get the friendly name associated with the input class.
  39008. * @returns the input friendly name
  39009. */
  39010. getSimpleName(): string;
  39011. }
  39012. }
  39013. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39014. import { Nullable } from "babylonjs/types";
  39015. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39016. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39017. /**
  39018. * Listen to mouse events to control the camera.
  39019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39020. */
  39021. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39022. /**
  39023. * Defines the camera the input is attached to.
  39024. */
  39025. camera: FlyCamera;
  39026. /**
  39027. * Defines if touch is enabled. (Default is true.)
  39028. */
  39029. touchEnabled: boolean;
  39030. /**
  39031. * Defines the buttons associated with the input to handle camera rotation.
  39032. */
  39033. buttons: number[];
  39034. /**
  39035. * Assign buttons for Yaw control.
  39036. */
  39037. buttonsYaw: number[];
  39038. /**
  39039. * Assign buttons for Pitch control.
  39040. */
  39041. buttonsPitch: number[];
  39042. /**
  39043. * Assign buttons for Roll control.
  39044. */
  39045. buttonsRoll: number[];
  39046. /**
  39047. * Detect if any button is being pressed while mouse is moved.
  39048. * -1 = Mouse locked.
  39049. * 0 = Left button.
  39050. * 1 = Middle Button.
  39051. * 2 = Right Button.
  39052. */
  39053. activeButton: number;
  39054. /**
  39055. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39056. * Higher values reduce its sensitivity.
  39057. */
  39058. angularSensibility: number;
  39059. private _mousemoveCallback;
  39060. private _observer;
  39061. private _rollObserver;
  39062. private previousPosition;
  39063. private noPreventDefault;
  39064. private element;
  39065. /**
  39066. * Listen to mouse events to control the camera.
  39067. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39069. */
  39070. constructor(touchEnabled?: boolean);
  39071. /**
  39072. * Attach the mouse control to the HTML DOM element.
  39073. * @param element Defines the element that listens to the input events.
  39074. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39075. */
  39076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39077. /**
  39078. * Detach the current controls from the specified dom element.
  39079. * @param element Defines the element to stop listening the inputs from
  39080. */
  39081. detachControl(element: Nullable<HTMLElement>): void;
  39082. /**
  39083. * Gets the class name of the current input.
  39084. * @returns the class name.
  39085. */
  39086. getClassName(): string;
  39087. /**
  39088. * Get the friendly name associated with the input class.
  39089. * @returns the input's friendly name.
  39090. */
  39091. getSimpleName(): string;
  39092. private _pointerInput;
  39093. private _onMouseMove;
  39094. /**
  39095. * Rotate camera by mouse offset.
  39096. */
  39097. private rotateCamera;
  39098. }
  39099. }
  39100. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39101. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39102. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39103. /**
  39104. * Default Inputs manager for the FlyCamera.
  39105. * It groups all the default supported inputs for ease of use.
  39106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39107. */
  39108. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39109. /**
  39110. * Instantiates a new FlyCameraInputsManager.
  39111. * @param camera Defines the camera the inputs belong to.
  39112. */
  39113. constructor(camera: FlyCamera);
  39114. /**
  39115. * Add keyboard input support to the input manager.
  39116. * @returns the new FlyCameraKeyboardMoveInput().
  39117. */
  39118. addKeyboard(): FlyCameraInputsManager;
  39119. /**
  39120. * Add mouse input support to the input manager.
  39121. * @param touchEnabled Enable touch screen support.
  39122. * @returns the new FlyCameraMouseInput().
  39123. */
  39124. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39125. }
  39126. }
  39127. declare module "babylonjs/Cameras/flyCamera" {
  39128. import { Scene } from "babylonjs/scene";
  39129. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39131. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39132. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39133. /**
  39134. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39135. * such as in a 3D Space Shooter or a Flight Simulator.
  39136. */
  39137. export class FlyCamera extends TargetCamera {
  39138. /**
  39139. * Define the collision ellipsoid of the camera.
  39140. * This is helpful for simulating a camera body, like a player's body.
  39141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39142. */
  39143. ellipsoid: Vector3;
  39144. /**
  39145. * Define an offset for the position of the ellipsoid around the camera.
  39146. * This can be helpful if the camera is attached away from the player's body center,
  39147. * such as at its head.
  39148. */
  39149. ellipsoidOffset: Vector3;
  39150. /**
  39151. * Enable or disable collisions of the camera with the rest of the scene objects.
  39152. */
  39153. checkCollisions: boolean;
  39154. /**
  39155. * Enable or disable gravity on the camera.
  39156. */
  39157. applyGravity: boolean;
  39158. /**
  39159. * Define the current direction the camera is moving to.
  39160. */
  39161. cameraDirection: Vector3;
  39162. /**
  39163. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39164. * This overrides and empties cameraRotation.
  39165. */
  39166. rotationQuaternion: Quaternion;
  39167. /**
  39168. * Track Roll to maintain the wanted Rolling when looking around.
  39169. */
  39170. _trackRoll: number;
  39171. /**
  39172. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39173. */
  39174. rollCorrect: number;
  39175. /**
  39176. * Mimic a banked turn, Rolling the camera when Yawing.
  39177. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39178. */
  39179. bankedTurn: boolean;
  39180. /**
  39181. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39182. */
  39183. bankedTurnLimit: number;
  39184. /**
  39185. * Value of 0 disables the banked Roll.
  39186. * Value of 1 is equal to the Yaw angle in radians.
  39187. */
  39188. bankedTurnMultiplier: number;
  39189. /**
  39190. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39191. */
  39192. inputs: FlyCameraInputsManager;
  39193. /**
  39194. * Gets the input sensibility for mouse input.
  39195. * Higher values reduce sensitivity.
  39196. */
  39197. /**
  39198. * Sets the input sensibility for a mouse input.
  39199. * Higher values reduce sensitivity.
  39200. */
  39201. angularSensibility: number;
  39202. /**
  39203. * Get the keys for camera movement forward.
  39204. */
  39205. /**
  39206. * Set the keys for camera movement forward.
  39207. */
  39208. keysForward: number[];
  39209. /**
  39210. * Get the keys for camera movement backward.
  39211. */
  39212. keysBackward: number[];
  39213. /**
  39214. * Get the keys for camera movement up.
  39215. */
  39216. /**
  39217. * Set the keys for camera movement up.
  39218. */
  39219. keysUp: number[];
  39220. /**
  39221. * Get the keys for camera movement down.
  39222. */
  39223. /**
  39224. * Set the keys for camera movement down.
  39225. */
  39226. keysDown: number[];
  39227. /**
  39228. * Get the keys for camera movement left.
  39229. */
  39230. /**
  39231. * Set the keys for camera movement left.
  39232. */
  39233. keysLeft: number[];
  39234. /**
  39235. * Set the keys for camera movement right.
  39236. */
  39237. /**
  39238. * Set the keys for camera movement right.
  39239. */
  39240. keysRight: number[];
  39241. /**
  39242. * Event raised when the camera collides with a mesh in the scene.
  39243. */
  39244. onCollide: (collidedMesh: AbstractMesh) => void;
  39245. private _collider;
  39246. private _needMoveForGravity;
  39247. private _oldPosition;
  39248. private _diffPosition;
  39249. private _newPosition;
  39250. /** @hidden */
  39251. _localDirection: Vector3;
  39252. /** @hidden */
  39253. _transformedDirection: Vector3;
  39254. /**
  39255. * Instantiates a FlyCamera.
  39256. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39257. * such as in a 3D Space Shooter or a Flight Simulator.
  39258. * @param name Define the name of the camera in the scene.
  39259. * @param position Define the starting position of the camera in the scene.
  39260. * @param scene Define the scene the camera belongs to.
  39261. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39262. */
  39263. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39264. /**
  39265. * Attach a control to the HTML DOM element.
  39266. * @param element Defines the element that listens to the input events.
  39267. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39268. */
  39269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39270. /**
  39271. * Detach a control from the HTML DOM element.
  39272. * The camera will stop reacting to that input.
  39273. * @param element Defines the element that listens to the input events.
  39274. */
  39275. detachControl(element: HTMLElement): void;
  39276. private _collisionMask;
  39277. /**
  39278. * Get the mask that the camera ignores in collision events.
  39279. */
  39280. /**
  39281. * Set the mask that the camera ignores in collision events.
  39282. */
  39283. collisionMask: number;
  39284. /** @hidden */
  39285. _collideWithWorld(displacement: Vector3): void;
  39286. /** @hidden */
  39287. private _onCollisionPositionChange;
  39288. /** @hidden */
  39289. _checkInputs(): void;
  39290. /** @hidden */
  39291. _decideIfNeedsToMove(): boolean;
  39292. /** @hidden */
  39293. _updatePosition(): void;
  39294. /**
  39295. * Restore the Roll to its target value at the rate specified.
  39296. * @param rate - Higher means slower restoring.
  39297. * @hidden
  39298. */
  39299. restoreRoll(rate: number): void;
  39300. /**
  39301. * Destroy the camera and release the current resources held by it.
  39302. */
  39303. dispose(): void;
  39304. /**
  39305. * Get the current object class name.
  39306. * @returns the class name.
  39307. */
  39308. getClassName(): string;
  39309. }
  39310. }
  39311. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39312. import { Nullable } from "babylonjs/types";
  39313. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39314. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39315. /**
  39316. * Listen to keyboard events to control the camera.
  39317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39318. */
  39319. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39320. /**
  39321. * Defines the camera the input is attached to.
  39322. */
  39323. camera: FlyCamera;
  39324. /**
  39325. * The list of keyboard keys used to control the forward move of the camera.
  39326. */
  39327. keysForward: number[];
  39328. /**
  39329. * The list of keyboard keys used to control the backward move of the camera.
  39330. */
  39331. keysBackward: number[];
  39332. /**
  39333. * The list of keyboard keys used to control the forward move of the camera.
  39334. */
  39335. keysUp: number[];
  39336. /**
  39337. * The list of keyboard keys used to control the backward move of the camera.
  39338. */
  39339. keysDown: number[];
  39340. /**
  39341. * The list of keyboard keys used to control the right strafe move of the camera.
  39342. */
  39343. keysRight: number[];
  39344. /**
  39345. * The list of keyboard keys used to control the left strafe move of the camera.
  39346. */
  39347. keysLeft: number[];
  39348. private _keys;
  39349. private _onCanvasBlurObserver;
  39350. private _onKeyboardObserver;
  39351. private _engine;
  39352. private _scene;
  39353. /**
  39354. * Attach the input controls to a specific dom element to get the input from.
  39355. * @param element Defines the element the controls should be listened from
  39356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39357. */
  39358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39359. /**
  39360. * Detach the current controls from the specified dom element.
  39361. * @param element Defines the element to stop listening the inputs from
  39362. */
  39363. detachControl(element: Nullable<HTMLElement>): void;
  39364. /**
  39365. * Gets the class name of the current intput.
  39366. * @returns the class name
  39367. */
  39368. getClassName(): string;
  39369. /** @hidden */
  39370. _onLostFocus(e: FocusEvent): void;
  39371. /**
  39372. * Get the friendly name associated with the input class.
  39373. * @returns the input friendly name
  39374. */
  39375. getSimpleName(): string;
  39376. /**
  39377. * Update the current camera state depending on the inputs that have been used this frame.
  39378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39379. */
  39380. checkInputs(): void;
  39381. }
  39382. }
  39383. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39384. import { Nullable } from "babylonjs/types";
  39385. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39386. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39387. /**
  39388. * Manage the mouse wheel inputs to control a follow camera.
  39389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39390. */
  39391. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39392. /**
  39393. * Defines the camera the input is attached to.
  39394. */
  39395. camera: FollowCamera;
  39396. /**
  39397. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39398. */
  39399. axisControlRadius: boolean;
  39400. /**
  39401. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39402. */
  39403. axisControlHeight: boolean;
  39404. /**
  39405. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39406. */
  39407. axisControlRotation: boolean;
  39408. /**
  39409. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39410. * relation to mouseWheel events.
  39411. */
  39412. wheelPrecision: number;
  39413. /**
  39414. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39415. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39416. */
  39417. wheelDeltaPercentage: number;
  39418. private _wheel;
  39419. private _observer;
  39420. /**
  39421. * Attach the input controls to a specific dom element to get the input from.
  39422. * @param element Defines the element the controls should be listened from
  39423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39424. */
  39425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39426. /**
  39427. * Detach the current controls from the specified dom element.
  39428. * @param element Defines the element to stop listening the inputs from
  39429. */
  39430. detachControl(element: Nullable<HTMLElement>): void;
  39431. /**
  39432. * Gets the class name of the current intput.
  39433. * @returns the class name
  39434. */
  39435. getClassName(): string;
  39436. /**
  39437. * Get the friendly name associated with the input class.
  39438. * @returns the input friendly name
  39439. */
  39440. getSimpleName(): string;
  39441. }
  39442. }
  39443. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39444. import { Nullable } from "babylonjs/types";
  39445. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39446. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39447. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39448. /**
  39449. * Manage the pointers inputs to control an follow camera.
  39450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39451. */
  39452. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39453. /**
  39454. * Defines the camera the input is attached to.
  39455. */
  39456. camera: FollowCamera;
  39457. /**
  39458. * Gets the class name of the current input.
  39459. * @returns the class name
  39460. */
  39461. getClassName(): string;
  39462. /**
  39463. * Defines the pointer angular sensibility along the X axis or how fast is
  39464. * the camera rotating.
  39465. * A negative number will reverse the axis direction.
  39466. */
  39467. angularSensibilityX: number;
  39468. /**
  39469. * Defines the pointer angular sensibility along the Y axis or how fast is
  39470. * the camera rotating.
  39471. * A negative number will reverse the axis direction.
  39472. */
  39473. angularSensibilityY: number;
  39474. /**
  39475. * Defines the pointer pinch precision or how fast is the camera zooming.
  39476. * A negative number will reverse the axis direction.
  39477. */
  39478. pinchPrecision: number;
  39479. /**
  39480. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39481. * from 0.
  39482. * It defines the percentage of current camera.radius to use as delta when
  39483. * pinch zoom is used.
  39484. */
  39485. pinchDeltaPercentage: number;
  39486. /**
  39487. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39488. */
  39489. axisXControlRadius: boolean;
  39490. /**
  39491. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39492. */
  39493. axisXControlHeight: boolean;
  39494. /**
  39495. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39496. */
  39497. axisXControlRotation: boolean;
  39498. /**
  39499. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39500. */
  39501. axisYControlRadius: boolean;
  39502. /**
  39503. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39504. */
  39505. axisYControlHeight: boolean;
  39506. /**
  39507. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39508. */
  39509. axisYControlRotation: boolean;
  39510. /**
  39511. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39512. */
  39513. axisPinchControlRadius: boolean;
  39514. /**
  39515. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39516. */
  39517. axisPinchControlHeight: boolean;
  39518. /**
  39519. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39520. */
  39521. axisPinchControlRotation: boolean;
  39522. /**
  39523. * Log error messages if basic misconfiguration has occurred.
  39524. */
  39525. warningEnable: boolean;
  39526. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39528. private _warningCounter;
  39529. private _warning;
  39530. }
  39531. }
  39532. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39533. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39534. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39535. /**
  39536. * Default Inputs manager for the FollowCamera.
  39537. * It groups all the default supported inputs for ease of use.
  39538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39539. */
  39540. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39541. /**
  39542. * Instantiates a new FollowCameraInputsManager.
  39543. * @param camera Defines the camera the inputs belong to
  39544. */
  39545. constructor(camera: FollowCamera);
  39546. /**
  39547. * Add keyboard input support to the input manager.
  39548. * @returns the current input manager
  39549. */
  39550. addKeyboard(): FollowCameraInputsManager;
  39551. /**
  39552. * Add mouse wheel input support to the input manager.
  39553. * @returns the current input manager
  39554. */
  39555. addMouseWheel(): FollowCameraInputsManager;
  39556. /**
  39557. * Add pointers input support to the input manager.
  39558. * @returns the current input manager
  39559. */
  39560. addPointers(): FollowCameraInputsManager;
  39561. /**
  39562. * Add orientation input support to the input manager.
  39563. * @returns the current input manager
  39564. */
  39565. addVRDeviceOrientation(): FollowCameraInputsManager;
  39566. }
  39567. }
  39568. declare module "babylonjs/Cameras/followCamera" {
  39569. import { Nullable } from "babylonjs/types";
  39570. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39571. import { Scene } from "babylonjs/scene";
  39572. import { Vector3 } from "babylonjs/Maths/math.vector";
  39573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39574. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39575. /**
  39576. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39577. * an arc rotate version arcFollowCamera are available.
  39578. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39579. */
  39580. export class FollowCamera extends TargetCamera {
  39581. /**
  39582. * Distance the follow camera should follow an object at
  39583. */
  39584. radius: number;
  39585. /**
  39586. * Minimum allowed distance of the camera to the axis of rotation
  39587. * (The camera can not get closer).
  39588. * This can help limiting how the Camera is able to move in the scene.
  39589. */
  39590. lowerRadiusLimit: Nullable<number>;
  39591. /**
  39592. * Maximum allowed distance of the camera to the axis of rotation
  39593. * (The camera can not get further).
  39594. * This can help limiting how the Camera is able to move in the scene.
  39595. */
  39596. upperRadiusLimit: Nullable<number>;
  39597. /**
  39598. * Define a rotation offset between the camera and the object it follows
  39599. */
  39600. rotationOffset: number;
  39601. /**
  39602. * Minimum allowed angle to camera position relative to target object.
  39603. * This can help limiting how the Camera is able to move in the scene.
  39604. */
  39605. lowerRotationOffsetLimit: Nullable<number>;
  39606. /**
  39607. * Maximum allowed angle to camera position relative to target object.
  39608. * This can help limiting how the Camera is able to move in the scene.
  39609. */
  39610. upperRotationOffsetLimit: Nullable<number>;
  39611. /**
  39612. * Define a height offset between the camera and the object it follows.
  39613. * It can help following an object from the top (like a car chaing a plane)
  39614. */
  39615. heightOffset: number;
  39616. /**
  39617. * Minimum allowed height of camera position relative to target object.
  39618. * This can help limiting how the Camera is able to move in the scene.
  39619. */
  39620. lowerHeightOffsetLimit: Nullable<number>;
  39621. /**
  39622. * Maximum allowed height of camera position relative to target object.
  39623. * This can help limiting how the Camera is able to move in the scene.
  39624. */
  39625. upperHeightOffsetLimit: Nullable<number>;
  39626. /**
  39627. * Define how fast the camera can accelerate to follow it s target.
  39628. */
  39629. cameraAcceleration: number;
  39630. /**
  39631. * Define the speed limit of the camera following an object.
  39632. */
  39633. maxCameraSpeed: number;
  39634. /**
  39635. * Define the target of the camera.
  39636. */
  39637. lockedTarget: Nullable<AbstractMesh>;
  39638. /**
  39639. * Defines the input associated with the camera.
  39640. */
  39641. inputs: FollowCameraInputsManager;
  39642. /**
  39643. * Instantiates the follow camera.
  39644. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39645. * @param name Define the name of the camera in the scene
  39646. * @param position Define the position of the camera
  39647. * @param scene Define the scene the camera belong to
  39648. * @param lockedTarget Define the target of the camera
  39649. */
  39650. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39651. private _follow;
  39652. /**
  39653. * Attached controls to the current camera.
  39654. * @param element Defines the element the controls should be listened from
  39655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39656. */
  39657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39658. /**
  39659. * Detach the current controls from the camera.
  39660. * The camera will stop reacting to inputs.
  39661. * @param element Defines the element to stop listening the inputs from
  39662. */
  39663. detachControl(element: HTMLElement): void;
  39664. /** @hidden */
  39665. _checkInputs(): void;
  39666. private _checkLimits;
  39667. /**
  39668. * Gets the camera class name.
  39669. * @returns the class name
  39670. */
  39671. getClassName(): string;
  39672. }
  39673. /**
  39674. * Arc Rotate version of the follow camera.
  39675. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39676. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39677. */
  39678. export class ArcFollowCamera extends TargetCamera {
  39679. /** The longitudinal angle of the camera */
  39680. alpha: number;
  39681. /** The latitudinal angle of the camera */
  39682. beta: number;
  39683. /** The radius of the camera from its target */
  39684. radius: number;
  39685. /** Define the camera target (the messh it should follow) */
  39686. target: Nullable<AbstractMesh>;
  39687. private _cartesianCoordinates;
  39688. /**
  39689. * Instantiates a new ArcFollowCamera
  39690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39691. * @param name Define the name of the camera
  39692. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39693. * @param beta Define the rotation angle of the camera around the elevation axis
  39694. * @param radius Define the radius of the camera from its target point
  39695. * @param target Define the target of the camera
  39696. * @param scene Define the scene the camera belongs to
  39697. */
  39698. constructor(name: string,
  39699. /** The longitudinal angle of the camera */
  39700. alpha: number,
  39701. /** The latitudinal angle of the camera */
  39702. beta: number,
  39703. /** The radius of the camera from its target */
  39704. radius: number,
  39705. /** Define the camera target (the messh it should follow) */
  39706. target: Nullable<AbstractMesh>, scene: Scene);
  39707. private _follow;
  39708. /** @hidden */
  39709. _checkInputs(): void;
  39710. /**
  39711. * Returns the class name of the object.
  39712. * It is mostly used internally for serialization purposes.
  39713. */
  39714. getClassName(): string;
  39715. }
  39716. }
  39717. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39718. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39719. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39720. import { Nullable } from "babylonjs/types";
  39721. /**
  39722. * Manage the keyboard inputs to control the movement of a follow camera.
  39723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39724. */
  39725. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39726. /**
  39727. * Defines the camera the input is attached to.
  39728. */
  39729. camera: FollowCamera;
  39730. /**
  39731. * Defines the list of key codes associated with the up action (increase heightOffset)
  39732. */
  39733. keysHeightOffsetIncr: number[];
  39734. /**
  39735. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39736. */
  39737. keysHeightOffsetDecr: number[];
  39738. /**
  39739. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39740. */
  39741. keysHeightOffsetModifierAlt: boolean;
  39742. /**
  39743. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39744. */
  39745. keysHeightOffsetModifierCtrl: boolean;
  39746. /**
  39747. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39748. */
  39749. keysHeightOffsetModifierShift: boolean;
  39750. /**
  39751. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39752. */
  39753. keysRotationOffsetIncr: number[];
  39754. /**
  39755. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39756. */
  39757. keysRotationOffsetDecr: number[];
  39758. /**
  39759. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39760. */
  39761. keysRotationOffsetModifierAlt: boolean;
  39762. /**
  39763. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39764. */
  39765. keysRotationOffsetModifierCtrl: boolean;
  39766. /**
  39767. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39768. */
  39769. keysRotationOffsetModifierShift: boolean;
  39770. /**
  39771. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39772. */
  39773. keysRadiusIncr: number[];
  39774. /**
  39775. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39776. */
  39777. keysRadiusDecr: number[];
  39778. /**
  39779. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39780. */
  39781. keysRadiusModifierAlt: boolean;
  39782. /**
  39783. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39784. */
  39785. keysRadiusModifierCtrl: boolean;
  39786. /**
  39787. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39788. */
  39789. keysRadiusModifierShift: boolean;
  39790. /**
  39791. * Defines the rate of change of heightOffset.
  39792. */
  39793. heightSensibility: number;
  39794. /**
  39795. * Defines the rate of change of rotationOffset.
  39796. */
  39797. rotationSensibility: number;
  39798. /**
  39799. * Defines the rate of change of radius.
  39800. */
  39801. radiusSensibility: number;
  39802. private _keys;
  39803. private _ctrlPressed;
  39804. private _altPressed;
  39805. private _shiftPressed;
  39806. private _onCanvasBlurObserver;
  39807. private _onKeyboardObserver;
  39808. private _engine;
  39809. private _scene;
  39810. /**
  39811. * Attach the input controls to a specific dom element to get the input from.
  39812. * @param element Defines the element the controls should be listened from
  39813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39814. */
  39815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39816. /**
  39817. * Detach the current controls from the specified dom element.
  39818. * @param element Defines the element to stop listening the inputs from
  39819. */
  39820. detachControl(element: Nullable<HTMLElement>): void;
  39821. /**
  39822. * Update the current camera state depending on the inputs that have been used this frame.
  39823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39824. */
  39825. checkInputs(): void;
  39826. /**
  39827. * Gets the class name of the current input.
  39828. * @returns the class name
  39829. */
  39830. getClassName(): string;
  39831. /**
  39832. * Get the friendly name associated with the input class.
  39833. * @returns the input friendly name
  39834. */
  39835. getSimpleName(): string;
  39836. /**
  39837. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39838. * allow modification of the heightOffset value.
  39839. */
  39840. private _modifierHeightOffset;
  39841. /**
  39842. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39843. * allow modification of the rotationOffset value.
  39844. */
  39845. private _modifierRotationOffset;
  39846. /**
  39847. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39848. * allow modification of the radius value.
  39849. */
  39850. private _modifierRadius;
  39851. }
  39852. }
  39853. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39854. import { Nullable } from "babylonjs/types";
  39855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39857. import { Observable } from "babylonjs/Misc/observable";
  39858. module "babylonjs/Cameras/freeCameraInputsManager" {
  39859. interface FreeCameraInputsManager {
  39860. /**
  39861. * @hidden
  39862. */
  39863. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39864. /**
  39865. * Add orientation input support to the input manager.
  39866. * @returns the current input manager
  39867. */
  39868. addDeviceOrientation(): FreeCameraInputsManager;
  39869. }
  39870. }
  39871. /**
  39872. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39873. * Screen rotation is taken into account.
  39874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39875. */
  39876. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39877. private _camera;
  39878. private _screenOrientationAngle;
  39879. private _constantTranform;
  39880. private _screenQuaternion;
  39881. private _alpha;
  39882. private _beta;
  39883. private _gamma;
  39884. /**
  39885. * Can be used to detect if a device orientation sensor is availible on a device
  39886. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39887. * @returns a promise that will resolve on orientation change
  39888. */
  39889. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39890. /**
  39891. * @hidden
  39892. */
  39893. _onDeviceOrientationChangedObservable: Observable<void>;
  39894. /**
  39895. * Instantiates a new input
  39896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39897. */
  39898. constructor();
  39899. /**
  39900. * Define the camera controlled by the input.
  39901. */
  39902. camera: FreeCamera;
  39903. /**
  39904. * Attach the input controls to a specific dom element to get the input from.
  39905. * @param element Defines the element the controls should be listened from
  39906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39907. */
  39908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39909. private _orientationChanged;
  39910. private _deviceOrientation;
  39911. /**
  39912. * Detach the current controls from the specified dom element.
  39913. * @param element Defines the element to stop listening the inputs from
  39914. */
  39915. detachControl(element: Nullable<HTMLElement>): void;
  39916. /**
  39917. * Update the current camera state depending on the inputs that have been used this frame.
  39918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39919. */
  39920. checkInputs(): void;
  39921. /**
  39922. * Gets the class name of the current intput.
  39923. * @returns the class name
  39924. */
  39925. getClassName(): string;
  39926. /**
  39927. * Get the friendly name associated with the input class.
  39928. * @returns the input friendly name
  39929. */
  39930. getSimpleName(): string;
  39931. }
  39932. }
  39933. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39934. import { Nullable } from "babylonjs/types";
  39935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39937. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39938. /**
  39939. * Manage the gamepad inputs to control a free camera.
  39940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39941. */
  39942. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39943. /**
  39944. * Define the camera the input is attached to.
  39945. */
  39946. camera: FreeCamera;
  39947. /**
  39948. * Define the Gamepad controlling the input
  39949. */
  39950. gamepad: Nullable<Gamepad>;
  39951. /**
  39952. * Defines the gamepad rotation sensiblity.
  39953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39954. */
  39955. gamepadAngularSensibility: number;
  39956. /**
  39957. * Defines the gamepad move sensiblity.
  39958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39959. */
  39960. gamepadMoveSensibility: number;
  39961. private _yAxisScale;
  39962. /**
  39963. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39964. */
  39965. invertYAxis: boolean;
  39966. private _onGamepadConnectedObserver;
  39967. private _onGamepadDisconnectedObserver;
  39968. private _cameraTransform;
  39969. private _deltaTransform;
  39970. private _vector3;
  39971. private _vector2;
  39972. /**
  39973. * Attach the input controls to a specific dom element to get the input from.
  39974. * @param element Defines the element the controls should be listened from
  39975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39976. */
  39977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39978. /**
  39979. * Detach the current controls from the specified dom element.
  39980. * @param element Defines the element to stop listening the inputs from
  39981. */
  39982. detachControl(element: Nullable<HTMLElement>): void;
  39983. /**
  39984. * Update the current camera state depending on the inputs that have been used this frame.
  39985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39986. */
  39987. checkInputs(): void;
  39988. /**
  39989. * Gets the class name of the current intput.
  39990. * @returns the class name
  39991. */
  39992. getClassName(): string;
  39993. /**
  39994. * Get the friendly name associated with the input class.
  39995. * @returns the input friendly name
  39996. */
  39997. getSimpleName(): string;
  39998. }
  39999. }
  40000. declare module "babylonjs/Misc/virtualJoystick" {
  40001. import { Nullable } from "babylonjs/types";
  40002. import { Vector3 } from "babylonjs/Maths/math.vector";
  40003. /**
  40004. * Defines the potential axis of a Joystick
  40005. */
  40006. export enum JoystickAxis {
  40007. /** X axis */
  40008. X = 0,
  40009. /** Y axis */
  40010. Y = 1,
  40011. /** Z axis */
  40012. Z = 2
  40013. }
  40014. /**
  40015. * Class used to define virtual joystick (used in touch mode)
  40016. */
  40017. export class VirtualJoystick {
  40018. /**
  40019. * Gets or sets a boolean indicating that left and right values must be inverted
  40020. */
  40021. reverseLeftRight: boolean;
  40022. /**
  40023. * Gets or sets a boolean indicating that up and down values must be inverted
  40024. */
  40025. reverseUpDown: boolean;
  40026. /**
  40027. * Gets the offset value for the position (ie. the change of the position value)
  40028. */
  40029. deltaPosition: Vector3;
  40030. /**
  40031. * Gets a boolean indicating if the virtual joystick was pressed
  40032. */
  40033. pressed: boolean;
  40034. /**
  40035. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40036. */
  40037. static Canvas: Nullable<HTMLCanvasElement>;
  40038. private static _globalJoystickIndex;
  40039. private static vjCanvasContext;
  40040. private static vjCanvasWidth;
  40041. private static vjCanvasHeight;
  40042. private static halfWidth;
  40043. private _action;
  40044. private _axisTargetedByLeftAndRight;
  40045. private _axisTargetedByUpAndDown;
  40046. private _joystickSensibility;
  40047. private _inversedSensibility;
  40048. private _joystickPointerID;
  40049. private _joystickColor;
  40050. private _joystickPointerPos;
  40051. private _joystickPreviousPointerPos;
  40052. private _joystickPointerStartPos;
  40053. private _deltaJoystickVector;
  40054. private _leftJoystick;
  40055. private _touches;
  40056. private _onPointerDownHandlerRef;
  40057. private _onPointerMoveHandlerRef;
  40058. private _onPointerUpHandlerRef;
  40059. private _onResize;
  40060. /**
  40061. * Creates a new virtual joystick
  40062. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40063. */
  40064. constructor(leftJoystick?: boolean);
  40065. /**
  40066. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40067. * @param newJoystickSensibility defines the new sensibility
  40068. */
  40069. setJoystickSensibility(newJoystickSensibility: number): void;
  40070. private _onPointerDown;
  40071. private _onPointerMove;
  40072. private _onPointerUp;
  40073. /**
  40074. * Change the color of the virtual joystick
  40075. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40076. */
  40077. setJoystickColor(newColor: string): void;
  40078. /**
  40079. * Defines a callback to call when the joystick is touched
  40080. * @param action defines the callback
  40081. */
  40082. setActionOnTouch(action: () => any): void;
  40083. /**
  40084. * Defines which axis you'd like to control for left & right
  40085. * @param axis defines the axis to use
  40086. */
  40087. setAxisForLeftRight(axis: JoystickAxis): void;
  40088. /**
  40089. * Defines which axis you'd like to control for up & down
  40090. * @param axis defines the axis to use
  40091. */
  40092. setAxisForUpDown(axis: JoystickAxis): void;
  40093. private _drawVirtualJoystick;
  40094. /**
  40095. * Release internal HTML canvas
  40096. */
  40097. releaseCanvas(): void;
  40098. }
  40099. }
  40100. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40101. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40102. import { Nullable } from "babylonjs/types";
  40103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40104. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40105. module "babylonjs/Cameras/freeCameraInputsManager" {
  40106. interface FreeCameraInputsManager {
  40107. /**
  40108. * Add virtual joystick input support to the input manager.
  40109. * @returns the current input manager
  40110. */
  40111. addVirtualJoystick(): FreeCameraInputsManager;
  40112. }
  40113. }
  40114. /**
  40115. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40117. */
  40118. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40119. /**
  40120. * Defines the camera the input is attached to.
  40121. */
  40122. camera: FreeCamera;
  40123. private _leftjoystick;
  40124. private _rightjoystick;
  40125. /**
  40126. * Gets the left stick of the virtual joystick.
  40127. * @returns The virtual Joystick
  40128. */
  40129. getLeftJoystick(): VirtualJoystick;
  40130. /**
  40131. * Gets the right stick of the virtual joystick.
  40132. * @returns The virtual Joystick
  40133. */
  40134. getRightJoystick(): VirtualJoystick;
  40135. /**
  40136. * Update the current camera state depending on the inputs that have been used this frame.
  40137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40138. */
  40139. checkInputs(): void;
  40140. /**
  40141. * Attach the input controls to a specific dom element to get the input from.
  40142. * @param element Defines the element the controls should be listened from
  40143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40144. */
  40145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40146. /**
  40147. * Detach the current controls from the specified dom element.
  40148. * @param element Defines the element to stop listening the inputs from
  40149. */
  40150. detachControl(element: Nullable<HTMLElement>): void;
  40151. /**
  40152. * Gets the class name of the current intput.
  40153. * @returns the class name
  40154. */
  40155. getClassName(): string;
  40156. /**
  40157. * Get the friendly name associated with the input class.
  40158. * @returns the input friendly name
  40159. */
  40160. getSimpleName(): string;
  40161. }
  40162. }
  40163. declare module "babylonjs/Cameras/Inputs/index" {
  40164. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40165. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40166. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40167. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40168. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40169. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40170. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40171. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40172. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40173. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40174. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40175. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40176. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40177. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40178. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40179. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40180. }
  40181. declare module "babylonjs/Cameras/touchCamera" {
  40182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40183. import { Scene } from "babylonjs/scene";
  40184. import { Vector3 } from "babylonjs/Maths/math.vector";
  40185. /**
  40186. * This represents a FPS type of camera controlled by touch.
  40187. * This is like a universal camera minus the Gamepad controls.
  40188. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40189. */
  40190. export class TouchCamera extends FreeCamera {
  40191. /**
  40192. * Defines the touch sensibility for rotation.
  40193. * The higher the faster.
  40194. */
  40195. touchAngularSensibility: number;
  40196. /**
  40197. * Defines the touch sensibility for move.
  40198. * The higher the faster.
  40199. */
  40200. touchMoveSensibility: number;
  40201. /**
  40202. * Instantiates a new touch camera.
  40203. * This represents a FPS type of camera controlled by touch.
  40204. * This is like a universal camera minus the Gamepad controls.
  40205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40206. * @param name Define the name of the camera in the scene
  40207. * @param position Define the start position of the camera in the scene
  40208. * @param scene Define the scene the camera belongs to
  40209. */
  40210. constructor(name: string, position: Vector3, scene: Scene);
  40211. /**
  40212. * Gets the current object class name.
  40213. * @return the class name
  40214. */
  40215. getClassName(): string;
  40216. /** @hidden */
  40217. _setupInputs(): void;
  40218. }
  40219. }
  40220. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40221. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40222. import { Scene } from "babylonjs/scene";
  40223. import { Vector3 } from "babylonjs/Maths/math.vector";
  40224. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40225. import { Axis } from "babylonjs/Maths/math.axis";
  40226. /**
  40227. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40228. * being tilted forward or back and left or right.
  40229. */
  40230. export class DeviceOrientationCamera extends FreeCamera {
  40231. private _initialQuaternion;
  40232. private _quaternionCache;
  40233. private _tmpDragQuaternion;
  40234. private _disablePointerInputWhenUsingDeviceOrientation;
  40235. /**
  40236. * Creates a new device orientation camera
  40237. * @param name The name of the camera
  40238. * @param position The start position camera
  40239. * @param scene The scene the camera belongs to
  40240. */
  40241. constructor(name: string, position: Vector3, scene: Scene);
  40242. /**
  40243. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40244. */
  40245. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40246. private _dragFactor;
  40247. /**
  40248. * Enabled turning on the y axis when the orientation sensor is active
  40249. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40250. */
  40251. enableHorizontalDragging(dragFactor?: number): void;
  40252. /**
  40253. * Gets the current instance class name ("DeviceOrientationCamera").
  40254. * This helps avoiding instanceof at run time.
  40255. * @returns the class name
  40256. */
  40257. getClassName(): string;
  40258. /**
  40259. * @hidden
  40260. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40261. */
  40262. _checkInputs(): void;
  40263. /**
  40264. * Reset the camera to its default orientation on the specified axis only.
  40265. * @param axis The axis to reset
  40266. */
  40267. resetToCurrentRotation(axis?: Axis): void;
  40268. }
  40269. }
  40270. declare module "babylonjs/Gamepads/xboxGamepad" {
  40271. import { Observable } from "babylonjs/Misc/observable";
  40272. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40273. /**
  40274. * Defines supported buttons for XBox360 compatible gamepads
  40275. */
  40276. export enum Xbox360Button {
  40277. /** A */
  40278. A = 0,
  40279. /** B */
  40280. B = 1,
  40281. /** X */
  40282. X = 2,
  40283. /** Y */
  40284. Y = 3,
  40285. /** Start */
  40286. Start = 4,
  40287. /** Back */
  40288. Back = 5,
  40289. /** Left button */
  40290. LB = 6,
  40291. /** Right button */
  40292. RB = 7,
  40293. /** Left stick */
  40294. LeftStick = 8,
  40295. /** Right stick */
  40296. RightStick = 9
  40297. }
  40298. /** Defines values for XBox360 DPad */
  40299. export enum Xbox360Dpad {
  40300. /** Up */
  40301. Up = 0,
  40302. /** Down */
  40303. Down = 1,
  40304. /** Left */
  40305. Left = 2,
  40306. /** Right */
  40307. Right = 3
  40308. }
  40309. /**
  40310. * Defines a XBox360 gamepad
  40311. */
  40312. export class Xbox360Pad extends Gamepad {
  40313. private _leftTrigger;
  40314. private _rightTrigger;
  40315. private _onlefttriggerchanged;
  40316. private _onrighttriggerchanged;
  40317. private _onbuttondown;
  40318. private _onbuttonup;
  40319. private _ondpaddown;
  40320. private _ondpadup;
  40321. /** Observable raised when a button is pressed */
  40322. onButtonDownObservable: Observable<Xbox360Button>;
  40323. /** Observable raised when a button is released */
  40324. onButtonUpObservable: Observable<Xbox360Button>;
  40325. /** Observable raised when a pad is pressed */
  40326. onPadDownObservable: Observable<Xbox360Dpad>;
  40327. /** Observable raised when a pad is released */
  40328. onPadUpObservable: Observable<Xbox360Dpad>;
  40329. private _buttonA;
  40330. private _buttonB;
  40331. private _buttonX;
  40332. private _buttonY;
  40333. private _buttonBack;
  40334. private _buttonStart;
  40335. private _buttonLB;
  40336. private _buttonRB;
  40337. private _buttonLeftStick;
  40338. private _buttonRightStick;
  40339. private _dPadUp;
  40340. private _dPadDown;
  40341. private _dPadLeft;
  40342. private _dPadRight;
  40343. private _isXboxOnePad;
  40344. /**
  40345. * Creates a new XBox360 gamepad object
  40346. * @param id defines the id of this gamepad
  40347. * @param index defines its index
  40348. * @param gamepad defines the internal HTML gamepad object
  40349. * @param xboxOne defines if it is a XBox One gamepad
  40350. */
  40351. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40352. /**
  40353. * Defines the callback to call when left trigger is pressed
  40354. * @param callback defines the callback to use
  40355. */
  40356. onlefttriggerchanged(callback: (value: number) => void): void;
  40357. /**
  40358. * Defines the callback to call when right trigger is pressed
  40359. * @param callback defines the callback to use
  40360. */
  40361. onrighttriggerchanged(callback: (value: number) => void): void;
  40362. /**
  40363. * Gets the left trigger value
  40364. */
  40365. /**
  40366. * Sets the left trigger value
  40367. */
  40368. leftTrigger: number;
  40369. /**
  40370. * Gets the right trigger value
  40371. */
  40372. /**
  40373. * Sets the right trigger value
  40374. */
  40375. rightTrigger: number;
  40376. /**
  40377. * Defines the callback to call when a button is pressed
  40378. * @param callback defines the callback to use
  40379. */
  40380. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40381. /**
  40382. * Defines the callback to call when a button is released
  40383. * @param callback defines the callback to use
  40384. */
  40385. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40386. /**
  40387. * Defines the callback to call when a pad is pressed
  40388. * @param callback defines the callback to use
  40389. */
  40390. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40391. /**
  40392. * Defines the callback to call when a pad is released
  40393. * @param callback defines the callback to use
  40394. */
  40395. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40396. private _setButtonValue;
  40397. private _setDPadValue;
  40398. /**
  40399. * Gets the value of the `A` button
  40400. */
  40401. /**
  40402. * Sets the value of the `A` button
  40403. */
  40404. buttonA: number;
  40405. /**
  40406. * Gets the value of the `B` button
  40407. */
  40408. /**
  40409. * Sets the value of the `B` button
  40410. */
  40411. buttonB: number;
  40412. /**
  40413. * Gets the value of the `X` button
  40414. */
  40415. /**
  40416. * Sets the value of the `X` button
  40417. */
  40418. buttonX: number;
  40419. /**
  40420. * Gets the value of the `Y` button
  40421. */
  40422. /**
  40423. * Sets the value of the `Y` button
  40424. */
  40425. buttonY: number;
  40426. /**
  40427. * Gets the value of the `Start` button
  40428. */
  40429. /**
  40430. * Sets the value of the `Start` button
  40431. */
  40432. buttonStart: number;
  40433. /**
  40434. * Gets the value of the `Back` button
  40435. */
  40436. /**
  40437. * Sets the value of the `Back` button
  40438. */
  40439. buttonBack: number;
  40440. /**
  40441. * Gets the value of the `Left` button
  40442. */
  40443. /**
  40444. * Sets the value of the `Left` button
  40445. */
  40446. buttonLB: number;
  40447. /**
  40448. * Gets the value of the `Right` button
  40449. */
  40450. /**
  40451. * Sets the value of the `Right` button
  40452. */
  40453. buttonRB: number;
  40454. /**
  40455. * Gets the value of the Left joystick
  40456. */
  40457. /**
  40458. * Sets the value of the Left joystick
  40459. */
  40460. buttonLeftStick: number;
  40461. /**
  40462. * Gets the value of the Right joystick
  40463. */
  40464. /**
  40465. * Sets the value of the Right joystick
  40466. */
  40467. buttonRightStick: number;
  40468. /**
  40469. * Gets the value of D-pad up
  40470. */
  40471. /**
  40472. * Sets the value of D-pad up
  40473. */
  40474. dPadUp: number;
  40475. /**
  40476. * Gets the value of D-pad down
  40477. */
  40478. /**
  40479. * Sets the value of D-pad down
  40480. */
  40481. dPadDown: number;
  40482. /**
  40483. * Gets the value of D-pad left
  40484. */
  40485. /**
  40486. * Sets the value of D-pad left
  40487. */
  40488. dPadLeft: number;
  40489. /**
  40490. * Gets the value of D-pad right
  40491. */
  40492. /**
  40493. * Sets the value of D-pad right
  40494. */
  40495. dPadRight: number;
  40496. /**
  40497. * Force the gamepad to synchronize with device values
  40498. */
  40499. update(): void;
  40500. /**
  40501. * Disposes the gamepad
  40502. */
  40503. dispose(): void;
  40504. }
  40505. }
  40506. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40507. import { Observable } from "babylonjs/Misc/observable";
  40508. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40509. /**
  40510. * Defines supported buttons for DualShock compatible gamepads
  40511. */
  40512. export enum DualShockButton {
  40513. /** Cross */
  40514. Cross = 0,
  40515. /** Circle */
  40516. Circle = 1,
  40517. /** Square */
  40518. Square = 2,
  40519. /** Triangle */
  40520. Triangle = 3,
  40521. /** Options */
  40522. Options = 4,
  40523. /** Share */
  40524. Share = 5,
  40525. /** L1 */
  40526. L1 = 6,
  40527. /** R1 */
  40528. R1 = 7,
  40529. /** Left stick */
  40530. LeftStick = 8,
  40531. /** Right stick */
  40532. RightStick = 9
  40533. }
  40534. /** Defines values for DualShock DPad */
  40535. export enum DualShockDpad {
  40536. /** Up */
  40537. Up = 0,
  40538. /** Down */
  40539. Down = 1,
  40540. /** Left */
  40541. Left = 2,
  40542. /** Right */
  40543. Right = 3
  40544. }
  40545. /**
  40546. * Defines a DualShock gamepad
  40547. */
  40548. export class DualShockPad extends Gamepad {
  40549. private _leftTrigger;
  40550. private _rightTrigger;
  40551. private _onlefttriggerchanged;
  40552. private _onrighttriggerchanged;
  40553. private _onbuttondown;
  40554. private _onbuttonup;
  40555. private _ondpaddown;
  40556. private _ondpadup;
  40557. /** Observable raised when a button is pressed */
  40558. onButtonDownObservable: Observable<DualShockButton>;
  40559. /** Observable raised when a button is released */
  40560. onButtonUpObservable: Observable<DualShockButton>;
  40561. /** Observable raised when a pad is pressed */
  40562. onPadDownObservable: Observable<DualShockDpad>;
  40563. /** Observable raised when a pad is released */
  40564. onPadUpObservable: Observable<DualShockDpad>;
  40565. private _buttonCross;
  40566. private _buttonCircle;
  40567. private _buttonSquare;
  40568. private _buttonTriangle;
  40569. private _buttonShare;
  40570. private _buttonOptions;
  40571. private _buttonL1;
  40572. private _buttonR1;
  40573. private _buttonLeftStick;
  40574. private _buttonRightStick;
  40575. private _dPadUp;
  40576. private _dPadDown;
  40577. private _dPadLeft;
  40578. private _dPadRight;
  40579. /**
  40580. * Creates a new DualShock gamepad object
  40581. * @param id defines the id of this gamepad
  40582. * @param index defines its index
  40583. * @param gamepad defines the internal HTML gamepad object
  40584. */
  40585. constructor(id: string, index: number, gamepad: any);
  40586. /**
  40587. * Defines the callback to call when left trigger is pressed
  40588. * @param callback defines the callback to use
  40589. */
  40590. onlefttriggerchanged(callback: (value: number) => void): void;
  40591. /**
  40592. * Defines the callback to call when right trigger is pressed
  40593. * @param callback defines the callback to use
  40594. */
  40595. onrighttriggerchanged(callback: (value: number) => void): void;
  40596. /**
  40597. * Gets the left trigger value
  40598. */
  40599. /**
  40600. * Sets the left trigger value
  40601. */
  40602. leftTrigger: number;
  40603. /**
  40604. * Gets the right trigger value
  40605. */
  40606. /**
  40607. * Sets the right trigger value
  40608. */
  40609. rightTrigger: number;
  40610. /**
  40611. * Defines the callback to call when a button is pressed
  40612. * @param callback defines the callback to use
  40613. */
  40614. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40615. /**
  40616. * Defines the callback to call when a button is released
  40617. * @param callback defines the callback to use
  40618. */
  40619. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40620. /**
  40621. * Defines the callback to call when a pad is pressed
  40622. * @param callback defines the callback to use
  40623. */
  40624. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40625. /**
  40626. * Defines the callback to call when a pad is released
  40627. * @param callback defines the callback to use
  40628. */
  40629. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40630. private _setButtonValue;
  40631. private _setDPadValue;
  40632. /**
  40633. * Gets the value of the `Cross` button
  40634. */
  40635. /**
  40636. * Sets the value of the `Cross` button
  40637. */
  40638. buttonCross: number;
  40639. /**
  40640. * Gets the value of the `Circle` button
  40641. */
  40642. /**
  40643. * Sets the value of the `Circle` button
  40644. */
  40645. buttonCircle: number;
  40646. /**
  40647. * Gets the value of the `Square` button
  40648. */
  40649. /**
  40650. * Sets the value of the `Square` button
  40651. */
  40652. buttonSquare: number;
  40653. /**
  40654. * Gets the value of the `Triangle` button
  40655. */
  40656. /**
  40657. * Sets the value of the `Triangle` button
  40658. */
  40659. buttonTriangle: number;
  40660. /**
  40661. * Gets the value of the `Options` button
  40662. */
  40663. /**
  40664. * Sets the value of the `Options` button
  40665. */
  40666. buttonOptions: number;
  40667. /**
  40668. * Gets the value of the `Share` button
  40669. */
  40670. /**
  40671. * Sets the value of the `Share` button
  40672. */
  40673. buttonShare: number;
  40674. /**
  40675. * Gets the value of the `L1` button
  40676. */
  40677. /**
  40678. * Sets the value of the `L1` button
  40679. */
  40680. buttonL1: number;
  40681. /**
  40682. * Gets the value of the `R1` button
  40683. */
  40684. /**
  40685. * Sets the value of the `R1` button
  40686. */
  40687. buttonR1: number;
  40688. /**
  40689. * Gets the value of the Left joystick
  40690. */
  40691. /**
  40692. * Sets the value of the Left joystick
  40693. */
  40694. buttonLeftStick: number;
  40695. /**
  40696. * Gets the value of the Right joystick
  40697. */
  40698. /**
  40699. * Sets the value of the Right joystick
  40700. */
  40701. buttonRightStick: number;
  40702. /**
  40703. * Gets the value of D-pad up
  40704. */
  40705. /**
  40706. * Sets the value of D-pad up
  40707. */
  40708. dPadUp: number;
  40709. /**
  40710. * Gets the value of D-pad down
  40711. */
  40712. /**
  40713. * Sets the value of D-pad down
  40714. */
  40715. dPadDown: number;
  40716. /**
  40717. * Gets the value of D-pad left
  40718. */
  40719. /**
  40720. * Sets the value of D-pad left
  40721. */
  40722. dPadLeft: number;
  40723. /**
  40724. * Gets the value of D-pad right
  40725. */
  40726. /**
  40727. * Sets the value of D-pad right
  40728. */
  40729. dPadRight: number;
  40730. /**
  40731. * Force the gamepad to synchronize with device values
  40732. */
  40733. update(): void;
  40734. /**
  40735. * Disposes the gamepad
  40736. */
  40737. dispose(): void;
  40738. }
  40739. }
  40740. declare module "babylonjs/Gamepads/gamepadManager" {
  40741. import { Observable } from "babylonjs/Misc/observable";
  40742. import { Nullable } from "babylonjs/types";
  40743. import { Scene } from "babylonjs/scene";
  40744. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40745. /**
  40746. * Manager for handling gamepads
  40747. */
  40748. export class GamepadManager {
  40749. private _scene?;
  40750. private _babylonGamepads;
  40751. private _oneGamepadConnected;
  40752. /** @hidden */
  40753. _isMonitoring: boolean;
  40754. private _gamepadEventSupported;
  40755. private _gamepadSupport;
  40756. /**
  40757. * observable to be triggered when the gamepad controller has been connected
  40758. */
  40759. onGamepadConnectedObservable: Observable<Gamepad>;
  40760. /**
  40761. * observable to be triggered when the gamepad controller has been disconnected
  40762. */
  40763. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40764. private _onGamepadConnectedEvent;
  40765. private _onGamepadDisconnectedEvent;
  40766. /**
  40767. * Initializes the gamepad manager
  40768. * @param _scene BabylonJS scene
  40769. */
  40770. constructor(_scene?: Scene | undefined);
  40771. /**
  40772. * The gamepads in the game pad manager
  40773. */
  40774. readonly gamepads: Gamepad[];
  40775. /**
  40776. * Get the gamepad controllers based on type
  40777. * @param type The type of gamepad controller
  40778. * @returns Nullable gamepad
  40779. */
  40780. getGamepadByType(type?: number): Nullable<Gamepad>;
  40781. /**
  40782. * Disposes the gamepad manager
  40783. */
  40784. dispose(): void;
  40785. private _addNewGamepad;
  40786. private _startMonitoringGamepads;
  40787. private _stopMonitoringGamepads;
  40788. /** @hidden */
  40789. _checkGamepadsStatus(): void;
  40790. private _updateGamepadObjects;
  40791. }
  40792. }
  40793. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40794. import { Nullable } from "babylonjs/types";
  40795. import { Scene } from "babylonjs/scene";
  40796. import { ISceneComponent } from "babylonjs/sceneComponent";
  40797. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40798. module "babylonjs/scene" {
  40799. interface Scene {
  40800. /** @hidden */
  40801. _gamepadManager: Nullable<GamepadManager>;
  40802. /**
  40803. * Gets the gamepad manager associated with the scene
  40804. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40805. */
  40806. gamepadManager: GamepadManager;
  40807. }
  40808. }
  40809. module "babylonjs/Cameras/freeCameraInputsManager" {
  40810. /**
  40811. * Interface representing a free camera inputs manager
  40812. */
  40813. interface FreeCameraInputsManager {
  40814. /**
  40815. * Adds gamepad input support to the FreeCameraInputsManager.
  40816. * @returns the FreeCameraInputsManager
  40817. */
  40818. addGamepad(): FreeCameraInputsManager;
  40819. }
  40820. }
  40821. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40822. /**
  40823. * Interface representing an arc rotate camera inputs manager
  40824. */
  40825. interface ArcRotateCameraInputsManager {
  40826. /**
  40827. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40828. * @returns the camera inputs manager
  40829. */
  40830. addGamepad(): ArcRotateCameraInputsManager;
  40831. }
  40832. }
  40833. /**
  40834. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40835. */
  40836. export class GamepadSystemSceneComponent implements ISceneComponent {
  40837. /**
  40838. * The component name helpfull to identify the component in the list of scene components.
  40839. */
  40840. readonly name: string;
  40841. /**
  40842. * The scene the component belongs to.
  40843. */
  40844. scene: Scene;
  40845. /**
  40846. * Creates a new instance of the component for the given scene
  40847. * @param scene Defines the scene to register the component in
  40848. */
  40849. constructor(scene: Scene);
  40850. /**
  40851. * Registers the component in a given scene
  40852. */
  40853. register(): void;
  40854. /**
  40855. * Rebuilds the elements related to this component in case of
  40856. * context lost for instance.
  40857. */
  40858. rebuild(): void;
  40859. /**
  40860. * Disposes the component and the associated ressources
  40861. */
  40862. dispose(): void;
  40863. private _beforeCameraUpdate;
  40864. }
  40865. }
  40866. declare module "babylonjs/Cameras/universalCamera" {
  40867. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40868. import { Scene } from "babylonjs/scene";
  40869. import { Vector3 } from "babylonjs/Maths/math.vector";
  40870. import "babylonjs/Gamepads/gamepadSceneComponent";
  40871. /**
  40872. * 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,
  40873. * which still works and will still be found in many Playgrounds.
  40874. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40875. */
  40876. export class UniversalCamera extends TouchCamera {
  40877. /**
  40878. * Defines the gamepad rotation sensiblity.
  40879. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40880. */
  40881. gamepadAngularSensibility: number;
  40882. /**
  40883. * Defines the gamepad move sensiblity.
  40884. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40885. */
  40886. gamepadMoveSensibility: number;
  40887. /**
  40888. * 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,
  40889. * which still works and will still be found in many Playgrounds.
  40890. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40891. * @param name Define the name of the camera in the scene
  40892. * @param position Define the start position of the camera in the scene
  40893. * @param scene Define the scene the camera belongs to
  40894. */
  40895. constructor(name: string, position: Vector3, scene: Scene);
  40896. /**
  40897. * Gets the current object class name.
  40898. * @return the class name
  40899. */
  40900. getClassName(): string;
  40901. }
  40902. }
  40903. declare module "babylonjs/Cameras/gamepadCamera" {
  40904. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40905. import { Scene } from "babylonjs/scene";
  40906. import { Vector3 } from "babylonjs/Maths/math.vector";
  40907. /**
  40908. * This represents a FPS type of camera. This is only here for back compat purpose.
  40909. * Please use the UniversalCamera instead as both are identical.
  40910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40911. */
  40912. export class GamepadCamera extends UniversalCamera {
  40913. /**
  40914. * Instantiates a new Gamepad Camera
  40915. * This represents a FPS type of camera. This is only here for back compat purpose.
  40916. * Please use the UniversalCamera instead as both are identical.
  40917. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40918. * @param name Define the name of the camera in the scene
  40919. * @param position Define the start position of the camera in the scene
  40920. * @param scene Define the scene the camera belongs to
  40921. */
  40922. constructor(name: string, position: Vector3, scene: Scene);
  40923. /**
  40924. * Gets the current object class name.
  40925. * @return the class name
  40926. */
  40927. getClassName(): string;
  40928. }
  40929. }
  40930. declare module "babylonjs/Shaders/pass.fragment" {
  40931. /** @hidden */
  40932. export var passPixelShader: {
  40933. name: string;
  40934. shader: string;
  40935. };
  40936. }
  40937. declare module "babylonjs/Shaders/passCube.fragment" {
  40938. /** @hidden */
  40939. export var passCubePixelShader: {
  40940. name: string;
  40941. shader: string;
  40942. };
  40943. }
  40944. declare module "babylonjs/PostProcesses/passPostProcess" {
  40945. import { Nullable } from "babylonjs/types";
  40946. import { Camera } from "babylonjs/Cameras/camera";
  40947. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40948. import { Engine } from "babylonjs/Engines/engine";
  40949. import "babylonjs/Shaders/pass.fragment";
  40950. import "babylonjs/Shaders/passCube.fragment";
  40951. /**
  40952. * PassPostProcess which produces an output the same as it's input
  40953. */
  40954. export class PassPostProcess extends PostProcess {
  40955. /**
  40956. * Creates the PassPostProcess
  40957. * @param name The name of the effect.
  40958. * @param options The required width/height ratio to downsize to before computing the render pass.
  40959. * @param camera The camera to apply the render pass to.
  40960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40961. * @param engine The engine which the post process will be applied. (default: current engine)
  40962. * @param reusable If the post process can be reused on the same frame. (default: false)
  40963. * @param textureType The type of texture to be used when performing the post processing.
  40964. * @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)
  40965. */
  40966. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40967. }
  40968. /**
  40969. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40970. */
  40971. export class PassCubePostProcess extends PostProcess {
  40972. private _face;
  40973. /**
  40974. * Gets or sets the cube face to display.
  40975. * * 0 is +X
  40976. * * 1 is -X
  40977. * * 2 is +Y
  40978. * * 3 is -Y
  40979. * * 4 is +Z
  40980. * * 5 is -Z
  40981. */
  40982. face: number;
  40983. /**
  40984. * Creates the PassCubePostProcess
  40985. * @param name The name of the effect.
  40986. * @param options The required width/height ratio to downsize to before computing the render pass.
  40987. * @param camera The camera to apply the render pass to.
  40988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40989. * @param engine The engine which the post process will be applied. (default: current engine)
  40990. * @param reusable If the post process can be reused on the same frame. (default: false)
  40991. * @param textureType The type of texture to be used when performing the post processing.
  40992. * @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)
  40993. */
  40994. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40995. }
  40996. }
  40997. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40998. /** @hidden */
  40999. export var anaglyphPixelShader: {
  41000. name: string;
  41001. shader: string;
  41002. };
  41003. }
  41004. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41005. import { Engine } from "babylonjs/Engines/engine";
  41006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41007. import { Camera } from "babylonjs/Cameras/camera";
  41008. import "babylonjs/Shaders/anaglyph.fragment";
  41009. /**
  41010. * Postprocess used to generate anaglyphic rendering
  41011. */
  41012. export class AnaglyphPostProcess extends PostProcess {
  41013. private _passedProcess;
  41014. /**
  41015. * Creates a new AnaglyphPostProcess
  41016. * @param name defines postprocess name
  41017. * @param options defines creation options or target ratio scale
  41018. * @param rigCameras defines cameras using this postprocess
  41019. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41020. * @param engine defines hosting engine
  41021. * @param reusable defines if the postprocess will be reused multiple times per frame
  41022. */
  41023. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41024. }
  41025. }
  41026. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41027. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41028. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41029. import { Scene } from "babylonjs/scene";
  41030. import { Vector3 } from "babylonjs/Maths/math.vector";
  41031. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41032. /**
  41033. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41034. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41035. */
  41036. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41037. /**
  41038. * Creates a new AnaglyphArcRotateCamera
  41039. * @param name defines camera name
  41040. * @param alpha defines alpha angle (in radians)
  41041. * @param beta defines beta angle (in radians)
  41042. * @param radius defines radius
  41043. * @param target defines camera target
  41044. * @param interaxialDistance defines distance between each color axis
  41045. * @param scene defines the hosting scene
  41046. */
  41047. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41048. /**
  41049. * Gets camera class name
  41050. * @returns AnaglyphArcRotateCamera
  41051. */
  41052. getClassName(): string;
  41053. }
  41054. }
  41055. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41057. import { Scene } from "babylonjs/scene";
  41058. import { Vector3 } from "babylonjs/Maths/math.vector";
  41059. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41060. /**
  41061. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41062. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41063. */
  41064. export class AnaglyphFreeCamera extends FreeCamera {
  41065. /**
  41066. * Creates a new AnaglyphFreeCamera
  41067. * @param name defines camera name
  41068. * @param position defines initial position
  41069. * @param interaxialDistance defines distance between each color axis
  41070. * @param scene defines the hosting scene
  41071. */
  41072. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41073. /**
  41074. * Gets camera class name
  41075. * @returns AnaglyphFreeCamera
  41076. */
  41077. getClassName(): string;
  41078. }
  41079. }
  41080. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41081. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41082. import { Scene } from "babylonjs/scene";
  41083. import { Vector3 } from "babylonjs/Maths/math.vector";
  41084. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41085. /**
  41086. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41087. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41088. */
  41089. export class AnaglyphGamepadCamera extends GamepadCamera {
  41090. /**
  41091. * Creates a new AnaglyphGamepadCamera
  41092. * @param name defines camera name
  41093. * @param position defines initial position
  41094. * @param interaxialDistance defines distance between each color axis
  41095. * @param scene defines the hosting scene
  41096. */
  41097. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41098. /**
  41099. * Gets camera class name
  41100. * @returns AnaglyphGamepadCamera
  41101. */
  41102. getClassName(): string;
  41103. }
  41104. }
  41105. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41106. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41107. import { Scene } from "babylonjs/scene";
  41108. import { Vector3 } from "babylonjs/Maths/math.vector";
  41109. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41110. /**
  41111. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41112. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41113. */
  41114. export class AnaglyphUniversalCamera extends UniversalCamera {
  41115. /**
  41116. * Creates a new AnaglyphUniversalCamera
  41117. * @param name defines camera name
  41118. * @param position defines initial position
  41119. * @param interaxialDistance defines distance between each color axis
  41120. * @param scene defines the hosting scene
  41121. */
  41122. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41123. /**
  41124. * Gets camera class name
  41125. * @returns AnaglyphUniversalCamera
  41126. */
  41127. getClassName(): string;
  41128. }
  41129. }
  41130. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41131. /** @hidden */
  41132. export var stereoscopicInterlacePixelShader: {
  41133. name: string;
  41134. shader: string;
  41135. };
  41136. }
  41137. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41138. import { Camera } from "babylonjs/Cameras/camera";
  41139. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41140. import { Engine } from "babylonjs/Engines/engine";
  41141. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41142. /**
  41143. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41144. */
  41145. export class StereoscopicInterlacePostProcess extends PostProcess {
  41146. private _stepSize;
  41147. private _passedProcess;
  41148. /**
  41149. * Initializes a StereoscopicInterlacePostProcess
  41150. * @param name The name of the effect.
  41151. * @param rigCameras The rig cameras to be appled to the post process
  41152. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41154. * @param engine The engine which the post process will be applied. (default: current engine)
  41155. * @param reusable If the post process can be reused on the same frame. (default: false)
  41156. */
  41157. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41158. }
  41159. }
  41160. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41161. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41162. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41163. import { Scene } from "babylonjs/scene";
  41164. import { Vector3 } from "babylonjs/Maths/math.vector";
  41165. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41166. /**
  41167. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41168. * @see http://doc.babylonjs.com/features/cameras
  41169. */
  41170. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41171. /**
  41172. * Creates a new StereoscopicArcRotateCamera
  41173. * @param name defines camera name
  41174. * @param alpha defines alpha angle (in radians)
  41175. * @param beta defines beta angle (in radians)
  41176. * @param radius defines radius
  41177. * @param target defines camera target
  41178. * @param interaxialDistance defines distance between each color axis
  41179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41180. * @param scene defines the hosting scene
  41181. */
  41182. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41183. /**
  41184. * Gets camera class name
  41185. * @returns StereoscopicArcRotateCamera
  41186. */
  41187. getClassName(): string;
  41188. }
  41189. }
  41190. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41191. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41192. import { Scene } from "babylonjs/scene";
  41193. import { Vector3 } from "babylonjs/Maths/math.vector";
  41194. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41195. /**
  41196. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41197. * @see http://doc.babylonjs.com/features/cameras
  41198. */
  41199. export class StereoscopicFreeCamera extends FreeCamera {
  41200. /**
  41201. * Creates a new StereoscopicFreeCamera
  41202. * @param name defines camera name
  41203. * @param position defines initial position
  41204. * @param interaxialDistance defines distance between each color axis
  41205. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41206. * @param scene defines the hosting scene
  41207. */
  41208. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41209. /**
  41210. * Gets camera class name
  41211. * @returns StereoscopicFreeCamera
  41212. */
  41213. getClassName(): string;
  41214. }
  41215. }
  41216. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41217. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41218. import { Scene } from "babylonjs/scene";
  41219. import { Vector3 } from "babylonjs/Maths/math.vector";
  41220. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41221. /**
  41222. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41223. * @see http://doc.babylonjs.com/features/cameras
  41224. */
  41225. export class StereoscopicGamepadCamera extends GamepadCamera {
  41226. /**
  41227. * Creates a new StereoscopicGamepadCamera
  41228. * @param name defines camera name
  41229. * @param position defines initial position
  41230. * @param interaxialDistance defines distance between each color axis
  41231. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41232. * @param scene defines the hosting scene
  41233. */
  41234. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41235. /**
  41236. * Gets camera class name
  41237. * @returns StereoscopicGamepadCamera
  41238. */
  41239. getClassName(): string;
  41240. }
  41241. }
  41242. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41243. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41244. import { Scene } from "babylonjs/scene";
  41245. import { Vector3 } from "babylonjs/Maths/math.vector";
  41246. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41247. /**
  41248. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41249. * @see http://doc.babylonjs.com/features/cameras
  41250. */
  41251. export class StereoscopicUniversalCamera extends UniversalCamera {
  41252. /**
  41253. * Creates a new StereoscopicUniversalCamera
  41254. * @param name defines camera name
  41255. * @param position defines initial position
  41256. * @param interaxialDistance defines distance between each color axis
  41257. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41258. * @param scene defines the hosting scene
  41259. */
  41260. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41261. /**
  41262. * Gets camera class name
  41263. * @returns StereoscopicUniversalCamera
  41264. */
  41265. getClassName(): string;
  41266. }
  41267. }
  41268. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41269. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41270. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41271. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41272. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41273. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41274. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41275. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41276. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41277. }
  41278. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41279. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41280. import { Scene } from "babylonjs/scene";
  41281. import { Vector3 } from "babylonjs/Maths/math.vector";
  41282. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41283. /**
  41284. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41285. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41286. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41287. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41288. */
  41289. export class VirtualJoysticksCamera extends FreeCamera {
  41290. /**
  41291. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41292. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41293. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41294. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41295. * @param name Define the name of the camera in the scene
  41296. * @param position Define the start position of the camera in the scene
  41297. * @param scene Define the scene the camera belongs to
  41298. */
  41299. constructor(name: string, position: Vector3, scene: Scene);
  41300. /**
  41301. * Gets the current object class name.
  41302. * @return the class name
  41303. */
  41304. getClassName(): string;
  41305. }
  41306. }
  41307. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41308. import { Matrix } from "babylonjs/Maths/math.vector";
  41309. /**
  41310. * This represents all the required metrics to create a VR camera.
  41311. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41312. */
  41313. export class VRCameraMetrics {
  41314. /**
  41315. * Define the horizontal resolution off the screen.
  41316. */
  41317. hResolution: number;
  41318. /**
  41319. * Define the vertical resolution off the screen.
  41320. */
  41321. vResolution: number;
  41322. /**
  41323. * Define the horizontal screen size.
  41324. */
  41325. hScreenSize: number;
  41326. /**
  41327. * Define the vertical screen size.
  41328. */
  41329. vScreenSize: number;
  41330. /**
  41331. * Define the vertical screen center position.
  41332. */
  41333. vScreenCenter: number;
  41334. /**
  41335. * Define the distance of the eyes to the screen.
  41336. */
  41337. eyeToScreenDistance: number;
  41338. /**
  41339. * Define the distance between both lenses
  41340. */
  41341. lensSeparationDistance: number;
  41342. /**
  41343. * Define the distance between both viewer's eyes.
  41344. */
  41345. interpupillaryDistance: number;
  41346. /**
  41347. * Define the distortion factor of the VR postprocess.
  41348. * Please, touch with care.
  41349. */
  41350. distortionK: number[];
  41351. /**
  41352. * Define the chromatic aberration correction factors for the VR post process.
  41353. */
  41354. chromaAbCorrection: number[];
  41355. /**
  41356. * Define the scale factor of the post process.
  41357. * The smaller the better but the slower.
  41358. */
  41359. postProcessScaleFactor: number;
  41360. /**
  41361. * Define an offset for the lens center.
  41362. */
  41363. lensCenterOffset: number;
  41364. /**
  41365. * Define if the current vr camera should compensate the distortion of the lense or not.
  41366. */
  41367. compensateDistortion: boolean;
  41368. /**
  41369. * Defines if multiview should be enabled when rendering (Default: false)
  41370. */
  41371. multiviewEnabled: boolean;
  41372. /**
  41373. * Gets the rendering aspect ratio based on the provided resolutions.
  41374. */
  41375. readonly aspectRatio: number;
  41376. /**
  41377. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41378. */
  41379. readonly aspectRatioFov: number;
  41380. /**
  41381. * @hidden
  41382. */
  41383. readonly leftHMatrix: Matrix;
  41384. /**
  41385. * @hidden
  41386. */
  41387. readonly rightHMatrix: Matrix;
  41388. /**
  41389. * @hidden
  41390. */
  41391. readonly leftPreViewMatrix: Matrix;
  41392. /**
  41393. * @hidden
  41394. */
  41395. readonly rightPreViewMatrix: Matrix;
  41396. /**
  41397. * Get the default VRMetrics based on the most generic setup.
  41398. * @returns the default vr metrics
  41399. */
  41400. static GetDefault(): VRCameraMetrics;
  41401. }
  41402. }
  41403. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41404. /** @hidden */
  41405. export var vrDistortionCorrectionPixelShader: {
  41406. name: string;
  41407. shader: string;
  41408. };
  41409. }
  41410. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41411. import { Camera } from "babylonjs/Cameras/camera";
  41412. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41413. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41414. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41415. /**
  41416. * VRDistortionCorrectionPostProcess used for mobile VR
  41417. */
  41418. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41419. private _isRightEye;
  41420. private _distortionFactors;
  41421. private _postProcessScaleFactor;
  41422. private _lensCenterOffset;
  41423. private _scaleIn;
  41424. private _scaleFactor;
  41425. private _lensCenter;
  41426. /**
  41427. * Initializes the VRDistortionCorrectionPostProcess
  41428. * @param name The name of the effect.
  41429. * @param camera The camera to apply the render pass to.
  41430. * @param isRightEye If this is for the right eye distortion
  41431. * @param vrMetrics All the required metrics for the VR camera
  41432. */
  41433. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41434. }
  41435. }
  41436. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41437. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41438. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41439. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41440. import { Scene } from "babylonjs/scene";
  41441. import { Vector3 } from "babylonjs/Maths/math.vector";
  41442. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41443. import "babylonjs/Cameras/RigModes/vrRigMode";
  41444. /**
  41445. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41446. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41447. */
  41448. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41449. /**
  41450. * Creates a new VRDeviceOrientationArcRotateCamera
  41451. * @param name defines camera name
  41452. * @param alpha defines the camera rotation along the logitudinal axis
  41453. * @param beta defines the camera rotation along the latitudinal axis
  41454. * @param radius defines the camera distance from its target
  41455. * @param target defines the camera target
  41456. * @param scene defines the scene the camera belongs to
  41457. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41458. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41459. */
  41460. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41461. /**
  41462. * Gets camera class name
  41463. * @returns VRDeviceOrientationArcRotateCamera
  41464. */
  41465. getClassName(): string;
  41466. }
  41467. }
  41468. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41469. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41470. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41471. import { Scene } from "babylonjs/scene";
  41472. import { Vector3 } from "babylonjs/Maths/math.vector";
  41473. import "babylonjs/Cameras/RigModes/vrRigMode";
  41474. /**
  41475. * Camera used to simulate VR rendering (based on FreeCamera)
  41476. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41477. */
  41478. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41479. /**
  41480. * Creates a new VRDeviceOrientationFreeCamera
  41481. * @param name defines camera name
  41482. * @param position defines the start position of the camera
  41483. * @param scene defines the scene the camera belongs to
  41484. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41485. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41486. */
  41487. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41488. /**
  41489. * Gets camera class name
  41490. * @returns VRDeviceOrientationFreeCamera
  41491. */
  41492. getClassName(): string;
  41493. }
  41494. }
  41495. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41496. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41497. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41498. import { Scene } from "babylonjs/scene";
  41499. import { Vector3 } from "babylonjs/Maths/math.vector";
  41500. import "babylonjs/Gamepads/gamepadSceneComponent";
  41501. /**
  41502. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41504. */
  41505. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41506. /**
  41507. * Creates a new VRDeviceOrientationGamepadCamera
  41508. * @param name defines camera name
  41509. * @param position defines the start position of the camera
  41510. * @param scene defines the scene the camera belongs to
  41511. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41512. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41513. */
  41514. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41515. /**
  41516. * Gets camera class name
  41517. * @returns VRDeviceOrientationGamepadCamera
  41518. */
  41519. getClassName(): string;
  41520. }
  41521. }
  41522. declare module "babylonjs/Materials/pushMaterial" {
  41523. import { Nullable } from "babylonjs/types";
  41524. import { Scene } from "babylonjs/scene";
  41525. import { Matrix } from "babylonjs/Maths/math.vector";
  41526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41527. import { Mesh } from "babylonjs/Meshes/mesh";
  41528. import { Material } from "babylonjs/Materials/material";
  41529. import { Effect } from "babylonjs/Materials/effect";
  41530. /**
  41531. * Base class of materials working in push mode in babylon JS
  41532. * @hidden
  41533. */
  41534. export class PushMaterial extends Material {
  41535. protected _activeEffect: Effect;
  41536. protected _normalMatrix: Matrix;
  41537. /**
  41538. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41539. * This means that the material can keep using a previous shader while a new one is being compiled.
  41540. * This is mostly used when shader parallel compilation is supported (true by default)
  41541. */
  41542. allowShaderHotSwapping: boolean;
  41543. constructor(name: string, scene: Scene);
  41544. getEffect(): Effect;
  41545. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41546. /**
  41547. * Binds the given world matrix to the active effect
  41548. *
  41549. * @param world the matrix to bind
  41550. */
  41551. bindOnlyWorldMatrix(world: Matrix): void;
  41552. /**
  41553. * Binds the given normal matrix to the active effect
  41554. *
  41555. * @param normalMatrix the matrix to bind
  41556. */
  41557. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41558. bind(world: Matrix, mesh?: Mesh): void;
  41559. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41560. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41561. }
  41562. }
  41563. declare module "babylonjs/Materials/materialFlags" {
  41564. /**
  41565. * This groups all the flags used to control the materials channel.
  41566. */
  41567. export class MaterialFlags {
  41568. private static _DiffuseTextureEnabled;
  41569. /**
  41570. * Are diffuse textures enabled in the application.
  41571. */
  41572. static DiffuseTextureEnabled: boolean;
  41573. private static _AmbientTextureEnabled;
  41574. /**
  41575. * Are ambient textures enabled in the application.
  41576. */
  41577. static AmbientTextureEnabled: boolean;
  41578. private static _OpacityTextureEnabled;
  41579. /**
  41580. * Are opacity textures enabled in the application.
  41581. */
  41582. static OpacityTextureEnabled: boolean;
  41583. private static _ReflectionTextureEnabled;
  41584. /**
  41585. * Are reflection textures enabled in the application.
  41586. */
  41587. static ReflectionTextureEnabled: boolean;
  41588. private static _EmissiveTextureEnabled;
  41589. /**
  41590. * Are emissive textures enabled in the application.
  41591. */
  41592. static EmissiveTextureEnabled: boolean;
  41593. private static _SpecularTextureEnabled;
  41594. /**
  41595. * Are specular textures enabled in the application.
  41596. */
  41597. static SpecularTextureEnabled: boolean;
  41598. private static _BumpTextureEnabled;
  41599. /**
  41600. * Are bump textures enabled in the application.
  41601. */
  41602. static BumpTextureEnabled: boolean;
  41603. private static _LightmapTextureEnabled;
  41604. /**
  41605. * Are lightmap textures enabled in the application.
  41606. */
  41607. static LightmapTextureEnabled: boolean;
  41608. private static _RefractionTextureEnabled;
  41609. /**
  41610. * Are refraction textures enabled in the application.
  41611. */
  41612. static RefractionTextureEnabled: boolean;
  41613. private static _ColorGradingTextureEnabled;
  41614. /**
  41615. * Are color grading textures enabled in the application.
  41616. */
  41617. static ColorGradingTextureEnabled: boolean;
  41618. private static _FresnelEnabled;
  41619. /**
  41620. * Are fresnels enabled in the application.
  41621. */
  41622. static FresnelEnabled: boolean;
  41623. private static _ClearCoatTextureEnabled;
  41624. /**
  41625. * Are clear coat textures enabled in the application.
  41626. */
  41627. static ClearCoatTextureEnabled: boolean;
  41628. private static _ClearCoatBumpTextureEnabled;
  41629. /**
  41630. * Are clear coat bump textures enabled in the application.
  41631. */
  41632. static ClearCoatBumpTextureEnabled: boolean;
  41633. private static _ClearCoatTintTextureEnabled;
  41634. /**
  41635. * Are clear coat tint textures enabled in the application.
  41636. */
  41637. static ClearCoatTintTextureEnabled: boolean;
  41638. private static _SheenTextureEnabled;
  41639. /**
  41640. * Are sheen textures enabled in the application.
  41641. */
  41642. static SheenTextureEnabled: boolean;
  41643. private static _AnisotropicTextureEnabled;
  41644. /**
  41645. * Are anisotropic textures enabled in the application.
  41646. */
  41647. static AnisotropicTextureEnabled: boolean;
  41648. private static _ThicknessTextureEnabled;
  41649. /**
  41650. * Are thickness textures enabled in the application.
  41651. */
  41652. static ThicknessTextureEnabled: boolean;
  41653. }
  41654. }
  41655. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41656. /** @hidden */
  41657. export var defaultFragmentDeclaration: {
  41658. name: string;
  41659. shader: string;
  41660. };
  41661. }
  41662. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41663. /** @hidden */
  41664. export var defaultUboDeclaration: {
  41665. name: string;
  41666. shader: string;
  41667. };
  41668. }
  41669. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41670. /** @hidden */
  41671. export var lightFragmentDeclaration: {
  41672. name: string;
  41673. shader: string;
  41674. };
  41675. }
  41676. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41677. /** @hidden */
  41678. export var lightUboDeclaration: {
  41679. name: string;
  41680. shader: string;
  41681. };
  41682. }
  41683. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41684. /** @hidden */
  41685. export var lightsFragmentFunctions: {
  41686. name: string;
  41687. shader: string;
  41688. };
  41689. }
  41690. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41691. /** @hidden */
  41692. export var shadowsFragmentFunctions: {
  41693. name: string;
  41694. shader: string;
  41695. };
  41696. }
  41697. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41698. /** @hidden */
  41699. export var fresnelFunction: {
  41700. name: string;
  41701. shader: string;
  41702. };
  41703. }
  41704. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41705. /** @hidden */
  41706. export var reflectionFunction: {
  41707. name: string;
  41708. shader: string;
  41709. };
  41710. }
  41711. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41712. /** @hidden */
  41713. export var bumpFragmentFunctions: {
  41714. name: string;
  41715. shader: string;
  41716. };
  41717. }
  41718. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41719. /** @hidden */
  41720. export var logDepthDeclaration: {
  41721. name: string;
  41722. shader: string;
  41723. };
  41724. }
  41725. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41726. /** @hidden */
  41727. export var bumpFragment: {
  41728. name: string;
  41729. shader: string;
  41730. };
  41731. }
  41732. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41733. /** @hidden */
  41734. export var depthPrePass: {
  41735. name: string;
  41736. shader: string;
  41737. };
  41738. }
  41739. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41740. /** @hidden */
  41741. export var lightFragment: {
  41742. name: string;
  41743. shader: string;
  41744. };
  41745. }
  41746. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41747. /** @hidden */
  41748. export var logDepthFragment: {
  41749. name: string;
  41750. shader: string;
  41751. };
  41752. }
  41753. declare module "babylonjs/Shaders/default.fragment" {
  41754. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41755. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41757. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41758. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41759. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41760. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41761. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41762. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41763. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41764. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41765. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41766. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41767. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41768. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41769. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41770. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41771. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41772. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41773. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41774. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41775. /** @hidden */
  41776. export var defaultPixelShader: {
  41777. name: string;
  41778. shader: string;
  41779. };
  41780. }
  41781. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41782. /** @hidden */
  41783. export var defaultVertexDeclaration: {
  41784. name: string;
  41785. shader: string;
  41786. };
  41787. }
  41788. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41789. /** @hidden */
  41790. export var bumpVertexDeclaration: {
  41791. name: string;
  41792. shader: string;
  41793. };
  41794. }
  41795. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41796. /** @hidden */
  41797. export var bumpVertex: {
  41798. name: string;
  41799. shader: string;
  41800. };
  41801. }
  41802. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41803. /** @hidden */
  41804. export var fogVertex: {
  41805. name: string;
  41806. shader: string;
  41807. };
  41808. }
  41809. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41810. /** @hidden */
  41811. export var shadowsVertex: {
  41812. name: string;
  41813. shader: string;
  41814. };
  41815. }
  41816. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41817. /** @hidden */
  41818. export var pointCloudVertex: {
  41819. name: string;
  41820. shader: string;
  41821. };
  41822. }
  41823. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41824. /** @hidden */
  41825. export var logDepthVertex: {
  41826. name: string;
  41827. shader: string;
  41828. };
  41829. }
  41830. declare module "babylonjs/Shaders/default.vertex" {
  41831. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41832. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41835. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41836. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41837. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41838. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41843. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41844. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41845. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41846. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41847. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41849. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41850. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41851. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41852. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41853. /** @hidden */
  41854. export var defaultVertexShader: {
  41855. name: string;
  41856. shader: string;
  41857. };
  41858. }
  41859. declare module "babylonjs/Materials/standardMaterial" {
  41860. import { SmartArray } from "babylonjs/Misc/smartArray";
  41861. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41862. import { Nullable } from "babylonjs/types";
  41863. import { Scene } from "babylonjs/scene";
  41864. import { Matrix } from "babylonjs/Maths/math.vector";
  41865. import { Color3 } from "babylonjs/Maths/math.color";
  41866. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41868. import { Mesh } from "babylonjs/Meshes/mesh";
  41869. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41870. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41871. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41872. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41873. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41876. import "babylonjs/Shaders/default.fragment";
  41877. import "babylonjs/Shaders/default.vertex";
  41878. /** @hidden */
  41879. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41880. MAINUV1: boolean;
  41881. MAINUV2: boolean;
  41882. DIFFUSE: boolean;
  41883. DIFFUSEDIRECTUV: number;
  41884. AMBIENT: boolean;
  41885. AMBIENTDIRECTUV: number;
  41886. OPACITY: boolean;
  41887. OPACITYDIRECTUV: number;
  41888. OPACITYRGB: boolean;
  41889. REFLECTION: boolean;
  41890. EMISSIVE: boolean;
  41891. EMISSIVEDIRECTUV: number;
  41892. SPECULAR: boolean;
  41893. SPECULARDIRECTUV: number;
  41894. BUMP: boolean;
  41895. BUMPDIRECTUV: number;
  41896. PARALLAX: boolean;
  41897. PARALLAXOCCLUSION: boolean;
  41898. SPECULAROVERALPHA: boolean;
  41899. CLIPPLANE: boolean;
  41900. CLIPPLANE2: boolean;
  41901. CLIPPLANE3: boolean;
  41902. CLIPPLANE4: boolean;
  41903. ALPHATEST: boolean;
  41904. DEPTHPREPASS: boolean;
  41905. ALPHAFROMDIFFUSE: boolean;
  41906. POINTSIZE: boolean;
  41907. FOG: boolean;
  41908. SPECULARTERM: boolean;
  41909. DIFFUSEFRESNEL: boolean;
  41910. OPACITYFRESNEL: boolean;
  41911. REFLECTIONFRESNEL: boolean;
  41912. REFRACTIONFRESNEL: boolean;
  41913. EMISSIVEFRESNEL: boolean;
  41914. FRESNEL: boolean;
  41915. NORMAL: boolean;
  41916. UV1: boolean;
  41917. UV2: boolean;
  41918. VERTEXCOLOR: boolean;
  41919. VERTEXALPHA: boolean;
  41920. NUM_BONE_INFLUENCERS: number;
  41921. BonesPerMesh: number;
  41922. BONETEXTURE: boolean;
  41923. INSTANCES: boolean;
  41924. GLOSSINESS: boolean;
  41925. ROUGHNESS: boolean;
  41926. EMISSIVEASILLUMINATION: boolean;
  41927. LINKEMISSIVEWITHDIFFUSE: boolean;
  41928. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41929. LIGHTMAP: boolean;
  41930. LIGHTMAPDIRECTUV: number;
  41931. OBJECTSPACE_NORMALMAP: boolean;
  41932. USELIGHTMAPASSHADOWMAP: boolean;
  41933. REFLECTIONMAP_3D: boolean;
  41934. REFLECTIONMAP_SPHERICAL: boolean;
  41935. REFLECTIONMAP_PLANAR: boolean;
  41936. REFLECTIONMAP_CUBIC: boolean;
  41937. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41938. REFLECTIONMAP_PROJECTION: boolean;
  41939. REFLECTIONMAP_SKYBOX: boolean;
  41940. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41941. REFLECTIONMAP_EXPLICIT: boolean;
  41942. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41943. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41944. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41945. INVERTCUBICMAP: boolean;
  41946. LOGARITHMICDEPTH: boolean;
  41947. REFRACTION: boolean;
  41948. REFRACTIONMAP_3D: boolean;
  41949. REFLECTIONOVERALPHA: boolean;
  41950. TWOSIDEDLIGHTING: boolean;
  41951. SHADOWFLOAT: boolean;
  41952. MORPHTARGETS: boolean;
  41953. MORPHTARGETS_NORMAL: boolean;
  41954. MORPHTARGETS_TANGENT: boolean;
  41955. MORPHTARGETS_UV: boolean;
  41956. NUM_MORPH_INFLUENCERS: number;
  41957. NONUNIFORMSCALING: boolean;
  41958. PREMULTIPLYALPHA: boolean;
  41959. IMAGEPROCESSING: boolean;
  41960. VIGNETTE: boolean;
  41961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41962. VIGNETTEBLENDMODEOPAQUE: boolean;
  41963. TONEMAPPING: boolean;
  41964. TONEMAPPING_ACES: boolean;
  41965. CONTRAST: boolean;
  41966. COLORCURVES: boolean;
  41967. COLORGRADING: boolean;
  41968. COLORGRADING3D: boolean;
  41969. SAMPLER3DGREENDEPTH: boolean;
  41970. SAMPLER3DBGRMAP: boolean;
  41971. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41972. MULTIVIEW: boolean;
  41973. /**
  41974. * If the reflection texture on this material is in linear color space
  41975. * @hidden
  41976. */
  41977. IS_REFLECTION_LINEAR: boolean;
  41978. /**
  41979. * If the refraction texture on this material is in linear color space
  41980. * @hidden
  41981. */
  41982. IS_REFRACTION_LINEAR: boolean;
  41983. EXPOSURE: boolean;
  41984. constructor();
  41985. setReflectionMode(modeToEnable: string): void;
  41986. }
  41987. /**
  41988. * This is the default material used in Babylon. It is the best trade off between quality
  41989. * and performances.
  41990. * @see http://doc.babylonjs.com/babylon101/materials
  41991. */
  41992. export class StandardMaterial extends PushMaterial {
  41993. private _diffuseTexture;
  41994. /**
  41995. * The basic texture of the material as viewed under a light.
  41996. */
  41997. diffuseTexture: Nullable<BaseTexture>;
  41998. private _ambientTexture;
  41999. /**
  42000. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42001. */
  42002. ambientTexture: Nullable<BaseTexture>;
  42003. private _opacityTexture;
  42004. /**
  42005. * Define the transparency of the material from a texture.
  42006. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42007. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42008. */
  42009. opacityTexture: Nullable<BaseTexture>;
  42010. private _reflectionTexture;
  42011. /**
  42012. * Define the texture used to display the reflection.
  42013. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42014. */
  42015. reflectionTexture: Nullable<BaseTexture>;
  42016. private _emissiveTexture;
  42017. /**
  42018. * Define texture of the material as if self lit.
  42019. * This will be mixed in the final result even in the absence of light.
  42020. */
  42021. emissiveTexture: Nullable<BaseTexture>;
  42022. private _specularTexture;
  42023. /**
  42024. * Define how the color and intensity of the highlight given by the light in the material.
  42025. */
  42026. specularTexture: Nullable<BaseTexture>;
  42027. private _bumpTexture;
  42028. /**
  42029. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42030. * 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.
  42031. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42032. */
  42033. bumpTexture: Nullable<BaseTexture>;
  42034. private _lightmapTexture;
  42035. /**
  42036. * Complex lighting can be computationally expensive to compute at runtime.
  42037. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42038. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42039. */
  42040. lightmapTexture: Nullable<BaseTexture>;
  42041. private _refractionTexture;
  42042. /**
  42043. * Define the texture used to display the refraction.
  42044. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42045. */
  42046. refractionTexture: Nullable<BaseTexture>;
  42047. /**
  42048. * The color of the material lit by the environmental background lighting.
  42049. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42050. */
  42051. ambientColor: Color3;
  42052. /**
  42053. * The basic color of the material as viewed under a light.
  42054. */
  42055. diffuseColor: Color3;
  42056. /**
  42057. * Define how the color and intensity of the highlight given by the light in the material.
  42058. */
  42059. specularColor: Color3;
  42060. /**
  42061. * Define the color of the material as if self lit.
  42062. * This will be mixed in the final result even in the absence of light.
  42063. */
  42064. emissiveColor: Color3;
  42065. /**
  42066. * Defines how sharp are the highlights in the material.
  42067. * The bigger the value the sharper giving a more glossy feeling to the result.
  42068. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42069. */
  42070. specularPower: number;
  42071. private _useAlphaFromDiffuseTexture;
  42072. /**
  42073. * Does the transparency come from the diffuse texture alpha channel.
  42074. */
  42075. useAlphaFromDiffuseTexture: boolean;
  42076. private _useEmissiveAsIllumination;
  42077. /**
  42078. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42079. */
  42080. useEmissiveAsIllumination: boolean;
  42081. private _linkEmissiveWithDiffuse;
  42082. /**
  42083. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42084. * the emissive level when the final color is close to one.
  42085. */
  42086. linkEmissiveWithDiffuse: boolean;
  42087. private _useSpecularOverAlpha;
  42088. /**
  42089. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42090. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42091. */
  42092. useSpecularOverAlpha: boolean;
  42093. private _useReflectionOverAlpha;
  42094. /**
  42095. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42096. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42097. */
  42098. useReflectionOverAlpha: boolean;
  42099. private _disableLighting;
  42100. /**
  42101. * Does lights from the scene impacts this material.
  42102. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42103. */
  42104. disableLighting: boolean;
  42105. private _useObjectSpaceNormalMap;
  42106. /**
  42107. * Allows using an object space normal map (instead of tangent space).
  42108. */
  42109. useObjectSpaceNormalMap: boolean;
  42110. private _useParallax;
  42111. /**
  42112. * Is parallax enabled or not.
  42113. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42114. */
  42115. useParallax: boolean;
  42116. private _useParallaxOcclusion;
  42117. /**
  42118. * Is parallax occlusion enabled or not.
  42119. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42120. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42121. */
  42122. useParallaxOcclusion: boolean;
  42123. /**
  42124. * 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.
  42125. */
  42126. parallaxScaleBias: number;
  42127. private _roughness;
  42128. /**
  42129. * Helps to define how blurry the reflections should appears in the material.
  42130. */
  42131. roughness: number;
  42132. /**
  42133. * In case of refraction, define the value of the index of refraction.
  42134. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42135. */
  42136. indexOfRefraction: number;
  42137. /**
  42138. * Invert the refraction texture alongside the y axis.
  42139. * It can be useful with procedural textures or probe for instance.
  42140. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42141. */
  42142. invertRefractionY: boolean;
  42143. /**
  42144. * Defines the alpha limits in alpha test mode.
  42145. */
  42146. alphaCutOff: number;
  42147. private _useLightmapAsShadowmap;
  42148. /**
  42149. * In case of light mapping, define whether the map contains light or shadow informations.
  42150. */
  42151. useLightmapAsShadowmap: boolean;
  42152. private _diffuseFresnelParameters;
  42153. /**
  42154. * Define the diffuse fresnel parameters of the material.
  42155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42156. */
  42157. diffuseFresnelParameters: FresnelParameters;
  42158. private _opacityFresnelParameters;
  42159. /**
  42160. * Define the opacity fresnel parameters of the material.
  42161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42162. */
  42163. opacityFresnelParameters: FresnelParameters;
  42164. private _reflectionFresnelParameters;
  42165. /**
  42166. * Define the reflection fresnel parameters of the material.
  42167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42168. */
  42169. reflectionFresnelParameters: FresnelParameters;
  42170. private _refractionFresnelParameters;
  42171. /**
  42172. * Define the refraction fresnel parameters of the material.
  42173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42174. */
  42175. refractionFresnelParameters: FresnelParameters;
  42176. private _emissiveFresnelParameters;
  42177. /**
  42178. * Define the emissive fresnel parameters of the material.
  42179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42180. */
  42181. emissiveFresnelParameters: FresnelParameters;
  42182. private _useReflectionFresnelFromSpecular;
  42183. /**
  42184. * If true automatically deducts the fresnels values from the material specularity.
  42185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42186. */
  42187. useReflectionFresnelFromSpecular: boolean;
  42188. private _useGlossinessFromSpecularMapAlpha;
  42189. /**
  42190. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42191. */
  42192. useGlossinessFromSpecularMapAlpha: boolean;
  42193. private _maxSimultaneousLights;
  42194. /**
  42195. * Defines the maximum number of lights that can be used in the material
  42196. */
  42197. maxSimultaneousLights: number;
  42198. private _invertNormalMapX;
  42199. /**
  42200. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42201. */
  42202. invertNormalMapX: boolean;
  42203. private _invertNormalMapY;
  42204. /**
  42205. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42206. */
  42207. invertNormalMapY: boolean;
  42208. private _twoSidedLighting;
  42209. /**
  42210. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42211. */
  42212. twoSidedLighting: boolean;
  42213. /**
  42214. * Default configuration related to image processing available in the standard Material.
  42215. */
  42216. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42217. /**
  42218. * Gets the image processing configuration used either in this material.
  42219. */
  42220. /**
  42221. * Sets the Default image processing configuration used either in the this material.
  42222. *
  42223. * If sets to null, the scene one is in use.
  42224. */
  42225. imageProcessingConfiguration: ImageProcessingConfiguration;
  42226. /**
  42227. * Keep track of the image processing observer to allow dispose and replace.
  42228. */
  42229. private _imageProcessingObserver;
  42230. /**
  42231. * Attaches a new image processing configuration to the Standard Material.
  42232. * @param configuration
  42233. */
  42234. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42235. /**
  42236. * Gets wether the color curves effect is enabled.
  42237. */
  42238. /**
  42239. * Sets wether the color curves effect is enabled.
  42240. */
  42241. cameraColorCurvesEnabled: boolean;
  42242. /**
  42243. * Gets wether the color grading effect is enabled.
  42244. */
  42245. /**
  42246. * Gets wether the color grading effect is enabled.
  42247. */
  42248. cameraColorGradingEnabled: boolean;
  42249. /**
  42250. * Gets wether tonemapping is enabled or not.
  42251. */
  42252. /**
  42253. * Sets wether tonemapping is enabled or not
  42254. */
  42255. cameraToneMappingEnabled: boolean;
  42256. /**
  42257. * The camera exposure used on this material.
  42258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42259. * This corresponds to a photographic exposure.
  42260. */
  42261. /**
  42262. * The camera exposure used on this material.
  42263. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42264. * This corresponds to a photographic exposure.
  42265. */
  42266. cameraExposure: number;
  42267. /**
  42268. * Gets The camera contrast used on this material.
  42269. */
  42270. /**
  42271. * Sets The camera contrast used on this material.
  42272. */
  42273. cameraContrast: number;
  42274. /**
  42275. * Gets the Color Grading 2D Lookup Texture.
  42276. */
  42277. /**
  42278. * Sets the Color Grading 2D Lookup Texture.
  42279. */
  42280. cameraColorGradingTexture: Nullable<BaseTexture>;
  42281. /**
  42282. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42283. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42284. * 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;
  42285. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42286. */
  42287. /**
  42288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42290. * 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;
  42291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42292. */
  42293. cameraColorCurves: Nullable<ColorCurves>;
  42294. /**
  42295. * Custom callback helping to override the default shader used in the material.
  42296. */
  42297. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42298. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42299. protected _worldViewProjectionMatrix: Matrix;
  42300. protected _globalAmbientColor: Color3;
  42301. protected _useLogarithmicDepth: boolean;
  42302. protected _rebuildInParallel: boolean;
  42303. /**
  42304. * Instantiates a new standard material.
  42305. * This is the default material used in Babylon. It is the best trade off between quality
  42306. * and performances.
  42307. * @see http://doc.babylonjs.com/babylon101/materials
  42308. * @param name Define the name of the material in the scene
  42309. * @param scene Define the scene the material belong to
  42310. */
  42311. constructor(name: string, scene: Scene);
  42312. /**
  42313. * Gets a boolean indicating that current material needs to register RTT
  42314. */
  42315. readonly hasRenderTargetTextures: boolean;
  42316. /**
  42317. * Gets the current class name of the material e.g. "StandardMaterial"
  42318. * Mainly use in serialization.
  42319. * @returns the class name
  42320. */
  42321. getClassName(): string;
  42322. /**
  42323. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42324. * You can try switching to logarithmic depth.
  42325. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42326. */
  42327. useLogarithmicDepth: boolean;
  42328. /**
  42329. * Specifies if the material will require alpha blending
  42330. * @returns a boolean specifying if alpha blending is needed
  42331. */
  42332. needAlphaBlending(): boolean;
  42333. /**
  42334. * Specifies if this material should be rendered in alpha test mode
  42335. * @returns a boolean specifying if an alpha test is needed.
  42336. */
  42337. needAlphaTesting(): boolean;
  42338. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42339. /**
  42340. * Get the texture used for alpha test purpose.
  42341. * @returns the diffuse texture in case of the standard material.
  42342. */
  42343. getAlphaTestTexture(): Nullable<BaseTexture>;
  42344. /**
  42345. * Get if the submesh is ready to be used and all its information available.
  42346. * Child classes can use it to update shaders
  42347. * @param mesh defines the mesh to check
  42348. * @param subMesh defines which submesh to check
  42349. * @param useInstances specifies that instances should be used
  42350. * @returns a boolean indicating that the submesh is ready or not
  42351. */
  42352. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42353. /**
  42354. * Builds the material UBO layouts.
  42355. * Used internally during the effect preparation.
  42356. */
  42357. buildUniformLayout(): void;
  42358. /**
  42359. * Unbinds the material from the mesh
  42360. */
  42361. unbind(): void;
  42362. /**
  42363. * Binds the submesh to this material by preparing the effect and shader to draw
  42364. * @param world defines the world transformation matrix
  42365. * @param mesh defines the mesh containing the submesh
  42366. * @param subMesh defines the submesh to bind the material to
  42367. */
  42368. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42369. /**
  42370. * Get the list of animatables in the material.
  42371. * @returns the list of animatables object used in the material
  42372. */
  42373. getAnimatables(): IAnimatable[];
  42374. /**
  42375. * Gets the active textures from the material
  42376. * @returns an array of textures
  42377. */
  42378. getActiveTextures(): BaseTexture[];
  42379. /**
  42380. * Specifies if the material uses a texture
  42381. * @param texture defines the texture to check against the material
  42382. * @returns a boolean specifying if the material uses the texture
  42383. */
  42384. hasTexture(texture: BaseTexture): boolean;
  42385. /**
  42386. * Disposes the material
  42387. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42388. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42389. */
  42390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42391. /**
  42392. * Makes a duplicate of the material, and gives it a new name
  42393. * @param name defines the new name for the duplicated material
  42394. * @returns the cloned material
  42395. */
  42396. clone(name: string): StandardMaterial;
  42397. /**
  42398. * Serializes this material in a JSON representation
  42399. * @returns the serialized material object
  42400. */
  42401. serialize(): any;
  42402. /**
  42403. * Creates a standard material from parsed material data
  42404. * @param source defines the JSON representation of the material
  42405. * @param scene defines the hosting scene
  42406. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42407. * @returns a new standard material
  42408. */
  42409. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42410. /**
  42411. * Are diffuse textures enabled in the application.
  42412. */
  42413. static DiffuseTextureEnabled: boolean;
  42414. /**
  42415. * Are ambient textures enabled in the application.
  42416. */
  42417. static AmbientTextureEnabled: boolean;
  42418. /**
  42419. * Are opacity textures enabled in the application.
  42420. */
  42421. static OpacityTextureEnabled: boolean;
  42422. /**
  42423. * Are reflection textures enabled in the application.
  42424. */
  42425. static ReflectionTextureEnabled: boolean;
  42426. /**
  42427. * Are emissive textures enabled in the application.
  42428. */
  42429. static EmissiveTextureEnabled: boolean;
  42430. /**
  42431. * Are specular textures enabled in the application.
  42432. */
  42433. static SpecularTextureEnabled: boolean;
  42434. /**
  42435. * Are bump textures enabled in the application.
  42436. */
  42437. static BumpTextureEnabled: boolean;
  42438. /**
  42439. * Are lightmap textures enabled in the application.
  42440. */
  42441. static LightmapTextureEnabled: boolean;
  42442. /**
  42443. * Are refraction textures enabled in the application.
  42444. */
  42445. static RefractionTextureEnabled: boolean;
  42446. /**
  42447. * Are color grading textures enabled in the application.
  42448. */
  42449. static ColorGradingTextureEnabled: boolean;
  42450. /**
  42451. * Are fresnels enabled in the application.
  42452. */
  42453. static FresnelEnabled: boolean;
  42454. }
  42455. }
  42456. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42457. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42458. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42459. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42460. /** @hidden */
  42461. export var imageProcessingPixelShader: {
  42462. name: string;
  42463. shader: string;
  42464. };
  42465. }
  42466. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42467. import { Nullable } from "babylonjs/types";
  42468. import { Color4 } from "babylonjs/Maths/math.color";
  42469. import { Camera } from "babylonjs/Cameras/camera";
  42470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42471. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42472. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42474. import { Engine } from "babylonjs/Engines/engine";
  42475. import "babylonjs/Shaders/imageProcessing.fragment";
  42476. import "babylonjs/Shaders/postprocess.vertex";
  42477. /**
  42478. * ImageProcessingPostProcess
  42479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42480. */
  42481. export class ImageProcessingPostProcess extends PostProcess {
  42482. /**
  42483. * Default configuration related to image processing available in the PBR Material.
  42484. */
  42485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42486. /**
  42487. * Gets the image processing configuration used either in this material.
  42488. */
  42489. /**
  42490. * Sets the Default image processing configuration used either in the this material.
  42491. *
  42492. * If sets to null, the scene one is in use.
  42493. */
  42494. imageProcessingConfiguration: ImageProcessingConfiguration;
  42495. /**
  42496. * Keep track of the image processing observer to allow dispose and replace.
  42497. */
  42498. private _imageProcessingObserver;
  42499. /**
  42500. * Attaches a new image processing configuration to the PBR Material.
  42501. * @param configuration
  42502. */
  42503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42504. /**
  42505. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42506. */
  42507. /**
  42508. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42509. */
  42510. colorCurves: Nullable<ColorCurves>;
  42511. /**
  42512. * Gets wether the color curves effect is enabled.
  42513. */
  42514. /**
  42515. * Sets wether the color curves effect is enabled.
  42516. */
  42517. colorCurvesEnabled: boolean;
  42518. /**
  42519. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42520. */
  42521. /**
  42522. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42523. */
  42524. colorGradingTexture: Nullable<BaseTexture>;
  42525. /**
  42526. * Gets wether the color grading effect is enabled.
  42527. */
  42528. /**
  42529. * Gets wether the color grading effect is enabled.
  42530. */
  42531. colorGradingEnabled: boolean;
  42532. /**
  42533. * Gets exposure used in the effect.
  42534. */
  42535. /**
  42536. * Sets exposure used in the effect.
  42537. */
  42538. exposure: number;
  42539. /**
  42540. * Gets wether tonemapping is enabled or not.
  42541. */
  42542. /**
  42543. * Sets wether tonemapping is enabled or not
  42544. */
  42545. toneMappingEnabled: boolean;
  42546. /**
  42547. * Gets the type of tone mapping effect.
  42548. */
  42549. /**
  42550. * Sets the type of tone mapping effect.
  42551. */
  42552. toneMappingType: number;
  42553. /**
  42554. * Gets contrast used in the effect.
  42555. */
  42556. /**
  42557. * Sets contrast used in the effect.
  42558. */
  42559. contrast: number;
  42560. /**
  42561. * Gets Vignette stretch size.
  42562. */
  42563. /**
  42564. * Sets Vignette stretch size.
  42565. */
  42566. vignetteStretch: number;
  42567. /**
  42568. * Gets Vignette centre X Offset.
  42569. */
  42570. /**
  42571. * Sets Vignette centre X Offset.
  42572. */
  42573. vignetteCentreX: number;
  42574. /**
  42575. * Gets Vignette centre Y Offset.
  42576. */
  42577. /**
  42578. * Sets Vignette centre Y Offset.
  42579. */
  42580. vignetteCentreY: number;
  42581. /**
  42582. * Gets Vignette weight or intensity of the vignette effect.
  42583. */
  42584. /**
  42585. * Sets Vignette weight or intensity of the vignette effect.
  42586. */
  42587. vignetteWeight: number;
  42588. /**
  42589. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42590. * if vignetteEnabled is set to true.
  42591. */
  42592. /**
  42593. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42594. * if vignetteEnabled is set to true.
  42595. */
  42596. vignetteColor: Color4;
  42597. /**
  42598. * Gets Camera field of view used by the Vignette effect.
  42599. */
  42600. /**
  42601. * Sets Camera field of view used by the Vignette effect.
  42602. */
  42603. vignetteCameraFov: number;
  42604. /**
  42605. * Gets the vignette blend mode allowing different kind of effect.
  42606. */
  42607. /**
  42608. * Sets the vignette blend mode allowing different kind of effect.
  42609. */
  42610. vignetteBlendMode: number;
  42611. /**
  42612. * Gets wether the vignette effect is enabled.
  42613. */
  42614. /**
  42615. * Sets wether the vignette effect is enabled.
  42616. */
  42617. vignetteEnabled: boolean;
  42618. private _fromLinearSpace;
  42619. /**
  42620. * Gets wether the input of the processing is in Gamma or Linear Space.
  42621. */
  42622. /**
  42623. * Sets wether the input of the processing is in Gamma or Linear Space.
  42624. */
  42625. fromLinearSpace: boolean;
  42626. /**
  42627. * Defines cache preventing GC.
  42628. */
  42629. private _defines;
  42630. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42631. /**
  42632. * "ImageProcessingPostProcess"
  42633. * @returns "ImageProcessingPostProcess"
  42634. */
  42635. getClassName(): string;
  42636. protected _updateParameters(): void;
  42637. dispose(camera?: Camera): void;
  42638. }
  42639. }
  42640. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42641. import { Scene } from "babylonjs/scene";
  42642. import { Color3 } from "babylonjs/Maths/math.color";
  42643. import { Mesh } from "babylonjs/Meshes/mesh";
  42644. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42645. import { Nullable } from "babylonjs/types";
  42646. /**
  42647. * Class containing static functions to help procedurally build meshes
  42648. */
  42649. export class GroundBuilder {
  42650. /**
  42651. * Creates a ground mesh
  42652. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42653. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42655. * @param name defines the name of the mesh
  42656. * @param options defines the options used to create the mesh
  42657. * @param scene defines the hosting scene
  42658. * @returns the ground mesh
  42659. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42660. */
  42661. static CreateGround(name: string, options: {
  42662. width?: number;
  42663. height?: number;
  42664. subdivisions?: number;
  42665. subdivisionsX?: number;
  42666. subdivisionsY?: number;
  42667. updatable?: boolean;
  42668. }, scene: any): Mesh;
  42669. /**
  42670. * Creates a tiled ground mesh
  42671. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42672. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42673. * * 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
  42674. * * 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
  42675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42676. * @param name defines the name of the mesh
  42677. * @param options defines the options used to create the mesh
  42678. * @param scene defines the hosting scene
  42679. * @returns the tiled ground mesh
  42680. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42681. */
  42682. static CreateTiledGround(name: string, options: {
  42683. xmin: number;
  42684. zmin: number;
  42685. xmax: number;
  42686. zmax: number;
  42687. subdivisions?: {
  42688. w: number;
  42689. h: number;
  42690. };
  42691. precision?: {
  42692. w: number;
  42693. h: number;
  42694. };
  42695. updatable?: boolean;
  42696. }, scene?: Nullable<Scene>): Mesh;
  42697. /**
  42698. * Creates a ground mesh from a height map
  42699. * * The parameter `url` sets the URL of the height map image resource.
  42700. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42701. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42702. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42703. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42704. * * 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.
  42705. * * 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).
  42706. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42708. * @param name defines the name of the mesh
  42709. * @param url defines the url to the height map
  42710. * @param options defines the options used to create the mesh
  42711. * @param scene defines the hosting scene
  42712. * @returns the ground mesh
  42713. * @see https://doc.babylonjs.com/babylon101/height_map
  42714. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42715. */
  42716. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42717. width?: number;
  42718. height?: number;
  42719. subdivisions?: number;
  42720. minHeight?: number;
  42721. maxHeight?: number;
  42722. colorFilter?: Color3;
  42723. alphaFilter?: number;
  42724. updatable?: boolean;
  42725. onReady?: (mesh: GroundMesh) => void;
  42726. }, scene?: Nullable<Scene>): GroundMesh;
  42727. }
  42728. }
  42729. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42730. import { Vector4 } from "babylonjs/Maths/math.vector";
  42731. import { Mesh } from "babylonjs/Meshes/mesh";
  42732. /**
  42733. * Class containing static functions to help procedurally build meshes
  42734. */
  42735. export class TorusBuilder {
  42736. /**
  42737. * Creates a torus mesh
  42738. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42739. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42740. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42744. * @param name defines the name of the mesh
  42745. * @param options defines the options used to create the mesh
  42746. * @param scene defines the hosting scene
  42747. * @returns the torus mesh
  42748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42749. */
  42750. static CreateTorus(name: string, options: {
  42751. diameter?: number;
  42752. thickness?: number;
  42753. tessellation?: number;
  42754. updatable?: boolean;
  42755. sideOrientation?: number;
  42756. frontUVs?: Vector4;
  42757. backUVs?: Vector4;
  42758. }, scene: any): Mesh;
  42759. }
  42760. }
  42761. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42762. import { Vector4 } from "babylonjs/Maths/math.vector";
  42763. import { Color4 } from "babylonjs/Maths/math.color";
  42764. import { Mesh } from "babylonjs/Meshes/mesh";
  42765. /**
  42766. * Class containing static functions to help procedurally build meshes
  42767. */
  42768. export class CylinderBuilder {
  42769. /**
  42770. * Creates a cylinder or a cone mesh
  42771. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42772. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42773. * * 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.
  42774. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42775. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42776. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42777. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42778. * * 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).
  42779. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42780. * * 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).
  42781. * * 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
  42782. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42783. * * 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
  42784. * * 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.
  42785. * * If `enclose` is false, a ring surface is one element.
  42786. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42787. * * 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
  42788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42791. * @param name defines the name of the mesh
  42792. * @param options defines the options used to create the mesh
  42793. * @param scene defines the hosting scene
  42794. * @returns the cylinder mesh
  42795. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42796. */
  42797. static CreateCylinder(name: string, options: {
  42798. height?: number;
  42799. diameterTop?: number;
  42800. diameterBottom?: number;
  42801. diameter?: number;
  42802. tessellation?: number;
  42803. subdivisions?: number;
  42804. arc?: number;
  42805. faceColors?: Color4[];
  42806. faceUV?: Vector4[];
  42807. updatable?: boolean;
  42808. hasRings?: boolean;
  42809. enclose?: boolean;
  42810. cap?: number;
  42811. sideOrientation?: number;
  42812. frontUVs?: Vector4;
  42813. backUVs?: Vector4;
  42814. }, scene: any): Mesh;
  42815. }
  42816. }
  42817. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42818. import { Observable } from "babylonjs/Misc/observable";
  42819. import { Nullable } from "babylonjs/types";
  42820. import { Camera } from "babylonjs/Cameras/camera";
  42821. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42822. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42823. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42824. import { Scene } from "babylonjs/scene";
  42825. import { Vector3 } from "babylonjs/Maths/math.vector";
  42826. import { Color3 } from "babylonjs/Maths/math.color";
  42827. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42829. import { Mesh } from "babylonjs/Meshes/mesh";
  42830. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42831. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42832. import "babylonjs/Meshes/Builders/groundBuilder";
  42833. import "babylonjs/Meshes/Builders/torusBuilder";
  42834. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42835. import "babylonjs/Gamepads/gamepadSceneComponent";
  42836. import "babylonjs/Animations/animatable";
  42837. /**
  42838. * Options to modify the vr teleportation behavior.
  42839. */
  42840. export interface VRTeleportationOptions {
  42841. /**
  42842. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42843. */
  42844. floorMeshName?: string;
  42845. /**
  42846. * A list of meshes to be used as the teleportation floor. (default: empty)
  42847. */
  42848. floorMeshes?: Mesh[];
  42849. }
  42850. /**
  42851. * Options to modify the vr experience helper's behavior.
  42852. */
  42853. export interface VRExperienceHelperOptions extends WebVROptions {
  42854. /**
  42855. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42856. */
  42857. createDeviceOrientationCamera?: boolean;
  42858. /**
  42859. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42860. */
  42861. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42862. /**
  42863. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42864. */
  42865. laserToggle?: boolean;
  42866. /**
  42867. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42868. */
  42869. floorMeshes?: Mesh[];
  42870. /**
  42871. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42872. */
  42873. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42874. }
  42875. /**
  42876. * Event containing information after VR has been entered
  42877. */
  42878. export class OnAfterEnteringVRObservableEvent {
  42879. /**
  42880. * If entering vr was successful
  42881. */
  42882. success: boolean;
  42883. }
  42884. /**
  42885. * Helps to quickly add VR support to an existing scene.
  42886. * See http://doc.babylonjs.com/how_to/webvr_helper
  42887. */
  42888. export class VRExperienceHelper {
  42889. /** Options to modify the vr experience helper's behavior. */
  42890. webVROptions: VRExperienceHelperOptions;
  42891. private _scene;
  42892. private _position;
  42893. private _btnVR;
  42894. private _btnVRDisplayed;
  42895. private _webVRsupported;
  42896. private _webVRready;
  42897. private _webVRrequesting;
  42898. private _webVRpresenting;
  42899. private _hasEnteredVR;
  42900. private _fullscreenVRpresenting;
  42901. private _inputElement;
  42902. private _webVRCamera;
  42903. private _vrDeviceOrientationCamera;
  42904. private _deviceOrientationCamera;
  42905. private _existingCamera;
  42906. private _onKeyDown;
  42907. private _onVrDisplayPresentChange;
  42908. private _onVRDisplayChanged;
  42909. private _onVRRequestPresentStart;
  42910. private _onVRRequestPresentComplete;
  42911. /**
  42912. * 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)
  42913. */
  42914. enableGazeEvenWhenNoPointerLock: boolean;
  42915. /**
  42916. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42917. */
  42918. exitVROnDoubleTap: boolean;
  42919. /**
  42920. * Observable raised right before entering VR.
  42921. */
  42922. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42923. /**
  42924. * Observable raised when entering VR has completed.
  42925. */
  42926. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42927. /**
  42928. * Observable raised when exiting VR.
  42929. */
  42930. onExitingVRObservable: Observable<VRExperienceHelper>;
  42931. /**
  42932. * Observable raised when controller mesh is loaded.
  42933. */
  42934. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42935. /** Return this.onEnteringVRObservable
  42936. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42937. */
  42938. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42939. /** Return this.onExitingVRObservable
  42940. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42941. */
  42942. readonly onExitingVR: Observable<VRExperienceHelper>;
  42943. /** Return this.onControllerMeshLoadedObservable
  42944. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42945. */
  42946. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42947. private _rayLength;
  42948. private _useCustomVRButton;
  42949. private _teleportationRequested;
  42950. private _teleportActive;
  42951. private _floorMeshName;
  42952. private _floorMeshesCollection;
  42953. private _rotationAllowed;
  42954. private _teleportBackwardsVector;
  42955. private _teleportationTarget;
  42956. private _isDefaultTeleportationTarget;
  42957. private _postProcessMove;
  42958. private _teleportationFillColor;
  42959. private _teleportationBorderColor;
  42960. private _rotationAngle;
  42961. private _haloCenter;
  42962. private _cameraGazer;
  42963. private _padSensibilityUp;
  42964. private _padSensibilityDown;
  42965. private _leftController;
  42966. private _rightController;
  42967. /**
  42968. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42969. */
  42970. onNewMeshSelected: Observable<AbstractMesh>;
  42971. /**
  42972. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42973. * This observable will provide the mesh and the controller used to select the mesh
  42974. */
  42975. onMeshSelectedWithController: Observable<{
  42976. mesh: AbstractMesh;
  42977. controller: WebVRController;
  42978. }>;
  42979. /**
  42980. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42981. */
  42982. onNewMeshPicked: Observable<PickingInfo>;
  42983. private _circleEase;
  42984. /**
  42985. * Observable raised before camera teleportation
  42986. */
  42987. onBeforeCameraTeleport: Observable<Vector3>;
  42988. /**
  42989. * Observable raised after camera teleportation
  42990. */
  42991. onAfterCameraTeleport: Observable<Vector3>;
  42992. /**
  42993. * Observable raised when current selected mesh gets unselected
  42994. */
  42995. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42996. private _raySelectionPredicate;
  42997. /**
  42998. * To be optionaly changed by user to define custom ray selection
  42999. */
  43000. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43001. /**
  43002. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43003. */
  43004. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43005. /**
  43006. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43007. */
  43008. teleportationEnabled: boolean;
  43009. private _defaultHeight;
  43010. private _teleportationInitialized;
  43011. private _interactionsEnabled;
  43012. private _interactionsRequested;
  43013. private _displayGaze;
  43014. private _displayLaserPointer;
  43015. /**
  43016. * The mesh used to display where the user is going to teleport.
  43017. */
  43018. /**
  43019. * Sets the mesh to be used to display where the user is going to teleport.
  43020. */
  43021. teleportationTarget: Mesh;
  43022. /**
  43023. * 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
  43024. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43025. * See http://doc.babylonjs.com/resources/baking_transformations
  43026. */
  43027. gazeTrackerMesh: Mesh;
  43028. /**
  43029. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43030. */
  43031. updateGazeTrackerScale: boolean;
  43032. /**
  43033. * If the gaze trackers color should be updated when selecting meshes
  43034. */
  43035. updateGazeTrackerColor: boolean;
  43036. /**
  43037. * If the controller laser color should be updated when selecting meshes
  43038. */
  43039. updateControllerLaserColor: boolean;
  43040. /**
  43041. * The gaze tracking mesh corresponding to the left controller
  43042. */
  43043. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43044. /**
  43045. * The gaze tracking mesh corresponding to the right controller
  43046. */
  43047. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43048. /**
  43049. * If the ray of the gaze should be displayed.
  43050. */
  43051. /**
  43052. * Sets if the ray of the gaze should be displayed.
  43053. */
  43054. displayGaze: boolean;
  43055. /**
  43056. * If the ray of the LaserPointer should be displayed.
  43057. */
  43058. /**
  43059. * Sets if the ray of the LaserPointer should be displayed.
  43060. */
  43061. displayLaserPointer: boolean;
  43062. /**
  43063. * The deviceOrientationCamera used as the camera when not in VR.
  43064. */
  43065. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43066. /**
  43067. * Based on the current WebVR support, returns the current VR camera used.
  43068. */
  43069. readonly currentVRCamera: Nullable<Camera>;
  43070. /**
  43071. * The webVRCamera which is used when in VR.
  43072. */
  43073. readonly webVRCamera: WebVRFreeCamera;
  43074. /**
  43075. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43076. */
  43077. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43078. /**
  43079. * The html button that is used to trigger entering into VR.
  43080. */
  43081. readonly vrButton: Nullable<HTMLButtonElement>;
  43082. private readonly _teleportationRequestInitiated;
  43083. /**
  43084. * Defines wether or not Pointer lock should be requested when switching to
  43085. * full screen.
  43086. */
  43087. requestPointerLockOnFullScreen: boolean;
  43088. /**
  43089. * Instantiates a VRExperienceHelper.
  43090. * Helps to quickly add VR support to an existing scene.
  43091. * @param scene The scene the VRExperienceHelper belongs to.
  43092. * @param webVROptions Options to modify the vr experience helper's behavior.
  43093. */
  43094. constructor(scene: Scene,
  43095. /** Options to modify the vr experience helper's behavior. */
  43096. webVROptions?: VRExperienceHelperOptions);
  43097. private _onDefaultMeshLoaded;
  43098. private _onResize;
  43099. private _onFullscreenChange;
  43100. /**
  43101. * Gets a value indicating if we are currently in VR mode.
  43102. */
  43103. readonly isInVRMode: boolean;
  43104. private onVrDisplayPresentChange;
  43105. private onVRDisplayChanged;
  43106. private moveButtonToBottomRight;
  43107. private displayVRButton;
  43108. private updateButtonVisibility;
  43109. private _cachedAngularSensibility;
  43110. /**
  43111. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43112. * Otherwise, will use the fullscreen API.
  43113. */
  43114. enterVR(): void;
  43115. /**
  43116. * Attempt to exit VR, or fullscreen.
  43117. */
  43118. exitVR(): void;
  43119. /**
  43120. * The position of the vr experience helper.
  43121. */
  43122. /**
  43123. * Sets the position of the vr experience helper.
  43124. */
  43125. position: Vector3;
  43126. /**
  43127. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43128. */
  43129. enableInteractions(): void;
  43130. private readonly _noControllerIsActive;
  43131. private beforeRender;
  43132. private _isTeleportationFloor;
  43133. /**
  43134. * Adds a floor mesh to be used for teleportation.
  43135. * @param floorMesh the mesh to be used for teleportation.
  43136. */
  43137. addFloorMesh(floorMesh: Mesh): void;
  43138. /**
  43139. * Removes a floor mesh from being used for teleportation.
  43140. * @param floorMesh the mesh to be removed.
  43141. */
  43142. removeFloorMesh(floorMesh: Mesh): void;
  43143. /**
  43144. * Enables interactions and teleportation using the VR controllers and gaze.
  43145. * @param vrTeleportationOptions options to modify teleportation behavior.
  43146. */
  43147. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43148. private _onNewGamepadConnected;
  43149. private _tryEnableInteractionOnController;
  43150. private _onNewGamepadDisconnected;
  43151. private _enableInteractionOnController;
  43152. private _checkTeleportWithRay;
  43153. private _checkRotate;
  43154. private _checkTeleportBackwards;
  43155. private _enableTeleportationOnController;
  43156. private _createTeleportationCircles;
  43157. private _displayTeleportationTarget;
  43158. private _hideTeleportationTarget;
  43159. private _rotateCamera;
  43160. private _moveTeleportationSelectorTo;
  43161. private _workingVector;
  43162. private _workingQuaternion;
  43163. private _workingMatrix;
  43164. /**
  43165. * Teleports the users feet to the desired location
  43166. * @param location The location where the user's feet should be placed
  43167. */
  43168. teleportCamera(location: Vector3): void;
  43169. private _convertNormalToDirectionOfRay;
  43170. private _castRayAndSelectObject;
  43171. private _notifySelectedMeshUnselected;
  43172. /**
  43173. * Sets the color of the laser ray from the vr controllers.
  43174. * @param color new color for the ray.
  43175. */
  43176. changeLaserColor(color: Color3): void;
  43177. /**
  43178. * Sets the color of the ray from the vr headsets gaze.
  43179. * @param color new color for the ray.
  43180. */
  43181. changeGazeColor(color: Color3): void;
  43182. /**
  43183. * Exits VR and disposes of the vr experience helper
  43184. */
  43185. dispose(): void;
  43186. /**
  43187. * Gets the name of the VRExperienceHelper class
  43188. * @returns "VRExperienceHelper"
  43189. */
  43190. getClassName(): string;
  43191. }
  43192. }
  43193. declare module "babylonjs/Cameras/VR/index" {
  43194. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43195. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43196. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43197. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43198. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43199. export * from "babylonjs/Cameras/VR/webVRCamera";
  43200. }
  43201. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43202. import { Nullable } from "babylonjs/types";
  43203. import { IDisposable } from "babylonjs/scene";
  43204. /**
  43205. * States of the webXR experience
  43206. */
  43207. export enum WebXRState {
  43208. /**
  43209. * Transitioning to being in XR mode
  43210. */
  43211. ENTERING_XR = 0,
  43212. /**
  43213. * Transitioning to non XR mode
  43214. */
  43215. EXITING_XR = 1,
  43216. /**
  43217. * In XR mode and presenting
  43218. */
  43219. IN_XR = 2,
  43220. /**
  43221. * Not entered XR mode
  43222. */
  43223. NOT_IN_XR = 3
  43224. }
  43225. /**
  43226. * Abstraction of the XR render target
  43227. */
  43228. export interface WebXRRenderTarget extends IDisposable {
  43229. /**
  43230. * xrpresent context of the canvas which can be used to display/mirror xr content
  43231. */
  43232. canvasContext: WebGLRenderingContext;
  43233. /**
  43234. * xr layer for the canvas
  43235. */
  43236. xrLayer: Nullable<XRWebGLLayer>;
  43237. /**
  43238. * Initializes the xr layer for the session
  43239. * @param xrSession xr session
  43240. * @returns a promise that will resolve once the XR Layer has been created
  43241. */
  43242. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43243. }
  43244. }
  43245. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43246. import { Nullable } from "babylonjs/types";
  43247. import { Observable } from "babylonjs/Misc/observable";
  43248. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43249. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43250. /**
  43251. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43252. */
  43253. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43254. private _engine;
  43255. private _canvas;
  43256. /**
  43257. * xrpresent context of the canvas which can be used to display/mirror xr content
  43258. */
  43259. canvasContext: WebGLRenderingContext;
  43260. /**
  43261. * xr layer for the canvas
  43262. */
  43263. xrLayer: Nullable<XRWebGLLayer>;
  43264. /**
  43265. * Initializes the xr layer for the session
  43266. * @param xrSession xr session
  43267. * @returns a promise that will resolve once the XR Layer has been created
  43268. */
  43269. initializeXRLayerAsync(xrSession: any): any;
  43270. /**
  43271. * Initializes the canvas to be added/removed upon entering/exiting xr
  43272. * @param engine the Babylon engine
  43273. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43274. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43275. */
  43276. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43277. /**
  43278. * Disposes of the object
  43279. */
  43280. dispose(): void;
  43281. private _setManagedOutputCanvas;
  43282. private _addCanvas;
  43283. private _removeCanvas;
  43284. }
  43285. }
  43286. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43287. import { Observable } from "babylonjs/Misc/observable";
  43288. import { Nullable } from "babylonjs/types";
  43289. import { IDisposable, Scene } from "babylonjs/scene";
  43290. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43291. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43292. /**
  43293. * Manages an XRSession to work with Babylon's engine
  43294. * @see https://doc.babylonjs.com/how_to/webxr
  43295. */
  43296. export class WebXRSessionManager implements IDisposable {
  43297. private scene;
  43298. /**
  43299. * Fires every time a new xrFrame arrives which can be used to update the camera
  43300. */
  43301. onXRFrameObservable: Observable<any>;
  43302. /**
  43303. * Fires when the xr session is ended either by the device or manually done
  43304. */
  43305. onXRSessionEnded: Observable<any>;
  43306. /**
  43307. * Underlying xr session
  43308. */
  43309. session: XRSession;
  43310. /**
  43311. * Type of reference space used when creating the session
  43312. */
  43313. referenceSpace: XRReferenceSpace;
  43314. /**
  43315. * Current XR frame
  43316. */
  43317. currentFrame: Nullable<XRFrame>;
  43318. private _xrNavigator;
  43319. private baseLayer;
  43320. private _rttProvider;
  43321. private _sessionEnded;
  43322. /**
  43323. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43324. * @param scene The scene which the session should be created for
  43325. */
  43326. constructor(scene: Scene);
  43327. /**
  43328. * Initializes the manager
  43329. * After initialization enterXR can be called to start an XR session
  43330. * @returns Promise which resolves after it is initialized
  43331. */
  43332. initializeAsync(): Promise<void>;
  43333. /**
  43334. * Initializes an xr session
  43335. * @param xrSessionMode mode to initialize
  43336. * @param optionalFeatures defines optional values to pass to the session builder
  43337. * @returns a promise which will resolve once the session has been initialized
  43338. */
  43339. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43340. /**
  43341. * Sets the reference space on the xr session
  43342. * @param referenceSpace space to set
  43343. * @returns a promise that will resolve once the reference space has been set
  43344. */
  43345. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43346. /**
  43347. * Updates the render state of the session
  43348. * @param state state to set
  43349. * @returns a promise that resolves once the render state has been updated
  43350. */
  43351. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43352. /**
  43353. * Starts rendering to the xr layer
  43354. * @returns a promise that will resolve once rendering has started
  43355. */
  43356. startRenderingToXRAsync(): Promise<void>;
  43357. /**
  43358. * Gets the correct render target texture to be rendered this frame for this eye
  43359. * @param eye the eye for which to get the render target
  43360. * @returns the render target for the specified eye
  43361. */
  43362. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43363. /**
  43364. * Stops the xrSession and restores the renderloop
  43365. * @returns Promise which resolves after it exits XR
  43366. */
  43367. exitXRAsync(): Promise<void>;
  43368. /**
  43369. * Checks if a session would be supported for the creation options specified
  43370. * @param sessionMode session mode to check if supported eg. immersive-vr
  43371. * @returns true if supported
  43372. */
  43373. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43374. /**
  43375. * Creates a WebXRRenderTarget object for the XR session
  43376. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43377. * @returns a WebXR render target to which the session can render
  43378. */
  43379. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43380. /**
  43381. * @hidden
  43382. * Converts the render layer of xrSession to a render target
  43383. * @param session session to create render target for
  43384. * @param scene scene the new render target should be created for
  43385. */
  43386. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43387. /**
  43388. * Disposes of the session manager
  43389. */
  43390. dispose(): void;
  43391. }
  43392. }
  43393. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43394. import { Scene } from "babylonjs/scene";
  43395. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43396. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43397. /**
  43398. * WebXR Camera which holds the views for the xrSession
  43399. * @see https://doc.babylonjs.com/how_to/webxr
  43400. */
  43401. export class WebXRCamera extends FreeCamera {
  43402. private static _TmpMatrix;
  43403. /**
  43404. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43405. * @param name the name of the camera
  43406. * @param scene the scene to add the camera to
  43407. */
  43408. constructor(name: string, scene: Scene);
  43409. private _updateNumberOfRigCameras;
  43410. /** @hidden */
  43411. _updateForDualEyeDebugging(): void;
  43412. /**
  43413. * Updates the cameras position from the current pose information of the XR session
  43414. * @param xrSessionManager the session containing pose information
  43415. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43416. */
  43417. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43418. }
  43419. }
  43420. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43421. import { Observable } from "babylonjs/Misc/observable";
  43422. import { IDisposable, Scene } from "babylonjs/scene";
  43423. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43425. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43426. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43427. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43428. /**
  43429. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43430. * @see https://doc.babylonjs.com/how_to/webxr
  43431. */
  43432. export class WebXRExperienceHelper implements IDisposable {
  43433. private scene;
  43434. /**
  43435. * 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
  43436. */
  43437. container: AbstractMesh;
  43438. /**
  43439. * Camera used to render xr content
  43440. */
  43441. camera: WebXRCamera;
  43442. /**
  43443. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43444. */
  43445. state: WebXRState;
  43446. private _setState;
  43447. private static _TmpVector;
  43448. /**
  43449. * Fires when the state of the experience helper has changed
  43450. */
  43451. onStateChangedObservable: Observable<WebXRState>;
  43452. /** Session manager used to keep track of xr session */
  43453. sessionManager: WebXRSessionManager;
  43454. private _nonVRCamera;
  43455. private _originalSceneAutoClear;
  43456. private _supported;
  43457. /**
  43458. * Creates the experience helper
  43459. * @param scene the scene to attach the experience helper to
  43460. * @returns a promise for the experience helper
  43461. */
  43462. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43463. /**
  43464. * Creates a WebXRExperienceHelper
  43465. * @param scene The scene the helper should be created in
  43466. */
  43467. private constructor();
  43468. /**
  43469. * Exits XR mode and returns the scene to its original state
  43470. * @returns promise that resolves after xr mode has exited
  43471. */
  43472. exitXRAsync(): Promise<void>;
  43473. /**
  43474. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43475. * @param sessionMode options for the XR session
  43476. * @param referenceSpaceType frame of reference of the XR session
  43477. * @param renderTarget the output canvas that will be used to enter XR mode
  43478. * @returns promise that resolves after xr mode has entered
  43479. */
  43480. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43481. /**
  43482. * Updates the global position of the camera by moving the camera's container
  43483. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43484. * @param position The desired global position of the camera
  43485. */
  43486. setPositionOfCameraUsingContainer(position: Vector3): void;
  43487. /**
  43488. * Rotates the xr camera by rotating the camera's container around the camera's position
  43489. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43490. * @param rotation the desired quaternion rotation to apply to the camera
  43491. */
  43492. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43493. /**
  43494. * Disposes of the experience helper
  43495. */
  43496. dispose(): void;
  43497. }
  43498. }
  43499. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43500. import { Nullable } from "babylonjs/types";
  43501. import { Observable } from "babylonjs/Misc/observable";
  43502. import { IDisposable, Scene } from "babylonjs/scene";
  43503. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43504. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43505. /**
  43506. * Button which can be used to enter a different mode of XR
  43507. */
  43508. export class WebXREnterExitUIButton {
  43509. /** button element */
  43510. element: HTMLElement;
  43511. /** XR initialization options for the button */
  43512. sessionMode: XRSessionMode;
  43513. /** Reference space type */
  43514. referenceSpaceType: XRReferenceSpaceType;
  43515. /**
  43516. * Creates a WebXREnterExitUIButton
  43517. * @param element button element
  43518. * @param sessionMode XR initialization session mode
  43519. * @param referenceSpaceType the type of reference space to be used
  43520. */
  43521. constructor(
  43522. /** button element */
  43523. element: HTMLElement,
  43524. /** XR initialization options for the button */
  43525. sessionMode: XRSessionMode,
  43526. /** Reference space type */
  43527. referenceSpaceType: XRReferenceSpaceType);
  43528. /**
  43529. * Overwritable function which can be used to update the button's visuals when the state changes
  43530. * @param activeButton the current active button in the UI
  43531. */
  43532. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43533. }
  43534. /**
  43535. * Options to create the webXR UI
  43536. */
  43537. export class WebXREnterExitUIOptions {
  43538. /**
  43539. * Context to enter xr with
  43540. */
  43541. renderTarget?: Nullable<WebXRRenderTarget>;
  43542. /**
  43543. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43544. */
  43545. customButtons?: Array<WebXREnterExitUIButton>;
  43546. }
  43547. /**
  43548. * UI to allow the user to enter/exit XR mode
  43549. */
  43550. export class WebXREnterExitUI implements IDisposable {
  43551. private scene;
  43552. private _overlay;
  43553. private _buttons;
  43554. private _activeButton;
  43555. /**
  43556. * Fired every time the active button is changed.
  43557. *
  43558. * When xr is entered via a button that launches xr that button will be the callback parameter
  43559. *
  43560. * When exiting xr the callback parameter will be null)
  43561. */
  43562. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43563. /**
  43564. * Creates UI to allow the user to enter/exit XR mode
  43565. * @param scene the scene to add the ui to
  43566. * @param helper the xr experience helper to enter/exit xr with
  43567. * @param options options to configure the UI
  43568. * @returns the created ui
  43569. */
  43570. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43571. private constructor();
  43572. private _updateButtons;
  43573. /**
  43574. * Disposes of the object
  43575. */
  43576. dispose(): void;
  43577. }
  43578. }
  43579. declare module "babylonjs/Cameras/XR/webXRController" {
  43580. import { Nullable } from "babylonjs/types";
  43581. import { Observable } from "babylonjs/Misc/observable";
  43582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43583. import { Ray } from "babylonjs/Culling/ray";
  43584. import { Scene } from "babylonjs/scene";
  43585. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43586. /**
  43587. * Represents an XR input
  43588. */
  43589. export class WebXRController {
  43590. private scene;
  43591. /** The underlying input source for the controller */
  43592. inputSource: XRInputSource;
  43593. private parentContainer;
  43594. /**
  43595. * 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
  43596. */
  43597. grip?: AbstractMesh;
  43598. /**
  43599. * Pointer which can be used to select objects or attach a visible laser to
  43600. */
  43601. pointer: AbstractMesh;
  43602. private _gamepadMode;
  43603. /**
  43604. * If available, this is the gamepad object related to this controller.
  43605. * Using this object it is possible to get click events and trackpad changes of the
  43606. * webxr controller that is currently being used.
  43607. */
  43608. gamepadController?: WebVRController;
  43609. /**
  43610. * Event that fires when the controller is removed/disposed
  43611. */
  43612. onDisposeObservable: Observable<{}>;
  43613. private _tmpMatrix;
  43614. private _tmpQuaternion;
  43615. private _tmpVector;
  43616. /**
  43617. * Creates the controller
  43618. * @see https://doc.babylonjs.com/how_to/webxr
  43619. * @param scene the scene which the controller should be associated to
  43620. * @param inputSource the underlying input source for the controller
  43621. * @param parentContainer parent that the controller meshes should be children of
  43622. */
  43623. constructor(scene: Scene,
  43624. /** The underlying input source for the controller */
  43625. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43626. /**
  43627. * Updates the controller pose based on the given XRFrame
  43628. * @param xrFrame xr frame to update the pose with
  43629. * @param referenceSpace reference space to use
  43630. */
  43631. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43632. /**
  43633. * Gets a world space ray coming from the controller
  43634. * @param result the resulting ray
  43635. */
  43636. getWorldPointerRayToRef(result: Ray): void;
  43637. /**
  43638. * Get the scene associated with this controller
  43639. * @returns the scene object
  43640. */
  43641. getScene(): Scene;
  43642. /**
  43643. * Disposes of the object
  43644. */
  43645. dispose(): void;
  43646. }
  43647. }
  43648. declare module "babylonjs/Cameras/XR/webXRInput" {
  43649. import { Observable } from "babylonjs/Misc/observable";
  43650. import { IDisposable } from "babylonjs/scene";
  43651. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43652. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43653. /**
  43654. * XR input used to track XR inputs such as controllers/rays
  43655. */
  43656. export class WebXRInput implements IDisposable {
  43657. /**
  43658. * Base experience the input listens to
  43659. */
  43660. baseExperience: WebXRExperienceHelper;
  43661. /**
  43662. * XR controllers being tracked
  43663. */
  43664. controllers: Array<WebXRController>;
  43665. private _frameObserver;
  43666. private _stateObserver;
  43667. /**
  43668. * Event when a controller has been connected/added
  43669. */
  43670. onControllerAddedObservable: Observable<WebXRController>;
  43671. /**
  43672. * Event when a controller has been removed/disconnected
  43673. */
  43674. onControllerRemovedObservable: Observable<WebXRController>;
  43675. /**
  43676. * Initializes the WebXRInput
  43677. * @param baseExperience experience helper which the input should be created for
  43678. */
  43679. constructor(
  43680. /**
  43681. * Base experience the input listens to
  43682. */
  43683. baseExperience: WebXRExperienceHelper);
  43684. private _onInputSourcesChange;
  43685. private _addAndRemoveControllers;
  43686. /**
  43687. * Disposes of the object
  43688. */
  43689. dispose(): void;
  43690. }
  43691. }
  43692. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43694. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43695. /**
  43696. * Enables teleportation
  43697. */
  43698. export class WebXRControllerTeleportation {
  43699. private _teleportationFillColor;
  43700. private _teleportationBorderColor;
  43701. private _tmpRay;
  43702. private _tmpVector;
  43703. /**
  43704. * Creates a WebXRControllerTeleportation
  43705. * @param input input manager to add teleportation to
  43706. * @param floorMeshes floormeshes which can be teleported to
  43707. */
  43708. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43709. }
  43710. }
  43711. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43712. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43713. /**
  43714. * Handles pointer input automatically for the pointer of XR controllers
  43715. */
  43716. export class WebXRControllerPointerSelection {
  43717. private static _idCounter;
  43718. private _tmpRay;
  43719. /**
  43720. * Creates a WebXRControllerPointerSelection
  43721. * @param input input manager to setup pointer selection
  43722. */
  43723. constructor(input: WebXRInput);
  43724. private _convertNormalToDirectionOfRay;
  43725. private _updatePointerDistance;
  43726. }
  43727. }
  43728. declare module "babylonjs/Loading/sceneLoader" {
  43729. import { Observable } from "babylonjs/Misc/observable";
  43730. import { Nullable } from "babylonjs/types";
  43731. import { Scene } from "babylonjs/scene";
  43732. import { Engine } from "babylonjs/Engines/engine";
  43733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43734. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43735. import { AssetContainer } from "babylonjs/assetContainer";
  43736. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43737. import { Skeleton } from "babylonjs/Bones/skeleton";
  43738. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43739. import { WebRequest } from "babylonjs/Misc/webRequest";
  43740. /**
  43741. * Class used to represent data loading progression
  43742. */
  43743. export class SceneLoaderProgressEvent {
  43744. /** defines if data length to load can be evaluated */
  43745. readonly lengthComputable: boolean;
  43746. /** defines the loaded data length */
  43747. readonly loaded: number;
  43748. /** defines the data length to load */
  43749. readonly total: number;
  43750. /**
  43751. * Create a new progress event
  43752. * @param lengthComputable defines if data length to load can be evaluated
  43753. * @param loaded defines the loaded data length
  43754. * @param total defines the data length to load
  43755. */
  43756. constructor(
  43757. /** defines if data length to load can be evaluated */
  43758. lengthComputable: boolean,
  43759. /** defines the loaded data length */
  43760. loaded: number,
  43761. /** defines the data length to load */
  43762. total: number);
  43763. /**
  43764. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43765. * @param event defines the source event
  43766. * @returns a new SceneLoaderProgressEvent
  43767. */
  43768. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43769. }
  43770. /**
  43771. * Interface used by SceneLoader plugins to define supported file extensions
  43772. */
  43773. export interface ISceneLoaderPluginExtensions {
  43774. /**
  43775. * Defines the list of supported extensions
  43776. */
  43777. [extension: string]: {
  43778. isBinary: boolean;
  43779. };
  43780. }
  43781. /**
  43782. * Interface used by SceneLoader plugin factory
  43783. */
  43784. export interface ISceneLoaderPluginFactory {
  43785. /**
  43786. * Defines the name of the factory
  43787. */
  43788. name: string;
  43789. /**
  43790. * Function called to create a new plugin
  43791. * @return the new plugin
  43792. */
  43793. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43794. /**
  43795. * The callback that returns true if the data can be directly loaded.
  43796. * @param data string containing the file data
  43797. * @returns if the data can be loaded directly
  43798. */
  43799. canDirectLoad?(data: string): boolean;
  43800. }
  43801. /**
  43802. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43803. */
  43804. export interface ISceneLoaderPluginBase {
  43805. /**
  43806. * The friendly name of this plugin.
  43807. */
  43808. name: string;
  43809. /**
  43810. * The file extensions supported by this plugin.
  43811. */
  43812. extensions: string | ISceneLoaderPluginExtensions;
  43813. /**
  43814. * The callback called when loading from a url.
  43815. * @param scene scene loading this url
  43816. * @param url url to load
  43817. * @param onSuccess callback called when the file successfully loads
  43818. * @param onProgress callback called while file is loading (if the server supports this mode)
  43819. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43820. * @param onError callback called when the file fails to load
  43821. * @returns a file request object
  43822. */
  43823. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43824. /**
  43825. * The callback called when loading from a file object.
  43826. * @param scene scene loading this file
  43827. * @param file defines the file to load
  43828. * @param onSuccess defines the callback to call when data is loaded
  43829. * @param onProgress defines the callback to call during loading process
  43830. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43831. * @param onError defines the callback to call when an error occurs
  43832. * @returns a file request object
  43833. */
  43834. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43835. /**
  43836. * The callback that returns true if the data can be directly loaded.
  43837. * @param data string containing the file data
  43838. * @returns if the data can be loaded directly
  43839. */
  43840. canDirectLoad?(data: string): boolean;
  43841. /**
  43842. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43843. * @param scene scene loading this data
  43844. * @param data string containing the data
  43845. * @returns data to pass to the plugin
  43846. */
  43847. directLoad?(scene: Scene, data: string): any;
  43848. /**
  43849. * The callback that allows custom handling of the root url based on the response url.
  43850. * @param rootUrl the original root url
  43851. * @param responseURL the response url if available
  43852. * @returns the new root url
  43853. */
  43854. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43855. }
  43856. /**
  43857. * Interface used to define a SceneLoader plugin
  43858. */
  43859. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43860. /**
  43861. * Import meshes into a scene.
  43862. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43863. * @param scene The scene to import into
  43864. * @param data The data to import
  43865. * @param rootUrl The root url for scene and resources
  43866. * @param meshes The meshes array to import into
  43867. * @param particleSystems The particle systems array to import into
  43868. * @param skeletons The skeletons array to import into
  43869. * @param onError The callback when import fails
  43870. * @returns True if successful or false otherwise
  43871. */
  43872. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43873. /**
  43874. * Load into a scene.
  43875. * @param scene The scene to load into
  43876. * @param data The data to import
  43877. * @param rootUrl The root url for scene and resources
  43878. * @param onError The callback when import fails
  43879. * @returns True if successful or false otherwise
  43880. */
  43881. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43882. /**
  43883. * Load into an asset container.
  43884. * @param scene The scene to load into
  43885. * @param data The data to import
  43886. * @param rootUrl The root url for scene and resources
  43887. * @param onError The callback when import fails
  43888. * @returns The loaded asset container
  43889. */
  43890. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43891. }
  43892. /**
  43893. * Interface used to define an async SceneLoader plugin
  43894. */
  43895. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43896. /**
  43897. * Import meshes into a scene.
  43898. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43899. * @param scene The scene to import into
  43900. * @param data The data to import
  43901. * @param rootUrl The root url for scene and resources
  43902. * @param onProgress The callback when the load progresses
  43903. * @param fileName Defines the name of the file to load
  43904. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43905. */
  43906. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43907. meshes: AbstractMesh[];
  43908. particleSystems: IParticleSystem[];
  43909. skeletons: Skeleton[];
  43910. animationGroups: AnimationGroup[];
  43911. }>;
  43912. /**
  43913. * Load into a scene.
  43914. * @param scene The scene to load into
  43915. * @param data The data to import
  43916. * @param rootUrl The root url for scene and resources
  43917. * @param onProgress The callback when the load progresses
  43918. * @param fileName Defines the name of the file to load
  43919. * @returns Nothing
  43920. */
  43921. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43922. /**
  43923. * Load into an asset container.
  43924. * @param scene The scene to load into
  43925. * @param data The data to import
  43926. * @param rootUrl The root url for scene and resources
  43927. * @param onProgress The callback when the load progresses
  43928. * @param fileName Defines the name of the file to load
  43929. * @returns The loaded asset container
  43930. */
  43931. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43932. }
  43933. /**
  43934. * Class used to load scene from various file formats using registered plugins
  43935. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43936. */
  43937. export class SceneLoader {
  43938. /**
  43939. * No logging while loading
  43940. */
  43941. static readonly NO_LOGGING: number;
  43942. /**
  43943. * Minimal logging while loading
  43944. */
  43945. static readonly MINIMAL_LOGGING: number;
  43946. /**
  43947. * Summary logging while loading
  43948. */
  43949. static readonly SUMMARY_LOGGING: number;
  43950. /**
  43951. * Detailled logging while loading
  43952. */
  43953. static readonly DETAILED_LOGGING: number;
  43954. /**
  43955. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43956. */
  43957. static ForceFullSceneLoadingForIncremental: boolean;
  43958. /**
  43959. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43960. */
  43961. static ShowLoadingScreen: boolean;
  43962. /**
  43963. * Defines the current logging level (while loading the scene)
  43964. * @ignorenaming
  43965. */
  43966. static loggingLevel: number;
  43967. /**
  43968. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43969. */
  43970. static CleanBoneMatrixWeights: boolean;
  43971. /**
  43972. * Event raised when a plugin is used to load a scene
  43973. */
  43974. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43975. private static _registeredPlugins;
  43976. private static _getDefaultPlugin;
  43977. private static _getPluginForExtension;
  43978. private static _getPluginForDirectLoad;
  43979. private static _getPluginForFilename;
  43980. private static _getDirectLoad;
  43981. private static _loadData;
  43982. private static _getFileInfo;
  43983. /**
  43984. * Gets a plugin that can load the given extension
  43985. * @param extension defines the extension to load
  43986. * @returns a plugin or null if none works
  43987. */
  43988. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43989. /**
  43990. * Gets a boolean indicating that the given extension can be loaded
  43991. * @param extension defines the extension to load
  43992. * @returns true if the extension is supported
  43993. */
  43994. static IsPluginForExtensionAvailable(extension: string): boolean;
  43995. /**
  43996. * Adds a new plugin to the list of registered plugins
  43997. * @param plugin defines the plugin to add
  43998. */
  43999. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44000. /**
  44001. * Import meshes into a scene
  44002. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44003. * @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)
  44004. * @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)
  44005. * @param scene the instance of BABYLON.Scene to append to
  44006. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44007. * @param onProgress a callback with a progress event for each file being loaded
  44008. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44009. * @param pluginExtension the extension used to determine the plugin
  44010. * @returns The loaded plugin
  44011. */
  44012. 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>;
  44013. /**
  44014. * Import meshes into a scene
  44015. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44016. * @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)
  44017. * @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)
  44018. * @param scene the instance of BABYLON.Scene to append to
  44019. * @param onProgress a callback with a progress event for each file being loaded
  44020. * @param pluginExtension the extension used to determine the plugin
  44021. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44022. */
  44023. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44024. meshes: AbstractMesh[];
  44025. particleSystems: IParticleSystem[];
  44026. skeletons: Skeleton[];
  44027. animationGroups: AnimationGroup[];
  44028. }>;
  44029. /**
  44030. * Load a scene
  44031. * @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)
  44032. * @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)
  44033. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44034. * @param onSuccess a callback with the scene when import succeeds
  44035. * @param onProgress a callback with a progress event for each file being loaded
  44036. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44037. * @param pluginExtension the extension used to determine the plugin
  44038. * @returns The loaded plugin
  44039. */
  44040. 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>;
  44041. /**
  44042. * Load a scene
  44043. * @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)
  44044. * @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)
  44045. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44046. * @param onProgress a callback with a progress event for each file being loaded
  44047. * @param pluginExtension the extension used to determine the plugin
  44048. * @returns The loaded scene
  44049. */
  44050. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44051. /**
  44052. * Append a scene
  44053. * @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)
  44054. * @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)
  44055. * @param scene is the instance of BABYLON.Scene to append to
  44056. * @param onSuccess a callback with the scene when import succeeds
  44057. * @param onProgress a callback with a progress event for each file being loaded
  44058. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44059. * @param pluginExtension the extension used to determine the plugin
  44060. * @returns The loaded plugin
  44061. */
  44062. 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>;
  44063. /**
  44064. * Append a scene
  44065. * @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)
  44066. * @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)
  44067. * @param scene is the instance of BABYLON.Scene to append to
  44068. * @param onProgress a callback with a progress event for each file being loaded
  44069. * @param pluginExtension the extension used to determine the plugin
  44070. * @returns The given scene
  44071. */
  44072. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44073. /**
  44074. * Load a scene into an asset container
  44075. * @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)
  44076. * @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)
  44077. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44078. * @param onSuccess a callback with the scene when import succeeds
  44079. * @param onProgress a callback with a progress event for each file being loaded
  44080. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44081. * @param pluginExtension the extension used to determine the plugin
  44082. * @returns The loaded plugin
  44083. */
  44084. 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>;
  44085. /**
  44086. * Load a scene into an asset container
  44087. * @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)
  44088. * @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)
  44089. * @param scene is the instance of Scene to append to
  44090. * @param onProgress a callback with a progress event for each file being loaded
  44091. * @param pluginExtension the extension used to determine the plugin
  44092. * @returns The loaded asset container
  44093. */
  44094. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44095. }
  44096. }
  44097. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44098. import { Scene } from "babylonjs/scene";
  44099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44100. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44101. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44102. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44103. /**
  44104. * Generic Controller
  44105. */
  44106. export class GenericController extends WebVRController {
  44107. /**
  44108. * Base Url for the controller model.
  44109. */
  44110. static readonly MODEL_BASE_URL: string;
  44111. /**
  44112. * File name for the controller model.
  44113. */
  44114. static readonly MODEL_FILENAME: string;
  44115. /**
  44116. * Creates a new GenericController from a gamepad
  44117. * @param vrGamepad the gamepad that the controller should be created from
  44118. */
  44119. constructor(vrGamepad: any);
  44120. /**
  44121. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44122. * @param scene scene in which to add meshes
  44123. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44124. */
  44125. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44126. /**
  44127. * Called once for each button that changed state since the last frame
  44128. * @param buttonIdx Which button index changed
  44129. * @param state New state of the button
  44130. * @param changes Which properties on the state changed since last frame
  44131. */
  44132. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44133. }
  44134. }
  44135. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44136. import { Observable } from "babylonjs/Misc/observable";
  44137. import { Scene } from "babylonjs/scene";
  44138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44139. import { Ray } from "babylonjs/Culling/ray";
  44140. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44141. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44142. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44143. /**
  44144. * Defines the WindowsMotionController object that the state of the windows motion controller
  44145. */
  44146. export class WindowsMotionController extends WebVRController {
  44147. /**
  44148. * The base url used to load the left and right controller models
  44149. */
  44150. static MODEL_BASE_URL: string;
  44151. /**
  44152. * The name of the left controller model file
  44153. */
  44154. static MODEL_LEFT_FILENAME: string;
  44155. /**
  44156. * The name of the right controller model file
  44157. */
  44158. static MODEL_RIGHT_FILENAME: string;
  44159. /**
  44160. * The controller name prefix for this controller type
  44161. */
  44162. static readonly GAMEPAD_ID_PREFIX: string;
  44163. /**
  44164. * The controller id pattern for this controller type
  44165. */
  44166. private static readonly GAMEPAD_ID_PATTERN;
  44167. private _loadedMeshInfo;
  44168. private readonly _mapping;
  44169. /**
  44170. * Fired when the trackpad on this controller is clicked
  44171. */
  44172. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44173. /**
  44174. * Fired when the trackpad on this controller is modified
  44175. */
  44176. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44177. /**
  44178. * The current x and y values of this controller's trackpad
  44179. */
  44180. trackpad: StickValues;
  44181. /**
  44182. * Creates a new WindowsMotionController from a gamepad
  44183. * @param vrGamepad the gamepad that the controller should be created from
  44184. */
  44185. constructor(vrGamepad: any);
  44186. /**
  44187. * Fired when the trigger on this controller is modified
  44188. */
  44189. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44190. /**
  44191. * Fired when the menu button on this controller is modified
  44192. */
  44193. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44194. /**
  44195. * Fired when the grip button on this controller is modified
  44196. */
  44197. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44198. /**
  44199. * Fired when the thumbstick button on this controller is modified
  44200. */
  44201. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44202. /**
  44203. * Fired when the touchpad button on this controller is modified
  44204. */
  44205. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44206. /**
  44207. * Fired when the touchpad values on this controller are modified
  44208. */
  44209. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44210. private _updateTrackpad;
  44211. /**
  44212. * Called once per frame by the engine.
  44213. */
  44214. update(): void;
  44215. /**
  44216. * Called once for each button that changed state since the last frame
  44217. * @param buttonIdx Which button index changed
  44218. * @param state New state of the button
  44219. * @param changes Which properties on the state changed since last frame
  44220. */
  44221. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44222. /**
  44223. * Moves the buttons on the controller mesh based on their current state
  44224. * @param buttonName the name of the button to move
  44225. * @param buttonValue the value of the button which determines the buttons new position
  44226. */
  44227. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44228. /**
  44229. * Moves the axis on the controller mesh based on its current state
  44230. * @param axis the index of the axis
  44231. * @param axisValue the value of the axis which determines the meshes new position
  44232. * @hidden
  44233. */
  44234. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44235. /**
  44236. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44237. * @param scene scene in which to add meshes
  44238. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44239. */
  44240. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44241. /**
  44242. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44243. * can be transformed by button presses and axes values, based on this._mapping.
  44244. *
  44245. * @param scene scene in which the meshes exist
  44246. * @param meshes list of meshes that make up the controller model to process
  44247. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44248. */
  44249. private processModel;
  44250. private createMeshInfo;
  44251. /**
  44252. * Gets the ray of the controller in the direction the controller is pointing
  44253. * @param length the length the resulting ray should be
  44254. * @returns a ray in the direction the controller is pointing
  44255. */
  44256. getForwardRay(length?: number): Ray;
  44257. /**
  44258. * Disposes of the controller
  44259. */
  44260. dispose(): void;
  44261. }
  44262. }
  44263. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44264. import { Observable } from "babylonjs/Misc/observable";
  44265. import { Scene } from "babylonjs/scene";
  44266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44267. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44268. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44269. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44270. /**
  44271. * Oculus Touch Controller
  44272. */
  44273. export class OculusTouchController extends WebVRController {
  44274. /**
  44275. * Base Url for the controller model.
  44276. */
  44277. static MODEL_BASE_URL: string;
  44278. /**
  44279. * File name for the left controller model.
  44280. */
  44281. static MODEL_LEFT_FILENAME: string;
  44282. /**
  44283. * File name for the right controller model.
  44284. */
  44285. static MODEL_RIGHT_FILENAME: string;
  44286. /**
  44287. * Base Url for the Quest controller model.
  44288. */
  44289. static QUEST_MODEL_BASE_URL: string;
  44290. /**
  44291. * @hidden
  44292. * If the controllers are running on a device that needs the updated Quest controller models
  44293. */
  44294. static _IsQuest: boolean;
  44295. /**
  44296. * Fired when the secondary trigger on this controller is modified
  44297. */
  44298. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44299. /**
  44300. * Fired when the thumb rest on this controller is modified
  44301. */
  44302. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44303. /**
  44304. * Creates a new OculusTouchController from a gamepad
  44305. * @param vrGamepad the gamepad that the controller should be created from
  44306. */
  44307. constructor(vrGamepad: any);
  44308. /**
  44309. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44310. * @param scene scene in which to add meshes
  44311. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44312. */
  44313. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44314. /**
  44315. * Fired when the A button on this controller is modified
  44316. */
  44317. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44318. /**
  44319. * Fired when the B button on this controller is modified
  44320. */
  44321. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44322. /**
  44323. * Fired when the X button on this controller is modified
  44324. */
  44325. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44326. /**
  44327. * Fired when the Y button on this controller is modified
  44328. */
  44329. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44330. /**
  44331. * Called once for each button that changed state since the last frame
  44332. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44333. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44334. * 2) secondary trigger (same)
  44335. * 3) A (right) X (left), touch, pressed = value
  44336. * 4) B / Y
  44337. * 5) thumb rest
  44338. * @param buttonIdx Which button index changed
  44339. * @param state New state of the button
  44340. * @param changes Which properties on the state changed since last frame
  44341. */
  44342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44343. }
  44344. }
  44345. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44346. import { Scene } from "babylonjs/scene";
  44347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44348. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44349. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44350. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44351. import { Observable } from "babylonjs/Misc/observable";
  44352. /**
  44353. * Vive Controller
  44354. */
  44355. export class ViveController extends WebVRController {
  44356. /**
  44357. * Base Url for the controller model.
  44358. */
  44359. static MODEL_BASE_URL: string;
  44360. /**
  44361. * File name for the controller model.
  44362. */
  44363. static MODEL_FILENAME: string;
  44364. /**
  44365. * Creates a new ViveController from a gamepad
  44366. * @param vrGamepad the gamepad that the controller should be created from
  44367. */
  44368. constructor(vrGamepad: any);
  44369. /**
  44370. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44371. * @param scene scene in which to add meshes
  44372. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44373. */
  44374. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44375. /**
  44376. * Fired when the left button on this controller is modified
  44377. */
  44378. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44379. /**
  44380. * Fired when the right button on this controller is modified
  44381. */
  44382. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44383. /**
  44384. * Fired when the menu button on this controller is modified
  44385. */
  44386. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44387. /**
  44388. * Called once for each button that changed state since the last frame
  44389. * Vive mapping:
  44390. * 0: touchpad
  44391. * 1: trigger
  44392. * 2: left AND right buttons
  44393. * 3: menu button
  44394. * @param buttonIdx Which button index changed
  44395. * @param state New state of the button
  44396. * @param changes Which properties on the state changed since last frame
  44397. */
  44398. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44399. }
  44400. }
  44401. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44402. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44403. /**
  44404. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44405. */
  44406. export class WebXRControllerModelLoader {
  44407. /**
  44408. * Creates the WebXRControllerModelLoader
  44409. * @param input xr input that creates the controllers
  44410. */
  44411. constructor(input: WebXRInput);
  44412. }
  44413. }
  44414. declare module "babylonjs/Cameras/XR/index" {
  44415. export * from "babylonjs/Cameras/XR/webXRCamera";
  44416. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44417. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44418. export * from "babylonjs/Cameras/XR/webXRInput";
  44419. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44420. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44421. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44422. export * from "babylonjs/Cameras/XR/webXRController";
  44423. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44424. export * from "babylonjs/Cameras/XR/webXRTypes";
  44425. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44426. }
  44427. declare module "babylonjs/Cameras/RigModes/index" {
  44428. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44429. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44430. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44431. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44432. }
  44433. declare module "babylonjs/Cameras/index" {
  44434. export * from "babylonjs/Cameras/Inputs/index";
  44435. export * from "babylonjs/Cameras/cameraInputsManager";
  44436. export * from "babylonjs/Cameras/camera";
  44437. export * from "babylonjs/Cameras/targetCamera";
  44438. export * from "babylonjs/Cameras/freeCamera";
  44439. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44440. export * from "babylonjs/Cameras/touchCamera";
  44441. export * from "babylonjs/Cameras/arcRotateCamera";
  44442. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44443. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44444. export * from "babylonjs/Cameras/flyCamera";
  44445. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44446. export * from "babylonjs/Cameras/followCamera";
  44447. export * from "babylonjs/Cameras/followCameraInputsManager";
  44448. export * from "babylonjs/Cameras/gamepadCamera";
  44449. export * from "babylonjs/Cameras/Stereoscopic/index";
  44450. export * from "babylonjs/Cameras/universalCamera";
  44451. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44452. export * from "babylonjs/Cameras/VR/index";
  44453. export * from "babylonjs/Cameras/XR/index";
  44454. export * from "babylonjs/Cameras/RigModes/index";
  44455. }
  44456. declare module "babylonjs/Collisions/index" {
  44457. export * from "babylonjs/Collisions/collider";
  44458. export * from "babylonjs/Collisions/collisionCoordinator";
  44459. export * from "babylonjs/Collisions/pickingInfo";
  44460. export * from "babylonjs/Collisions/intersectionInfo";
  44461. export * from "babylonjs/Collisions/meshCollisionData";
  44462. }
  44463. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44464. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44465. import { Vector3 } from "babylonjs/Maths/math.vector";
  44466. import { Ray } from "babylonjs/Culling/ray";
  44467. import { Plane } from "babylonjs/Maths/math.plane";
  44468. /**
  44469. * Contains an array of blocks representing the octree
  44470. */
  44471. export interface IOctreeContainer<T> {
  44472. /**
  44473. * Blocks within the octree
  44474. */
  44475. blocks: Array<OctreeBlock<T>>;
  44476. }
  44477. /**
  44478. * Class used to store a cell in an octree
  44479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44480. */
  44481. export class OctreeBlock<T> {
  44482. /**
  44483. * Gets the content of the current block
  44484. */
  44485. entries: T[];
  44486. /**
  44487. * Gets the list of block children
  44488. */
  44489. blocks: Array<OctreeBlock<T>>;
  44490. private _depth;
  44491. private _maxDepth;
  44492. private _capacity;
  44493. private _minPoint;
  44494. private _maxPoint;
  44495. private _boundingVectors;
  44496. private _creationFunc;
  44497. /**
  44498. * Creates a new block
  44499. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44500. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44501. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44502. * @param depth defines the current depth of this block in the octree
  44503. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44504. * @param creationFunc defines a callback to call when an element is added to the block
  44505. */
  44506. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44507. /**
  44508. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44509. */
  44510. readonly capacity: number;
  44511. /**
  44512. * Gets the minimum vector (in world space) of the block's bounding box
  44513. */
  44514. readonly minPoint: Vector3;
  44515. /**
  44516. * Gets the maximum vector (in world space) of the block's bounding box
  44517. */
  44518. readonly maxPoint: Vector3;
  44519. /**
  44520. * Add a new element to this block
  44521. * @param entry defines the element to add
  44522. */
  44523. addEntry(entry: T): void;
  44524. /**
  44525. * Remove an element from this block
  44526. * @param entry defines the element to remove
  44527. */
  44528. removeEntry(entry: T): void;
  44529. /**
  44530. * Add an array of elements to this block
  44531. * @param entries defines the array of elements to add
  44532. */
  44533. addEntries(entries: T[]): void;
  44534. /**
  44535. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44536. * @param frustumPlanes defines the frustum planes to test
  44537. * @param selection defines the array to store current content if selection is positive
  44538. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44539. */
  44540. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44541. /**
  44542. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44543. * @param sphereCenter defines the bounding sphere center
  44544. * @param sphereRadius defines the bounding sphere radius
  44545. * @param selection defines the array to store current content if selection is positive
  44546. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44547. */
  44548. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44549. /**
  44550. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44551. * @param ray defines the ray to test with
  44552. * @param selection defines the array to store current content if selection is positive
  44553. */
  44554. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44555. /**
  44556. * Subdivide the content into child blocks (this block will then be empty)
  44557. */
  44558. createInnerBlocks(): void;
  44559. /**
  44560. * @hidden
  44561. */
  44562. 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;
  44563. }
  44564. }
  44565. declare module "babylonjs/Culling/Octrees/octree" {
  44566. import { SmartArray } from "babylonjs/Misc/smartArray";
  44567. import { Vector3 } from "babylonjs/Maths/math.vector";
  44568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44570. import { Ray } from "babylonjs/Culling/ray";
  44571. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44572. import { Plane } from "babylonjs/Maths/math.plane";
  44573. /**
  44574. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44575. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44576. */
  44577. export class Octree<T> {
  44578. /** 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.) */
  44579. maxDepth: number;
  44580. /**
  44581. * Blocks within the octree containing objects
  44582. */
  44583. blocks: Array<OctreeBlock<T>>;
  44584. /**
  44585. * Content stored in the octree
  44586. */
  44587. dynamicContent: T[];
  44588. private _maxBlockCapacity;
  44589. private _selectionContent;
  44590. private _creationFunc;
  44591. /**
  44592. * Creates a octree
  44593. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44594. * @param creationFunc function to be used to instatiate the octree
  44595. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44596. * @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.)
  44597. */
  44598. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44599. /** 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.) */
  44600. maxDepth?: number);
  44601. /**
  44602. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44603. * @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);
  44604. * @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);
  44605. * @param entries meshes to be added to the octree blocks
  44606. */
  44607. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44608. /**
  44609. * Adds a mesh to the octree
  44610. * @param entry Mesh to add to the octree
  44611. */
  44612. addMesh(entry: T): void;
  44613. /**
  44614. * Remove an element from the octree
  44615. * @param entry defines the element to remove
  44616. */
  44617. removeMesh(entry: T): void;
  44618. /**
  44619. * Selects an array of meshes within the frustum
  44620. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44621. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44622. * @returns array of meshes within the frustum
  44623. */
  44624. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44625. /**
  44626. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44627. * @param sphereCenter defines the bounding sphere center
  44628. * @param sphereRadius defines the bounding sphere radius
  44629. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44630. * @returns an array of objects that intersect the sphere
  44631. */
  44632. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44633. /**
  44634. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44635. * @param ray defines the ray to test with
  44636. * @returns array of intersected objects
  44637. */
  44638. intersectsRay(ray: Ray): SmartArray<T>;
  44639. /**
  44640. * Adds a mesh into the octree block if it intersects the block
  44641. */
  44642. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44643. /**
  44644. * Adds a submesh into the octree block if it intersects the block
  44645. */
  44646. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44647. }
  44648. }
  44649. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44650. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44651. import { Scene } from "babylonjs/scene";
  44652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44654. import { Ray } from "babylonjs/Culling/ray";
  44655. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44656. import { Collider } from "babylonjs/Collisions/collider";
  44657. module "babylonjs/scene" {
  44658. interface Scene {
  44659. /**
  44660. * @hidden
  44661. * Backing Filed
  44662. */
  44663. _selectionOctree: Octree<AbstractMesh>;
  44664. /**
  44665. * Gets the octree used to boost mesh selection (picking)
  44666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44667. */
  44668. selectionOctree: Octree<AbstractMesh>;
  44669. /**
  44670. * Creates or updates the octree used to boost selection (picking)
  44671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44672. * @param maxCapacity defines the maximum capacity per leaf
  44673. * @param maxDepth defines the maximum depth of the octree
  44674. * @returns an octree of AbstractMesh
  44675. */
  44676. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44677. }
  44678. }
  44679. module "babylonjs/Meshes/abstractMesh" {
  44680. interface AbstractMesh {
  44681. /**
  44682. * @hidden
  44683. * Backing Field
  44684. */
  44685. _submeshesOctree: Octree<SubMesh>;
  44686. /**
  44687. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44688. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44689. * @param maxCapacity defines the maximum size of each block (64 by default)
  44690. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44691. * @returns the new octree
  44692. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44694. */
  44695. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44696. }
  44697. }
  44698. /**
  44699. * Defines the octree scene component responsible to manage any octrees
  44700. * in a given scene.
  44701. */
  44702. export class OctreeSceneComponent {
  44703. /**
  44704. * The component name help to identify the component in the list of scene components.
  44705. */
  44706. readonly name: string;
  44707. /**
  44708. * The scene the component belongs to.
  44709. */
  44710. scene: Scene;
  44711. /**
  44712. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44713. */
  44714. readonly checksIsEnabled: boolean;
  44715. /**
  44716. * Creates a new instance of the component for the given scene
  44717. * @param scene Defines the scene to register the component in
  44718. */
  44719. constructor(scene: Scene);
  44720. /**
  44721. * Registers the component in a given scene
  44722. */
  44723. register(): void;
  44724. /**
  44725. * Return the list of active meshes
  44726. * @returns the list of active meshes
  44727. */
  44728. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44729. /**
  44730. * Return the list of active sub meshes
  44731. * @param mesh The mesh to get the candidates sub meshes from
  44732. * @returns the list of active sub meshes
  44733. */
  44734. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44735. private _tempRay;
  44736. /**
  44737. * Return the list of sub meshes intersecting with a given local ray
  44738. * @param mesh defines the mesh to find the submesh for
  44739. * @param localRay defines the ray in local space
  44740. * @returns the list of intersecting sub meshes
  44741. */
  44742. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44743. /**
  44744. * Return the list of sub meshes colliding with a collider
  44745. * @param mesh defines the mesh to find the submesh for
  44746. * @param collider defines the collider to evaluate the collision against
  44747. * @returns the list of colliding sub meshes
  44748. */
  44749. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44750. /**
  44751. * Rebuilds the elements related to this component in case of
  44752. * context lost for instance.
  44753. */
  44754. rebuild(): void;
  44755. /**
  44756. * Disposes the component and the associated ressources.
  44757. */
  44758. dispose(): void;
  44759. }
  44760. }
  44761. declare module "babylonjs/Culling/Octrees/index" {
  44762. export * from "babylonjs/Culling/Octrees/octree";
  44763. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44764. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44765. }
  44766. declare module "babylonjs/Culling/index" {
  44767. export * from "babylonjs/Culling/boundingBox";
  44768. export * from "babylonjs/Culling/boundingInfo";
  44769. export * from "babylonjs/Culling/boundingSphere";
  44770. export * from "babylonjs/Culling/Octrees/index";
  44771. export * from "babylonjs/Culling/ray";
  44772. }
  44773. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44774. import { IDisposable, Scene } from "babylonjs/scene";
  44775. import { Nullable } from "babylonjs/types";
  44776. import { Observable } from "babylonjs/Misc/observable";
  44777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44778. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44779. import { Camera } from "babylonjs/Cameras/camera";
  44780. /**
  44781. * Renders a layer on top of an existing scene
  44782. */
  44783. export class UtilityLayerRenderer implements IDisposable {
  44784. /** the original scene that will be rendered on top of */
  44785. originalScene: Scene;
  44786. private _pointerCaptures;
  44787. private _lastPointerEvents;
  44788. private static _DefaultUtilityLayer;
  44789. private static _DefaultKeepDepthUtilityLayer;
  44790. private _sharedGizmoLight;
  44791. private _renderCamera;
  44792. /**
  44793. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44794. * @returns the camera that is used when rendering the utility layer
  44795. */
  44796. getRenderCamera(): Nullable<Camera>;
  44797. /**
  44798. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44799. * @param cam the camera that should be used when rendering the utility layer
  44800. */
  44801. setRenderCamera(cam: Nullable<Camera>): void;
  44802. /**
  44803. * @hidden
  44804. * Light which used by gizmos to get light shading
  44805. */
  44806. _getSharedGizmoLight(): HemisphericLight;
  44807. /**
  44808. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44809. */
  44810. pickUtilitySceneFirst: boolean;
  44811. /**
  44812. * 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)
  44813. */
  44814. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44815. /**
  44816. * 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)
  44817. */
  44818. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44819. /**
  44820. * The scene that is rendered on top of the original scene
  44821. */
  44822. utilityLayerScene: Scene;
  44823. /**
  44824. * If the utility layer should automatically be rendered on top of existing scene
  44825. */
  44826. shouldRender: boolean;
  44827. /**
  44828. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44829. */
  44830. onlyCheckPointerDownEvents: boolean;
  44831. /**
  44832. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44833. */
  44834. processAllEvents: boolean;
  44835. /**
  44836. * Observable raised when the pointer move from the utility layer scene to the main scene
  44837. */
  44838. onPointerOutObservable: Observable<number>;
  44839. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44840. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44841. private _afterRenderObserver;
  44842. private _sceneDisposeObserver;
  44843. private _originalPointerObserver;
  44844. /**
  44845. * Instantiates a UtilityLayerRenderer
  44846. * @param originalScene the original scene that will be rendered on top of
  44847. * @param handleEvents boolean indicating if the utility layer should handle events
  44848. */
  44849. constructor(
  44850. /** the original scene that will be rendered on top of */
  44851. originalScene: Scene, handleEvents?: boolean);
  44852. private _notifyObservers;
  44853. /**
  44854. * Renders the utility layers scene on top of the original scene
  44855. */
  44856. render(): void;
  44857. /**
  44858. * Disposes of the renderer
  44859. */
  44860. dispose(): void;
  44861. private _updateCamera;
  44862. }
  44863. }
  44864. declare module "babylonjs/Gizmos/gizmo" {
  44865. import { Nullable } from "babylonjs/types";
  44866. import { IDisposable } from "babylonjs/scene";
  44867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44868. import { Mesh } from "babylonjs/Meshes/mesh";
  44869. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44870. /**
  44871. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44872. */
  44873. export class Gizmo implements IDisposable {
  44874. /** The utility layer the gizmo will be added to */
  44875. gizmoLayer: UtilityLayerRenderer;
  44876. /**
  44877. * The root mesh of the gizmo
  44878. */
  44879. _rootMesh: Mesh;
  44880. private _attachedMesh;
  44881. /**
  44882. * Ratio for the scale of the gizmo (Default: 1)
  44883. */
  44884. scaleRatio: number;
  44885. /**
  44886. * If a custom mesh has been set (Default: false)
  44887. */
  44888. protected _customMeshSet: boolean;
  44889. /**
  44890. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44891. * * When set, interactions will be enabled
  44892. */
  44893. attachedMesh: Nullable<AbstractMesh>;
  44894. /**
  44895. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44896. * @param mesh The mesh to replace the default mesh of the gizmo
  44897. */
  44898. setCustomMesh(mesh: Mesh): void;
  44899. /**
  44900. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44901. */
  44902. updateGizmoRotationToMatchAttachedMesh: boolean;
  44903. /**
  44904. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44905. */
  44906. updateGizmoPositionToMatchAttachedMesh: boolean;
  44907. /**
  44908. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44909. */
  44910. updateScale: boolean;
  44911. protected _interactionsEnabled: boolean;
  44912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44913. private _beforeRenderObserver;
  44914. private _tempVector;
  44915. /**
  44916. * Creates a gizmo
  44917. * @param gizmoLayer The utility layer the gizmo will be added to
  44918. */
  44919. constructor(
  44920. /** The utility layer the gizmo will be added to */
  44921. gizmoLayer?: UtilityLayerRenderer);
  44922. /**
  44923. * Updates the gizmo to match the attached mesh's position/rotation
  44924. */
  44925. protected _update(): void;
  44926. /**
  44927. * Disposes of the gizmo
  44928. */
  44929. dispose(): void;
  44930. }
  44931. }
  44932. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44933. import { Observable } from "babylonjs/Misc/observable";
  44934. import { Nullable } from "babylonjs/types";
  44935. import { Vector3 } from "babylonjs/Maths/math.vector";
  44936. import { Color3 } from "babylonjs/Maths/math.color";
  44937. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44939. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44940. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44941. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44942. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44943. import { Scene } from "babylonjs/scene";
  44944. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44945. /**
  44946. * Single plane drag gizmo
  44947. */
  44948. export class PlaneDragGizmo extends Gizmo {
  44949. /**
  44950. * Drag behavior responsible for the gizmos dragging interactions
  44951. */
  44952. dragBehavior: PointerDragBehavior;
  44953. private _pointerObserver;
  44954. /**
  44955. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44956. */
  44957. snapDistance: number;
  44958. /**
  44959. * Event that fires each time the gizmo snaps to a new location.
  44960. * * snapDistance is the the change in distance
  44961. */
  44962. onSnapObservable: Observable<{
  44963. snapDistance: number;
  44964. }>;
  44965. private _plane;
  44966. private _coloredMaterial;
  44967. private _hoverMaterial;
  44968. private _isEnabled;
  44969. private _parent;
  44970. /** @hidden */
  44971. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44972. /** @hidden */
  44973. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44974. /**
  44975. * Creates a PlaneDragGizmo
  44976. * @param gizmoLayer The utility layer the gizmo will be added to
  44977. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44978. * @param color The color of the gizmo
  44979. */
  44980. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44981. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44982. /**
  44983. * If the gizmo is enabled
  44984. */
  44985. isEnabled: boolean;
  44986. /**
  44987. * Disposes of the gizmo
  44988. */
  44989. dispose(): void;
  44990. }
  44991. }
  44992. declare module "babylonjs/Gizmos/positionGizmo" {
  44993. import { Observable } from "babylonjs/Misc/observable";
  44994. import { Nullable } from "babylonjs/types";
  44995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44996. import { Mesh } from "babylonjs/Meshes/mesh";
  44997. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44998. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44999. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45000. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45001. /**
  45002. * Gizmo that enables dragging a mesh along 3 axis
  45003. */
  45004. export class PositionGizmo extends Gizmo {
  45005. /**
  45006. * Internal gizmo used for interactions on the x axis
  45007. */
  45008. xGizmo: AxisDragGizmo;
  45009. /**
  45010. * Internal gizmo used for interactions on the y axis
  45011. */
  45012. yGizmo: AxisDragGizmo;
  45013. /**
  45014. * Internal gizmo used for interactions on the z axis
  45015. */
  45016. zGizmo: AxisDragGizmo;
  45017. /**
  45018. * Internal gizmo used for interactions on the yz plane
  45019. */
  45020. xPlaneGizmo: PlaneDragGizmo;
  45021. /**
  45022. * Internal gizmo used for interactions on the xz plane
  45023. */
  45024. yPlaneGizmo: PlaneDragGizmo;
  45025. /**
  45026. * Internal gizmo used for interactions on the xy plane
  45027. */
  45028. zPlaneGizmo: PlaneDragGizmo;
  45029. /**
  45030. * private variables
  45031. */
  45032. private _meshAttached;
  45033. private _updateGizmoRotationToMatchAttachedMesh;
  45034. private _snapDistance;
  45035. private _scaleRatio;
  45036. /** Fires an event when any of it's sub gizmos are dragged */
  45037. onDragStartObservable: Observable<unknown>;
  45038. /** Fires an event when any of it's sub gizmos are released from dragging */
  45039. onDragEndObservable: Observable<unknown>;
  45040. /**
  45041. * If set to true, planar drag is enabled
  45042. */
  45043. private _planarGizmoEnabled;
  45044. attachedMesh: Nullable<AbstractMesh>;
  45045. /**
  45046. * Creates a PositionGizmo
  45047. * @param gizmoLayer The utility layer the gizmo will be added to
  45048. */
  45049. constructor(gizmoLayer?: UtilityLayerRenderer);
  45050. /**
  45051. * If the planar drag gizmo is enabled
  45052. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45053. */
  45054. planarGizmoEnabled: boolean;
  45055. updateGizmoRotationToMatchAttachedMesh: boolean;
  45056. /**
  45057. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45058. */
  45059. snapDistance: number;
  45060. /**
  45061. * Ratio for the scale of the gizmo (Default: 1)
  45062. */
  45063. scaleRatio: number;
  45064. /**
  45065. * Disposes of the gizmo
  45066. */
  45067. dispose(): void;
  45068. /**
  45069. * CustomMeshes are not supported by this gizmo
  45070. * @param mesh The mesh to replace the default mesh of the gizmo
  45071. */
  45072. setCustomMesh(mesh: Mesh): void;
  45073. }
  45074. }
  45075. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45076. import { Observable } from "babylonjs/Misc/observable";
  45077. import { Nullable } from "babylonjs/types";
  45078. import { Vector3 } from "babylonjs/Maths/math.vector";
  45079. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45081. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45082. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45083. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45084. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45085. import { Scene } from "babylonjs/scene";
  45086. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45087. import { Color3 } from "babylonjs/Maths/math.color";
  45088. /**
  45089. * Single axis drag gizmo
  45090. */
  45091. export class AxisDragGizmo extends Gizmo {
  45092. /**
  45093. * Drag behavior responsible for the gizmos dragging interactions
  45094. */
  45095. dragBehavior: PointerDragBehavior;
  45096. private _pointerObserver;
  45097. /**
  45098. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45099. */
  45100. snapDistance: number;
  45101. /**
  45102. * Event that fires each time the gizmo snaps to a new location.
  45103. * * snapDistance is the the change in distance
  45104. */
  45105. onSnapObservable: Observable<{
  45106. snapDistance: number;
  45107. }>;
  45108. private _isEnabled;
  45109. private _parent;
  45110. private _arrow;
  45111. private _coloredMaterial;
  45112. private _hoverMaterial;
  45113. /** @hidden */
  45114. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45115. /** @hidden */
  45116. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45117. /**
  45118. * Creates an AxisDragGizmo
  45119. * @param gizmoLayer The utility layer the gizmo will be added to
  45120. * @param dragAxis The axis which the gizmo will be able to drag on
  45121. * @param color The color of the gizmo
  45122. */
  45123. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45124. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45125. /**
  45126. * If the gizmo is enabled
  45127. */
  45128. isEnabled: boolean;
  45129. /**
  45130. * Disposes of the gizmo
  45131. */
  45132. dispose(): void;
  45133. }
  45134. }
  45135. declare module "babylonjs/Debug/axesViewer" {
  45136. import { Vector3 } from "babylonjs/Maths/math.vector";
  45137. import { Nullable } from "babylonjs/types";
  45138. import { Scene } from "babylonjs/scene";
  45139. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45140. /**
  45141. * The Axes viewer will show 3 axes in a specific point in space
  45142. */
  45143. export class AxesViewer {
  45144. private _xAxis;
  45145. private _yAxis;
  45146. private _zAxis;
  45147. private _scaleLinesFactor;
  45148. private _instanced;
  45149. /**
  45150. * Gets the hosting scene
  45151. */
  45152. scene: Scene;
  45153. /**
  45154. * Gets or sets a number used to scale line length
  45155. */
  45156. scaleLines: number;
  45157. /** Gets the node hierarchy used to render x-axis */
  45158. readonly xAxis: TransformNode;
  45159. /** Gets the node hierarchy used to render y-axis */
  45160. readonly yAxis: TransformNode;
  45161. /** Gets the node hierarchy used to render z-axis */
  45162. readonly zAxis: TransformNode;
  45163. /**
  45164. * Creates a new AxesViewer
  45165. * @param scene defines the hosting scene
  45166. * @param scaleLines defines a number used to scale line length (1 by default)
  45167. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45168. * @param xAxis defines the node hierarchy used to render the x-axis
  45169. * @param yAxis defines the node hierarchy used to render the y-axis
  45170. * @param zAxis defines the node hierarchy used to render the z-axis
  45171. */
  45172. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45173. /**
  45174. * Force the viewer to update
  45175. * @param position defines the position of the viewer
  45176. * @param xaxis defines the x axis of the viewer
  45177. * @param yaxis defines the y axis of the viewer
  45178. * @param zaxis defines the z axis of the viewer
  45179. */
  45180. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45181. /**
  45182. * Creates an instance of this axes viewer.
  45183. * @returns a new axes viewer with instanced meshes
  45184. */
  45185. createInstance(): AxesViewer;
  45186. /** Releases resources */
  45187. dispose(): void;
  45188. private static _SetRenderingGroupId;
  45189. }
  45190. }
  45191. declare module "babylonjs/Debug/boneAxesViewer" {
  45192. import { Nullable } from "babylonjs/types";
  45193. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45194. import { Vector3 } from "babylonjs/Maths/math.vector";
  45195. import { Mesh } from "babylonjs/Meshes/mesh";
  45196. import { Bone } from "babylonjs/Bones/bone";
  45197. import { Scene } from "babylonjs/scene";
  45198. /**
  45199. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45200. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45201. */
  45202. export class BoneAxesViewer extends AxesViewer {
  45203. /**
  45204. * Gets or sets the target mesh where to display the axes viewer
  45205. */
  45206. mesh: Nullable<Mesh>;
  45207. /**
  45208. * Gets or sets the target bone where to display the axes viewer
  45209. */
  45210. bone: Nullable<Bone>;
  45211. /** Gets current position */
  45212. pos: Vector3;
  45213. /** Gets direction of X axis */
  45214. xaxis: Vector3;
  45215. /** Gets direction of Y axis */
  45216. yaxis: Vector3;
  45217. /** Gets direction of Z axis */
  45218. zaxis: Vector3;
  45219. /**
  45220. * Creates a new BoneAxesViewer
  45221. * @param scene defines the hosting scene
  45222. * @param bone defines the target bone
  45223. * @param mesh defines the target mesh
  45224. * @param scaleLines defines a scaling factor for line length (1 by default)
  45225. */
  45226. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45227. /**
  45228. * Force the viewer to update
  45229. */
  45230. update(): void;
  45231. /** Releases resources */
  45232. dispose(): void;
  45233. }
  45234. }
  45235. declare module "babylonjs/Debug/debugLayer" {
  45236. import { Scene } from "babylonjs/scene";
  45237. /**
  45238. * Interface used to define scene explorer extensibility option
  45239. */
  45240. export interface IExplorerExtensibilityOption {
  45241. /**
  45242. * Define the option label
  45243. */
  45244. label: string;
  45245. /**
  45246. * Defines the action to execute on click
  45247. */
  45248. action: (entity: any) => void;
  45249. }
  45250. /**
  45251. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45252. */
  45253. export interface IExplorerExtensibilityGroup {
  45254. /**
  45255. * Defines a predicate to test if a given type mut be extended
  45256. */
  45257. predicate: (entity: any) => boolean;
  45258. /**
  45259. * Gets the list of options added to a type
  45260. */
  45261. entries: IExplorerExtensibilityOption[];
  45262. }
  45263. /**
  45264. * Interface used to define the options to use to create the Inspector
  45265. */
  45266. export interface IInspectorOptions {
  45267. /**
  45268. * Display in overlay mode (default: false)
  45269. */
  45270. overlay?: boolean;
  45271. /**
  45272. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45273. */
  45274. globalRoot?: HTMLElement;
  45275. /**
  45276. * Display the Scene explorer
  45277. */
  45278. showExplorer?: boolean;
  45279. /**
  45280. * Display the property inspector
  45281. */
  45282. showInspector?: boolean;
  45283. /**
  45284. * Display in embed mode (both panes on the right)
  45285. */
  45286. embedMode?: boolean;
  45287. /**
  45288. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45289. */
  45290. handleResize?: boolean;
  45291. /**
  45292. * Allow the panes to popup (default: true)
  45293. */
  45294. enablePopup?: boolean;
  45295. /**
  45296. * Allow the panes to be closed by users (default: true)
  45297. */
  45298. enableClose?: boolean;
  45299. /**
  45300. * Optional list of extensibility entries
  45301. */
  45302. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45303. /**
  45304. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45305. */
  45306. inspectorURL?: string;
  45307. }
  45308. module "babylonjs/scene" {
  45309. interface Scene {
  45310. /**
  45311. * @hidden
  45312. * Backing field
  45313. */
  45314. _debugLayer: DebugLayer;
  45315. /**
  45316. * Gets the debug layer (aka Inspector) associated with the scene
  45317. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45318. */
  45319. debugLayer: DebugLayer;
  45320. }
  45321. }
  45322. /**
  45323. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45324. * what is happening in your scene
  45325. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45326. */
  45327. export class DebugLayer {
  45328. /**
  45329. * Define the url to get the inspector script from.
  45330. * By default it uses the babylonjs CDN.
  45331. * @ignoreNaming
  45332. */
  45333. static InspectorURL: string;
  45334. private _scene;
  45335. private BJSINSPECTOR;
  45336. private _onPropertyChangedObservable?;
  45337. /**
  45338. * Observable triggered when a property is changed through the inspector.
  45339. */
  45340. readonly onPropertyChangedObservable: any;
  45341. /**
  45342. * Instantiates a new debug layer.
  45343. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45344. * what is happening in your scene
  45345. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45346. * @param scene Defines the scene to inspect
  45347. */
  45348. constructor(scene: Scene);
  45349. /** Creates the inspector window. */
  45350. private _createInspector;
  45351. /**
  45352. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45353. * @param entity defines the entity to select
  45354. * @param lineContainerTitle defines the specific block to highlight
  45355. */
  45356. select(entity: any, lineContainerTitle?: string): void;
  45357. /** Get the inspector from bundle or global */
  45358. private _getGlobalInspector;
  45359. /**
  45360. * Get if the inspector is visible or not.
  45361. * @returns true if visible otherwise, false
  45362. */
  45363. isVisible(): boolean;
  45364. /**
  45365. * Hide the inspector and close its window.
  45366. */
  45367. hide(): void;
  45368. /**
  45369. * Launch the debugLayer.
  45370. * @param config Define the configuration of the inspector
  45371. * @return a promise fulfilled when the debug layer is visible
  45372. */
  45373. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45374. }
  45375. }
  45376. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45377. import { Nullable } from "babylonjs/types";
  45378. import { Scene } from "babylonjs/scene";
  45379. import { Vector4 } from "babylonjs/Maths/math.vector";
  45380. import { Color4 } from "babylonjs/Maths/math.color";
  45381. import { Mesh } from "babylonjs/Meshes/mesh";
  45382. /**
  45383. * Class containing static functions to help procedurally build meshes
  45384. */
  45385. export class BoxBuilder {
  45386. /**
  45387. * Creates a box mesh
  45388. * * The parameter `size` sets the size (float) of each box side (default 1)
  45389. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45390. * * 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)
  45391. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45395. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45396. * @param name defines the name of the mesh
  45397. * @param options defines the options used to create the mesh
  45398. * @param scene defines the hosting scene
  45399. * @returns the box mesh
  45400. */
  45401. static CreateBox(name: string, options: {
  45402. size?: number;
  45403. width?: number;
  45404. height?: number;
  45405. depth?: number;
  45406. faceUV?: Vector4[];
  45407. faceColors?: Color4[];
  45408. sideOrientation?: number;
  45409. frontUVs?: Vector4;
  45410. backUVs?: Vector4;
  45411. wrap?: boolean;
  45412. topBaseAt?: number;
  45413. bottomBaseAt?: number;
  45414. updatable?: boolean;
  45415. }, scene?: Nullable<Scene>): Mesh;
  45416. }
  45417. }
  45418. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45419. import { Vector4 } from "babylonjs/Maths/math.vector";
  45420. import { Mesh } from "babylonjs/Meshes/mesh";
  45421. import { Scene } from "babylonjs/scene";
  45422. import { Nullable } from "babylonjs/types";
  45423. /**
  45424. * Class containing static functions to help procedurally build meshes
  45425. */
  45426. export class SphereBuilder {
  45427. /**
  45428. * Creates a sphere mesh
  45429. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45430. * * 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`)
  45431. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45432. * * 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
  45433. * * 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)
  45434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45437. * @param name defines the name of the mesh
  45438. * @param options defines the options used to create the mesh
  45439. * @param scene defines the hosting scene
  45440. * @returns the sphere mesh
  45441. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45442. */
  45443. static CreateSphere(name: string, options: {
  45444. segments?: number;
  45445. diameter?: number;
  45446. diameterX?: number;
  45447. diameterY?: number;
  45448. diameterZ?: number;
  45449. arc?: number;
  45450. slice?: number;
  45451. sideOrientation?: number;
  45452. frontUVs?: Vector4;
  45453. backUVs?: Vector4;
  45454. updatable?: boolean;
  45455. }, scene?: Nullable<Scene>): Mesh;
  45456. }
  45457. }
  45458. declare module "babylonjs/Debug/physicsViewer" {
  45459. import { Nullable } from "babylonjs/types";
  45460. import { Scene } from "babylonjs/scene";
  45461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45462. import { Mesh } from "babylonjs/Meshes/mesh";
  45463. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45464. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45465. /**
  45466. * Used to show the physics impostor around the specific mesh
  45467. */
  45468. export class PhysicsViewer {
  45469. /** @hidden */
  45470. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45471. /** @hidden */
  45472. protected _meshes: Array<Nullable<AbstractMesh>>;
  45473. /** @hidden */
  45474. protected _scene: Nullable<Scene>;
  45475. /** @hidden */
  45476. protected _numMeshes: number;
  45477. /** @hidden */
  45478. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45479. private _renderFunction;
  45480. private _utilityLayer;
  45481. private _debugBoxMesh;
  45482. private _debugSphereMesh;
  45483. private _debugCylinderMesh;
  45484. private _debugMaterial;
  45485. private _debugMeshMeshes;
  45486. /**
  45487. * Creates a new PhysicsViewer
  45488. * @param scene defines the hosting scene
  45489. */
  45490. constructor(scene: Scene);
  45491. /** @hidden */
  45492. protected _updateDebugMeshes(): void;
  45493. /**
  45494. * Renders a specified physic impostor
  45495. * @param impostor defines the impostor to render
  45496. * @param targetMesh defines the mesh represented by the impostor
  45497. * @returns the new debug mesh used to render the impostor
  45498. */
  45499. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45500. /**
  45501. * Hides a specified physic impostor
  45502. * @param impostor defines the impostor to hide
  45503. */
  45504. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45505. private _getDebugMaterial;
  45506. private _getDebugBoxMesh;
  45507. private _getDebugSphereMesh;
  45508. private _getDebugCylinderMesh;
  45509. private _getDebugMeshMesh;
  45510. private _getDebugMesh;
  45511. /** Releases all resources */
  45512. dispose(): void;
  45513. }
  45514. }
  45515. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45516. import { Vector3 } from "babylonjs/Maths/math.vector";
  45517. import { Color4 } from "babylonjs/Maths/math.color";
  45518. import { Nullable } from "babylonjs/types";
  45519. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45520. import { Scene } from "babylonjs/scene";
  45521. /**
  45522. * Class containing static functions to help procedurally build meshes
  45523. */
  45524. export class LinesBuilder {
  45525. /**
  45526. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45527. * * 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
  45528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45529. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45530. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45531. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45532. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45533. * * 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
  45534. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45537. * @param name defines the name of the new line system
  45538. * @param options defines the options used to create the line system
  45539. * @param scene defines the hosting scene
  45540. * @returns a new line system mesh
  45541. */
  45542. static CreateLineSystem(name: string, options: {
  45543. lines: Vector3[][];
  45544. updatable?: boolean;
  45545. instance?: Nullable<LinesMesh>;
  45546. colors?: Nullable<Color4[][]>;
  45547. useVertexAlpha?: boolean;
  45548. }, scene: Nullable<Scene>): LinesMesh;
  45549. /**
  45550. * Creates a line mesh
  45551. * 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
  45552. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45553. * * The parameter `points` is an array successive Vector3
  45554. * * 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
  45555. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45556. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45557. * * When updating an instance, remember that only point positions can change, not the number of points
  45558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45560. * @param name defines the name of the new line system
  45561. * @param options defines the options used to create the line system
  45562. * @param scene defines the hosting scene
  45563. * @returns a new line mesh
  45564. */
  45565. static CreateLines(name: string, options: {
  45566. points: Vector3[];
  45567. updatable?: boolean;
  45568. instance?: Nullable<LinesMesh>;
  45569. colors?: Color4[];
  45570. useVertexAlpha?: boolean;
  45571. }, scene?: Nullable<Scene>): LinesMesh;
  45572. /**
  45573. * Creates a dashed line mesh
  45574. * * 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
  45575. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45576. * * The parameter `points` is an array successive Vector3
  45577. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45578. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45579. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45580. * * 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
  45581. * * When updating an instance, remember that only point positions can change, not the number of points
  45582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45583. * @param name defines the name of the mesh
  45584. * @param options defines the options used to create the mesh
  45585. * @param scene defines the hosting scene
  45586. * @returns the dashed line mesh
  45587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45588. */
  45589. static CreateDashedLines(name: string, options: {
  45590. points: Vector3[];
  45591. dashSize?: number;
  45592. gapSize?: number;
  45593. dashNb?: number;
  45594. updatable?: boolean;
  45595. instance?: LinesMesh;
  45596. }, scene?: Nullable<Scene>): LinesMesh;
  45597. }
  45598. }
  45599. declare module "babylonjs/Debug/rayHelper" {
  45600. import { Nullable } from "babylonjs/types";
  45601. import { Ray } from "babylonjs/Culling/ray";
  45602. import { Vector3 } from "babylonjs/Maths/math.vector";
  45603. import { Color3 } from "babylonjs/Maths/math.color";
  45604. import { Scene } from "babylonjs/scene";
  45605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45606. import "babylonjs/Meshes/Builders/linesBuilder";
  45607. /**
  45608. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45609. * in order to better appreciate the issue one might have.
  45610. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45611. */
  45612. export class RayHelper {
  45613. /**
  45614. * Defines the ray we are currently tryin to visualize.
  45615. */
  45616. ray: Nullable<Ray>;
  45617. private _renderPoints;
  45618. private _renderLine;
  45619. private _renderFunction;
  45620. private _scene;
  45621. private _updateToMeshFunction;
  45622. private _attachedToMesh;
  45623. private _meshSpaceDirection;
  45624. private _meshSpaceOrigin;
  45625. /**
  45626. * Helper function to create a colored helper in a scene in one line.
  45627. * @param ray Defines the ray we are currently tryin to visualize
  45628. * @param scene Defines the scene the ray is used in
  45629. * @param color Defines the color we want to see the ray in
  45630. * @returns The newly created ray helper.
  45631. */
  45632. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45633. /**
  45634. * Instantiate a new ray helper.
  45635. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45636. * in order to better appreciate the issue one might have.
  45637. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45638. * @param ray Defines the ray we are currently tryin to visualize
  45639. */
  45640. constructor(ray: Ray);
  45641. /**
  45642. * Shows the ray we are willing to debug.
  45643. * @param scene Defines the scene the ray needs to be rendered in
  45644. * @param color Defines the color the ray needs to be rendered in
  45645. */
  45646. show(scene: Scene, color?: Color3): void;
  45647. /**
  45648. * Hides the ray we are debugging.
  45649. */
  45650. hide(): void;
  45651. private _render;
  45652. /**
  45653. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45654. * @param mesh Defines the mesh we want the helper attached to
  45655. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45656. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45657. * @param length Defines the length of the ray
  45658. */
  45659. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45660. /**
  45661. * Detach the ray helper from the mesh it has previously been attached to.
  45662. */
  45663. detachFromMesh(): void;
  45664. private _updateToMesh;
  45665. /**
  45666. * Dispose the helper and release its associated resources.
  45667. */
  45668. dispose(): void;
  45669. }
  45670. }
  45671. declare module "babylonjs/Debug/skeletonViewer" {
  45672. import { Color3 } from "babylonjs/Maths/math.color";
  45673. import { Scene } from "babylonjs/scene";
  45674. import { Nullable } from "babylonjs/types";
  45675. import { Skeleton } from "babylonjs/Bones/skeleton";
  45676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45677. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45678. /**
  45679. * Class used to render a debug view of a given skeleton
  45680. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45681. */
  45682. export class SkeletonViewer {
  45683. /** defines the skeleton to render */
  45684. skeleton: Skeleton;
  45685. /** defines the mesh attached to the skeleton */
  45686. mesh: AbstractMesh;
  45687. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45688. autoUpdateBonesMatrices: boolean;
  45689. /** defines the rendering group id to use with the viewer */
  45690. renderingGroupId: number;
  45691. /** Gets or sets the color used to render the skeleton */
  45692. color: Color3;
  45693. private _scene;
  45694. private _debugLines;
  45695. private _debugMesh;
  45696. private _isEnabled;
  45697. private _renderFunction;
  45698. private _utilityLayer;
  45699. /**
  45700. * Returns the mesh used to render the bones
  45701. */
  45702. readonly debugMesh: Nullable<LinesMesh>;
  45703. /**
  45704. * Creates a new SkeletonViewer
  45705. * @param skeleton defines the skeleton to render
  45706. * @param mesh defines the mesh attached to the skeleton
  45707. * @param scene defines the hosting scene
  45708. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45709. * @param renderingGroupId defines the rendering group id to use with the viewer
  45710. */
  45711. constructor(
  45712. /** defines the skeleton to render */
  45713. skeleton: Skeleton,
  45714. /** defines the mesh attached to the skeleton */
  45715. mesh: AbstractMesh, scene: Scene,
  45716. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45717. autoUpdateBonesMatrices?: boolean,
  45718. /** defines the rendering group id to use with the viewer */
  45719. renderingGroupId?: number);
  45720. /** Gets or sets a boolean indicating if the viewer is enabled */
  45721. isEnabled: boolean;
  45722. private _getBonePosition;
  45723. private _getLinesForBonesWithLength;
  45724. private _getLinesForBonesNoLength;
  45725. /** Update the viewer to sync with current skeleton state */
  45726. update(): void;
  45727. /** Release associated resources */
  45728. dispose(): void;
  45729. }
  45730. }
  45731. declare module "babylonjs/Debug/index" {
  45732. export * from "babylonjs/Debug/axesViewer";
  45733. export * from "babylonjs/Debug/boneAxesViewer";
  45734. export * from "babylonjs/Debug/debugLayer";
  45735. export * from "babylonjs/Debug/physicsViewer";
  45736. export * from "babylonjs/Debug/rayHelper";
  45737. export * from "babylonjs/Debug/skeletonViewer";
  45738. }
  45739. declare module "babylonjs/Engines/nullEngine" {
  45740. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45741. import { Scene } from "babylonjs/scene";
  45742. import { Engine } from "babylonjs/Engines/engine";
  45743. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45744. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45746. import { Effect } from "babylonjs/Materials/effect";
  45747. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45748. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45749. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45750. /**
  45751. * Options to create the null engine
  45752. */
  45753. export class NullEngineOptions {
  45754. /**
  45755. * Render width (Default: 512)
  45756. */
  45757. renderWidth: number;
  45758. /**
  45759. * Render height (Default: 256)
  45760. */
  45761. renderHeight: number;
  45762. /**
  45763. * Texture size (Default: 512)
  45764. */
  45765. textureSize: number;
  45766. /**
  45767. * If delta time between frames should be constant
  45768. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45769. */
  45770. deterministicLockstep: boolean;
  45771. /**
  45772. * Maximum about of steps between frames (Default: 4)
  45773. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45774. */
  45775. lockstepMaxSteps: number;
  45776. }
  45777. /**
  45778. * The null engine class provides support for headless version of babylon.js.
  45779. * This can be used in server side scenario or for testing purposes
  45780. */
  45781. export class NullEngine extends Engine {
  45782. private _options;
  45783. /**
  45784. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45786. * @returns true if engine is in deterministic lock step mode
  45787. */
  45788. isDeterministicLockStep(): boolean;
  45789. /**
  45790. * Gets the max steps when engine is running in deterministic lock step
  45791. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45792. * @returns the max steps
  45793. */
  45794. getLockstepMaxSteps(): number;
  45795. /**
  45796. * Gets the current hardware scaling level.
  45797. * By default the hardware scaling level is computed from the window device ratio.
  45798. * 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.
  45799. * @returns a number indicating the current hardware scaling level
  45800. */
  45801. getHardwareScalingLevel(): number;
  45802. constructor(options?: NullEngineOptions);
  45803. /**
  45804. * Creates a vertex buffer
  45805. * @param vertices the data for the vertex buffer
  45806. * @returns the new WebGL static buffer
  45807. */
  45808. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45809. /**
  45810. * Creates a new index buffer
  45811. * @param indices defines the content of the index buffer
  45812. * @param updatable defines if the index buffer must be updatable
  45813. * @returns a new webGL buffer
  45814. */
  45815. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45816. /**
  45817. * Clear the current render buffer or the current render target (if any is set up)
  45818. * @param color defines the color to use
  45819. * @param backBuffer defines if the back buffer must be cleared
  45820. * @param depth defines if the depth buffer must be cleared
  45821. * @param stencil defines if the stencil buffer must be cleared
  45822. */
  45823. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45824. /**
  45825. * Gets the current render width
  45826. * @param useScreen defines if screen size must be used (or the current render target if any)
  45827. * @returns a number defining the current render width
  45828. */
  45829. getRenderWidth(useScreen?: boolean): number;
  45830. /**
  45831. * Gets the current render height
  45832. * @param useScreen defines if screen size must be used (or the current render target if any)
  45833. * @returns a number defining the current render height
  45834. */
  45835. getRenderHeight(useScreen?: boolean): number;
  45836. /**
  45837. * Set the WebGL's viewport
  45838. * @param viewport defines the viewport element to be used
  45839. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45840. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45841. */
  45842. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45843. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45844. /**
  45845. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45846. * @param pipelineContext defines the pipeline context to use
  45847. * @param uniformsNames defines the list of uniform names
  45848. * @returns an array of webGL uniform locations
  45849. */
  45850. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45851. /**
  45852. * Gets the lsit of active attributes for a given webGL program
  45853. * @param pipelineContext defines the pipeline context to use
  45854. * @param attributesNames defines the list of attribute names to get
  45855. * @returns an array of indices indicating the offset of each attribute
  45856. */
  45857. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45858. /**
  45859. * Binds an effect to the webGL context
  45860. * @param effect defines the effect to bind
  45861. */
  45862. bindSamplers(effect: Effect): void;
  45863. /**
  45864. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45865. * @param effect defines the effect to activate
  45866. */
  45867. enableEffect(effect: Effect): void;
  45868. /**
  45869. * Set various states to the webGL context
  45870. * @param culling defines backface culling state
  45871. * @param zOffset defines the value to apply to zOffset (0 by default)
  45872. * @param force defines if states must be applied even if cache is up to date
  45873. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45874. */
  45875. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45876. /**
  45877. * Set the value of an uniform to an array of int32
  45878. * @param uniform defines the webGL uniform location where to store the value
  45879. * @param array defines the array of int32 to store
  45880. */
  45881. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45882. /**
  45883. * Set the value of an uniform to an array of int32 (stored as vec2)
  45884. * @param uniform defines the webGL uniform location where to store the value
  45885. * @param array defines the array of int32 to store
  45886. */
  45887. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45888. /**
  45889. * Set the value of an uniform to an array of int32 (stored as vec3)
  45890. * @param uniform defines the webGL uniform location where to store the value
  45891. * @param array defines the array of int32 to store
  45892. */
  45893. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45894. /**
  45895. * Set the value of an uniform to an array of int32 (stored as vec4)
  45896. * @param uniform defines the webGL uniform location where to store the value
  45897. * @param array defines the array of int32 to store
  45898. */
  45899. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45900. /**
  45901. * Set the value of an uniform to an array of float32
  45902. * @param uniform defines the webGL uniform location where to store the value
  45903. * @param array defines the array of float32 to store
  45904. */
  45905. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45906. /**
  45907. * Set the value of an uniform to an array of float32 (stored as vec2)
  45908. * @param uniform defines the webGL uniform location where to store the value
  45909. * @param array defines the array of float32 to store
  45910. */
  45911. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45912. /**
  45913. * Set the value of an uniform to an array of float32 (stored as vec3)
  45914. * @param uniform defines the webGL uniform location where to store the value
  45915. * @param array defines the array of float32 to store
  45916. */
  45917. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45918. /**
  45919. * Set the value of an uniform to an array of float32 (stored as vec4)
  45920. * @param uniform defines the webGL uniform location where to store the value
  45921. * @param array defines the array of float32 to store
  45922. */
  45923. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45924. /**
  45925. * Set the value of an uniform to an array of number
  45926. * @param uniform defines the webGL uniform location where to store the value
  45927. * @param array defines the array of number to store
  45928. */
  45929. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45930. /**
  45931. * Set the value of an uniform to an array of number (stored as vec2)
  45932. * @param uniform defines the webGL uniform location where to store the value
  45933. * @param array defines the array of number to store
  45934. */
  45935. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45936. /**
  45937. * Set the value of an uniform to an array of number (stored as vec3)
  45938. * @param uniform defines the webGL uniform location where to store the value
  45939. * @param array defines the array of number to store
  45940. */
  45941. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45942. /**
  45943. * Set the value of an uniform to an array of number (stored as vec4)
  45944. * @param uniform defines the webGL uniform location where to store the value
  45945. * @param array defines the array of number to store
  45946. */
  45947. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45948. /**
  45949. * Set the value of an uniform to an array of float32 (stored as matrices)
  45950. * @param uniform defines the webGL uniform location where to store the value
  45951. * @param matrices defines the array of float32 to store
  45952. */
  45953. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45954. /**
  45955. * Set the value of an uniform to a matrix (3x3)
  45956. * @param uniform defines the webGL uniform location where to store the value
  45957. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45958. */
  45959. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45960. /**
  45961. * Set the value of an uniform to a matrix (2x2)
  45962. * @param uniform defines the webGL uniform location where to store the value
  45963. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45964. */
  45965. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45966. /**
  45967. * Set the value of an uniform to a number (float)
  45968. * @param uniform defines the webGL uniform location where to store the value
  45969. * @param value defines the float number to store
  45970. */
  45971. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45972. /**
  45973. * Set the value of an uniform to a vec2
  45974. * @param uniform defines the webGL uniform location where to store the value
  45975. * @param x defines the 1st component of the value
  45976. * @param y defines the 2nd component of the value
  45977. */
  45978. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45979. /**
  45980. * Set the value of an uniform to a vec3
  45981. * @param uniform defines the webGL uniform location where to store the value
  45982. * @param x defines the 1st component of the value
  45983. * @param y defines the 2nd component of the value
  45984. * @param z defines the 3rd component of the value
  45985. */
  45986. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45987. /**
  45988. * Set the value of an uniform to a boolean
  45989. * @param uniform defines the webGL uniform location where to store the value
  45990. * @param bool defines the boolean to store
  45991. */
  45992. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45993. /**
  45994. * Set the value of an uniform to a vec4
  45995. * @param uniform defines the webGL uniform location where to store the value
  45996. * @param x defines the 1st component of the value
  45997. * @param y defines the 2nd component of the value
  45998. * @param z defines the 3rd component of the value
  45999. * @param w defines the 4th component of the value
  46000. */
  46001. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46002. /**
  46003. * Sets the current alpha mode
  46004. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46005. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46006. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46007. */
  46008. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46009. /**
  46010. * Bind webGl buffers directly to the webGL context
  46011. * @param vertexBuffers defines the vertex buffer to bind
  46012. * @param indexBuffer defines the index buffer to bind
  46013. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46014. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46015. * @param effect defines the effect associated with the vertex buffer
  46016. */
  46017. bindBuffers(vertexBuffers: {
  46018. [key: string]: VertexBuffer;
  46019. }, indexBuffer: DataBuffer, effect: Effect): void;
  46020. /**
  46021. * Force the entire cache to be cleared
  46022. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46023. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46024. */
  46025. wipeCaches(bruteForce?: boolean): void;
  46026. /**
  46027. * Send a draw order
  46028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46029. * @param indexStart defines the starting index
  46030. * @param indexCount defines the number of index to draw
  46031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46032. */
  46033. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46034. /**
  46035. * Draw a list of indexed primitives
  46036. * @param fillMode defines the primitive to use
  46037. * @param indexStart defines the starting index
  46038. * @param indexCount defines the number of index to draw
  46039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46040. */
  46041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46042. /**
  46043. * Draw a list of unindexed primitives
  46044. * @param fillMode defines the primitive to use
  46045. * @param verticesStart defines the index of first vertex to draw
  46046. * @param verticesCount defines the count of vertices to draw
  46047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46048. */
  46049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46050. /** @hidden */
  46051. _createTexture(): WebGLTexture;
  46052. /** @hidden */
  46053. _releaseTexture(texture: InternalTexture): void;
  46054. /**
  46055. * Usually called from Texture.ts.
  46056. * Passed information to create a WebGLTexture
  46057. * @param urlArg defines a value which contains one of the following:
  46058. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46059. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46060. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46061. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46062. * @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)
  46063. * @param scene needed for loading to the correct scene
  46064. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46065. * @param onLoad optional callback to be called upon successful completion
  46066. * @param onError optional callback to be called upon failure
  46067. * @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
  46068. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46069. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46070. * @param forcedExtension defines the extension to use to pick the right loader
  46071. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46072. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46073. */
  46074. 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;
  46075. /**
  46076. * Creates a new render target texture
  46077. * @param size defines the size of the texture
  46078. * @param options defines the options used to create the texture
  46079. * @returns a new render target texture stored in an InternalTexture
  46080. */
  46081. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46082. /**
  46083. * Update the sampling mode of a given texture
  46084. * @param samplingMode defines the required sampling mode
  46085. * @param texture defines the texture to update
  46086. */
  46087. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46088. /**
  46089. * Binds the frame buffer to the specified texture.
  46090. * @param texture The texture to render to or null for the default canvas
  46091. * @param faceIndex The face of the texture to render to in case of cube texture
  46092. * @param requiredWidth The width of the target to render to
  46093. * @param requiredHeight The height of the target to render to
  46094. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46095. * @param depthStencilTexture The depth stencil texture to use to render
  46096. * @param lodLevel defines le lod level to bind to the frame buffer
  46097. */
  46098. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46099. /**
  46100. * Unbind the current render target texture from the webGL context
  46101. * @param texture defines the render target texture to unbind
  46102. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46103. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46104. */
  46105. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46106. /**
  46107. * Creates a dynamic vertex buffer
  46108. * @param vertices the data for the dynamic vertex buffer
  46109. * @returns the new WebGL dynamic buffer
  46110. */
  46111. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46112. /**
  46113. * Update the content of a dynamic texture
  46114. * @param texture defines the texture to update
  46115. * @param canvas defines the canvas containing the source
  46116. * @param invertY defines if data must be stored with Y axis inverted
  46117. * @param premulAlpha defines if alpha is stored as premultiplied
  46118. * @param format defines the format of the data
  46119. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46120. */
  46121. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46122. /**
  46123. * Gets a boolean indicating if all created effects are ready
  46124. * @returns true if all effects are ready
  46125. */
  46126. areAllEffectsReady(): boolean;
  46127. /**
  46128. * @hidden
  46129. * Get the current error code of the webGL context
  46130. * @returns the error code
  46131. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46132. */
  46133. getError(): number;
  46134. /** @hidden */
  46135. _getUnpackAlignement(): number;
  46136. /** @hidden */
  46137. _unpackFlipY(value: boolean): void;
  46138. /**
  46139. * Update a dynamic index buffer
  46140. * @param indexBuffer defines the target index buffer
  46141. * @param indices defines the data to update
  46142. * @param offset defines the offset in the target index buffer where update should start
  46143. */
  46144. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46145. /**
  46146. * Updates a dynamic vertex buffer.
  46147. * @param vertexBuffer the vertex buffer to update
  46148. * @param vertices the data used to update the vertex buffer
  46149. * @param byteOffset the byte offset of the data (optional)
  46150. * @param byteLength the byte length of the data (optional)
  46151. */
  46152. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46153. /** @hidden */
  46154. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46155. /** @hidden */
  46156. _bindTexture(channel: number, texture: InternalTexture): void;
  46157. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46158. /**
  46159. * 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
  46160. */
  46161. releaseEffects(): void;
  46162. displayLoadingUI(): void;
  46163. hideLoadingUI(): void;
  46164. /** @hidden */
  46165. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46166. /** @hidden */
  46167. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46168. /** @hidden */
  46169. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46170. /** @hidden */
  46171. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46172. }
  46173. }
  46174. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46175. import { Nullable, int } from "babylonjs/types";
  46176. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46177. /** @hidden */
  46178. export class _OcclusionDataStorage {
  46179. /** @hidden */
  46180. occlusionInternalRetryCounter: number;
  46181. /** @hidden */
  46182. isOcclusionQueryInProgress: boolean;
  46183. /** @hidden */
  46184. isOccluded: boolean;
  46185. /** @hidden */
  46186. occlusionRetryCount: number;
  46187. /** @hidden */
  46188. occlusionType: number;
  46189. /** @hidden */
  46190. occlusionQueryAlgorithmType: number;
  46191. }
  46192. module "babylonjs/Engines/engine" {
  46193. interface Engine {
  46194. /**
  46195. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46196. * @return the new query
  46197. */
  46198. createQuery(): WebGLQuery;
  46199. /**
  46200. * Delete and release a webGL query
  46201. * @param query defines the query to delete
  46202. * @return the current engine
  46203. */
  46204. deleteQuery(query: WebGLQuery): Engine;
  46205. /**
  46206. * Check if a given query has resolved and got its value
  46207. * @param query defines the query to check
  46208. * @returns true if the query got its value
  46209. */
  46210. isQueryResultAvailable(query: WebGLQuery): boolean;
  46211. /**
  46212. * Gets the value of a given query
  46213. * @param query defines the query to check
  46214. * @returns the value of the query
  46215. */
  46216. getQueryResult(query: WebGLQuery): number;
  46217. /**
  46218. * Initiates an occlusion query
  46219. * @param algorithmType defines the algorithm to use
  46220. * @param query defines the query to use
  46221. * @returns the current engine
  46222. * @see http://doc.babylonjs.com/features/occlusionquery
  46223. */
  46224. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46225. /**
  46226. * Ends an occlusion query
  46227. * @see http://doc.babylonjs.com/features/occlusionquery
  46228. * @param algorithmType defines the algorithm to use
  46229. * @returns the current engine
  46230. */
  46231. endOcclusionQuery(algorithmType: number): Engine;
  46232. /**
  46233. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46234. * Please note that only one query can be issued at a time
  46235. * @returns a time token used to track the time span
  46236. */
  46237. startTimeQuery(): Nullable<_TimeToken>;
  46238. /**
  46239. * Ends a time query
  46240. * @param token defines the token used to measure the time span
  46241. * @returns the time spent (in ns)
  46242. */
  46243. endTimeQuery(token: _TimeToken): int;
  46244. /** @hidden */
  46245. _currentNonTimestampToken: Nullable<_TimeToken>;
  46246. /** @hidden */
  46247. _createTimeQuery(): WebGLQuery;
  46248. /** @hidden */
  46249. _deleteTimeQuery(query: WebGLQuery): void;
  46250. /** @hidden */
  46251. _getGlAlgorithmType(algorithmType: number): number;
  46252. /** @hidden */
  46253. _getTimeQueryResult(query: WebGLQuery): any;
  46254. /** @hidden */
  46255. _getTimeQueryAvailability(query: WebGLQuery): any;
  46256. }
  46257. }
  46258. module "babylonjs/Meshes/abstractMesh" {
  46259. interface AbstractMesh {
  46260. /**
  46261. * Backing filed
  46262. * @hidden
  46263. */
  46264. __occlusionDataStorage: _OcclusionDataStorage;
  46265. /**
  46266. * Access property
  46267. * @hidden
  46268. */
  46269. _occlusionDataStorage: _OcclusionDataStorage;
  46270. /**
  46271. * 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.
  46272. * The default value is -1 which means don't break the query and wait till the result
  46273. * @see http://doc.babylonjs.com/features/occlusionquery
  46274. */
  46275. occlusionRetryCount: number;
  46276. /**
  46277. * 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:
  46278. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46279. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46280. * * 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.
  46281. * @see http://doc.babylonjs.com/features/occlusionquery
  46282. */
  46283. occlusionType: number;
  46284. /**
  46285. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46286. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46287. * * 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.
  46288. * @see http://doc.babylonjs.com/features/occlusionquery
  46289. */
  46290. occlusionQueryAlgorithmType: number;
  46291. /**
  46292. * 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
  46293. * @see http://doc.babylonjs.com/features/occlusionquery
  46294. */
  46295. isOccluded: boolean;
  46296. /**
  46297. * Flag to check the progress status of the query
  46298. * @see http://doc.babylonjs.com/features/occlusionquery
  46299. */
  46300. isOcclusionQueryInProgress: boolean;
  46301. }
  46302. }
  46303. }
  46304. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46305. import { Nullable } from "babylonjs/types";
  46306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46307. /** @hidden */
  46308. export var _forceTransformFeedbackToBundle: boolean;
  46309. module "babylonjs/Engines/engine" {
  46310. interface Engine {
  46311. /**
  46312. * Creates a webGL transform feedback object
  46313. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46314. * @returns the webGL transform feedback object
  46315. */
  46316. createTransformFeedback(): WebGLTransformFeedback;
  46317. /**
  46318. * Delete a webGL transform feedback object
  46319. * @param value defines the webGL transform feedback object to delete
  46320. */
  46321. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46322. /**
  46323. * Bind a webGL transform feedback object to the webgl context
  46324. * @param value defines the webGL transform feedback object to bind
  46325. */
  46326. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46327. /**
  46328. * Begins a transform feedback operation
  46329. * @param usePoints defines if points or triangles must be used
  46330. */
  46331. beginTransformFeedback(usePoints: boolean): void;
  46332. /**
  46333. * Ends a transform feedback operation
  46334. */
  46335. endTransformFeedback(): void;
  46336. /**
  46337. * Specify the varyings to use with transform feedback
  46338. * @param program defines the associated webGL program
  46339. * @param value defines the list of strings representing the varying names
  46340. */
  46341. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46342. /**
  46343. * Bind a webGL buffer for a transform feedback operation
  46344. * @param value defines the webGL buffer to bind
  46345. */
  46346. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46347. }
  46348. }
  46349. }
  46350. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46351. import { Scene } from "babylonjs/scene";
  46352. import { Engine } from "babylonjs/Engines/engine";
  46353. import { Texture } from "babylonjs/Materials/Textures/texture";
  46354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46355. import "babylonjs/Engines/Extensions/engine.multiRender";
  46356. /**
  46357. * Creation options of the multi render target texture.
  46358. */
  46359. export interface IMultiRenderTargetOptions {
  46360. /**
  46361. * Define if the texture needs to create mip maps after render.
  46362. */
  46363. generateMipMaps?: boolean;
  46364. /**
  46365. * Define the types of all the draw buffers we want to create
  46366. */
  46367. types?: number[];
  46368. /**
  46369. * Define the sampling modes of all the draw buffers we want to create
  46370. */
  46371. samplingModes?: number[];
  46372. /**
  46373. * Define if a depth buffer is required
  46374. */
  46375. generateDepthBuffer?: boolean;
  46376. /**
  46377. * Define if a stencil buffer is required
  46378. */
  46379. generateStencilBuffer?: boolean;
  46380. /**
  46381. * Define if a depth texture is required instead of a depth buffer
  46382. */
  46383. generateDepthTexture?: boolean;
  46384. /**
  46385. * Define the number of desired draw buffers
  46386. */
  46387. textureCount?: number;
  46388. /**
  46389. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46390. */
  46391. doNotChangeAspectRatio?: boolean;
  46392. /**
  46393. * Define the default type of the buffers we are creating
  46394. */
  46395. defaultType?: number;
  46396. }
  46397. /**
  46398. * A multi render target, like a render target provides the ability to render to a texture.
  46399. * Unlike the render target, it can render to several draw buffers in one draw.
  46400. * This is specially interesting in deferred rendering or for any effects requiring more than
  46401. * just one color from a single pass.
  46402. */
  46403. export class MultiRenderTarget extends RenderTargetTexture {
  46404. private _internalTextures;
  46405. private _textures;
  46406. private _multiRenderTargetOptions;
  46407. /**
  46408. * Get if draw buffers are currently supported by the used hardware and browser.
  46409. */
  46410. readonly isSupported: boolean;
  46411. /**
  46412. * Get the list of textures generated by the multi render target.
  46413. */
  46414. readonly textures: Texture[];
  46415. /**
  46416. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46417. */
  46418. readonly depthTexture: Texture;
  46419. /**
  46420. * Set the wrapping mode on U of all the textures we are rendering to.
  46421. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46422. */
  46423. wrapU: number;
  46424. /**
  46425. * Set the wrapping mode on V of all the textures we are rendering to.
  46426. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46427. */
  46428. wrapV: number;
  46429. /**
  46430. * Instantiate a new multi render target texture.
  46431. * A multi render target, like a render target provides the ability to render to a texture.
  46432. * Unlike the render target, it can render to several draw buffers in one draw.
  46433. * This is specially interesting in deferred rendering or for any effects requiring more than
  46434. * just one color from a single pass.
  46435. * @param name Define the name of the texture
  46436. * @param size Define the size of the buffers to render to
  46437. * @param count Define the number of target we are rendering into
  46438. * @param scene Define the scene the texture belongs to
  46439. * @param options Define the options used to create the multi render target
  46440. */
  46441. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46442. /** @hidden */
  46443. _rebuild(): void;
  46444. private _createInternalTextures;
  46445. private _createTextures;
  46446. /**
  46447. * Define the number of samples used if MSAA is enabled.
  46448. */
  46449. samples: number;
  46450. /**
  46451. * Resize all the textures in the multi render target.
  46452. * Be carrefull as it will recreate all the data in the new texture.
  46453. * @param size Define the new size
  46454. */
  46455. resize(size: any): void;
  46456. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46457. /**
  46458. * Dispose the render targets and their associated resources
  46459. */
  46460. dispose(): void;
  46461. /**
  46462. * Release all the underlying texture used as draw buffers.
  46463. */
  46464. releaseInternalTextures(): void;
  46465. }
  46466. }
  46467. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46469. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46470. import { Nullable } from "babylonjs/types";
  46471. module "babylonjs/Engines/thinEngine" {
  46472. interface ThinEngine {
  46473. /**
  46474. * Unbind a list of render target textures from the webGL context
  46475. * This is used only when drawBuffer extension or webGL2 are active
  46476. * @param textures defines the render target textures to unbind
  46477. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46478. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46479. */
  46480. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46481. /**
  46482. * Create a multi render target texture
  46483. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46484. * @param size defines the size of the texture
  46485. * @param options defines the creation options
  46486. * @returns the cube texture as an InternalTexture
  46487. */
  46488. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46489. /**
  46490. * Update the sample count for a given multiple render target texture
  46491. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46492. * @param textures defines the textures to update
  46493. * @param samples defines the sample count to set
  46494. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46495. */
  46496. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46497. }
  46498. }
  46499. }
  46500. declare module "babylonjs/Engines/Extensions/engine.views" {
  46501. import { Camera } from "babylonjs/Cameras/camera";
  46502. import { Nullable } from "babylonjs/types";
  46503. /**
  46504. * Class used to define an additional view for the engine
  46505. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46506. */
  46507. export class EngineView {
  46508. /** Defines the canvas where to render the view */
  46509. target: HTMLCanvasElement;
  46510. /** Defines an optional camera used to render the view (will use active camera else) */
  46511. camera?: Camera;
  46512. }
  46513. module "babylonjs/Engines/engine" {
  46514. interface Engine {
  46515. /**
  46516. * Gets or sets the HTML element to use for attaching events
  46517. */
  46518. inputElement: Nullable<HTMLElement>;
  46519. /**
  46520. * Gets the current engine view
  46521. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46522. */
  46523. activeView: Nullable<EngineView>;
  46524. /** Gets or sets the list of views */
  46525. views: EngineView[];
  46526. /**
  46527. * Register a new child canvas
  46528. * @param canvas defines the canvas to register
  46529. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46530. * @returns the associated view
  46531. */
  46532. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46533. /**
  46534. * Remove a registered child canvas
  46535. * @param canvas defines the canvas to remove
  46536. * @returns the current engine
  46537. */
  46538. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46539. }
  46540. }
  46541. }
  46542. declare module "babylonjs/Engines/Extensions/index" {
  46543. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46544. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46545. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46546. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46547. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46548. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46549. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46550. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46551. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46552. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46553. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46554. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46555. export * from "babylonjs/Engines/Extensions/engine.views";
  46556. }
  46557. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46558. import { Nullable } from "babylonjs/types";
  46559. /**
  46560. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46561. */
  46562. export interface CubeMapInfo {
  46563. /**
  46564. * The pixel array for the front face.
  46565. * This is stored in format, left to right, up to down format.
  46566. */
  46567. front: Nullable<ArrayBufferView>;
  46568. /**
  46569. * The pixel array for the back face.
  46570. * This is stored in format, left to right, up to down format.
  46571. */
  46572. back: Nullable<ArrayBufferView>;
  46573. /**
  46574. * The pixel array for the left face.
  46575. * This is stored in format, left to right, up to down format.
  46576. */
  46577. left: Nullable<ArrayBufferView>;
  46578. /**
  46579. * The pixel array for the right face.
  46580. * This is stored in format, left to right, up to down format.
  46581. */
  46582. right: Nullable<ArrayBufferView>;
  46583. /**
  46584. * The pixel array for the up face.
  46585. * This is stored in format, left to right, up to down format.
  46586. */
  46587. up: Nullable<ArrayBufferView>;
  46588. /**
  46589. * The pixel array for the down face.
  46590. * This is stored in format, left to right, up to down format.
  46591. */
  46592. down: Nullable<ArrayBufferView>;
  46593. /**
  46594. * The size of the cubemap stored.
  46595. *
  46596. * Each faces will be size * size pixels.
  46597. */
  46598. size: number;
  46599. /**
  46600. * The format of the texture.
  46601. *
  46602. * RGBA, RGB.
  46603. */
  46604. format: number;
  46605. /**
  46606. * The type of the texture data.
  46607. *
  46608. * UNSIGNED_INT, FLOAT.
  46609. */
  46610. type: number;
  46611. /**
  46612. * Specifies whether the texture is in gamma space.
  46613. */
  46614. gammaSpace: boolean;
  46615. }
  46616. /**
  46617. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46618. */
  46619. export class PanoramaToCubeMapTools {
  46620. private static FACE_FRONT;
  46621. private static FACE_BACK;
  46622. private static FACE_RIGHT;
  46623. private static FACE_LEFT;
  46624. private static FACE_DOWN;
  46625. private static FACE_UP;
  46626. /**
  46627. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46628. *
  46629. * @param float32Array The source data.
  46630. * @param inputWidth The width of the input panorama.
  46631. * @param inputHeight The height of the input panorama.
  46632. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46633. * @return The cubemap data
  46634. */
  46635. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46636. private static CreateCubemapTexture;
  46637. private static CalcProjectionSpherical;
  46638. }
  46639. }
  46640. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46641. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46642. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46643. import { Nullable } from "babylonjs/types";
  46644. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46645. /**
  46646. * Helper class dealing with the extraction of spherical polynomial dataArray
  46647. * from a cube map.
  46648. */
  46649. export class CubeMapToSphericalPolynomialTools {
  46650. private static FileFaces;
  46651. /**
  46652. * Converts a texture to the according Spherical Polynomial data.
  46653. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46654. *
  46655. * @param texture The texture to extract the information from.
  46656. * @return The Spherical Polynomial data.
  46657. */
  46658. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46659. /**
  46660. * Converts a cubemap to the according Spherical Polynomial data.
  46661. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46662. *
  46663. * @param cubeInfo The Cube map to extract the information from.
  46664. * @return The Spherical Polynomial data.
  46665. */
  46666. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46667. }
  46668. }
  46669. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46670. import { Nullable } from "babylonjs/types";
  46671. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46672. module "babylonjs/Materials/Textures/baseTexture" {
  46673. interface BaseTexture {
  46674. /**
  46675. * Get the polynomial representation of the texture data.
  46676. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46677. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46678. */
  46679. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46680. }
  46681. }
  46682. }
  46683. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46684. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46685. /** @hidden */
  46686. export var rgbdEncodePixelShader: {
  46687. name: string;
  46688. shader: string;
  46689. };
  46690. }
  46691. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46692. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46693. /** @hidden */
  46694. export var rgbdDecodePixelShader: {
  46695. name: string;
  46696. shader: string;
  46697. };
  46698. }
  46699. declare module "babylonjs/Misc/environmentTextureTools" {
  46700. import { Nullable } from "babylonjs/types";
  46701. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46702. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46703. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46704. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46705. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46706. import "babylonjs/Shaders/rgbdEncode.fragment";
  46707. import "babylonjs/Shaders/rgbdDecode.fragment";
  46708. /**
  46709. * Raw texture data and descriptor sufficient for WebGL texture upload
  46710. */
  46711. export interface EnvironmentTextureInfo {
  46712. /**
  46713. * Version of the environment map
  46714. */
  46715. version: number;
  46716. /**
  46717. * Width of image
  46718. */
  46719. width: number;
  46720. /**
  46721. * Irradiance information stored in the file.
  46722. */
  46723. irradiance: any;
  46724. /**
  46725. * Specular information stored in the file.
  46726. */
  46727. specular: any;
  46728. }
  46729. /**
  46730. * Defines One Image in the file. It requires only the position in the file
  46731. * as well as the length.
  46732. */
  46733. interface BufferImageData {
  46734. /**
  46735. * Length of the image data.
  46736. */
  46737. length: number;
  46738. /**
  46739. * Position of the data from the null terminator delimiting the end of the JSON.
  46740. */
  46741. position: number;
  46742. }
  46743. /**
  46744. * Defines the specular data enclosed in the file.
  46745. * This corresponds to the version 1 of the data.
  46746. */
  46747. export interface EnvironmentTextureSpecularInfoV1 {
  46748. /**
  46749. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46750. */
  46751. specularDataPosition?: number;
  46752. /**
  46753. * This contains all the images data needed to reconstruct the cubemap.
  46754. */
  46755. mipmaps: Array<BufferImageData>;
  46756. /**
  46757. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46758. */
  46759. lodGenerationScale: number;
  46760. }
  46761. /**
  46762. * Sets of helpers addressing the serialization and deserialization of environment texture
  46763. * stored in a BabylonJS env file.
  46764. * Those files are usually stored as .env files.
  46765. */
  46766. export class EnvironmentTextureTools {
  46767. /**
  46768. * Magic number identifying the env file.
  46769. */
  46770. private static _MagicBytes;
  46771. /**
  46772. * Gets the environment info from an env file.
  46773. * @param data The array buffer containing the .env bytes.
  46774. * @returns the environment file info (the json header) if successfully parsed.
  46775. */
  46776. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46777. /**
  46778. * Creates an environment texture from a loaded cube texture.
  46779. * @param texture defines the cube texture to convert in env file
  46780. * @return a promise containing the environment data if succesfull.
  46781. */
  46782. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46783. /**
  46784. * Creates a JSON representation of the spherical data.
  46785. * @param texture defines the texture containing the polynomials
  46786. * @return the JSON representation of the spherical info
  46787. */
  46788. private static _CreateEnvTextureIrradiance;
  46789. /**
  46790. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46791. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46792. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46793. * @return the views described by info providing access to the underlying buffer
  46794. */
  46795. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46796. /**
  46797. * Uploads the texture info contained in the env file to the GPU.
  46798. * @param texture defines the internal texture to upload to
  46799. * @param arrayBuffer defines the buffer cotaining the data to load
  46800. * @param info defines the texture info retrieved through the GetEnvInfo method
  46801. * @returns a promise
  46802. */
  46803. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46804. private static _OnImageReadyAsync;
  46805. /**
  46806. * Uploads the levels of image data to the GPU.
  46807. * @param texture defines the internal texture to upload to
  46808. * @param imageData defines the array buffer views of image data [mipmap][face]
  46809. * @returns a promise
  46810. */
  46811. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46812. /**
  46813. * Uploads spherical polynomials information to the texture.
  46814. * @param texture defines the texture we are trying to upload the information to
  46815. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46816. */
  46817. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46818. /** @hidden */
  46819. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46820. }
  46821. }
  46822. declare module "babylonjs/Maths/math.vertexFormat" {
  46823. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46824. /**
  46825. * Contains position and normal vectors for a vertex
  46826. */
  46827. export class PositionNormalVertex {
  46828. /** the position of the vertex (defaut: 0,0,0) */
  46829. position: Vector3;
  46830. /** the normal of the vertex (defaut: 0,1,0) */
  46831. normal: Vector3;
  46832. /**
  46833. * Creates a PositionNormalVertex
  46834. * @param position the position of the vertex (defaut: 0,0,0)
  46835. * @param normal the normal of the vertex (defaut: 0,1,0)
  46836. */
  46837. constructor(
  46838. /** the position of the vertex (defaut: 0,0,0) */
  46839. position?: Vector3,
  46840. /** the normal of the vertex (defaut: 0,1,0) */
  46841. normal?: Vector3);
  46842. /**
  46843. * Clones the PositionNormalVertex
  46844. * @returns the cloned PositionNormalVertex
  46845. */
  46846. clone(): PositionNormalVertex;
  46847. }
  46848. /**
  46849. * Contains position, normal and uv vectors for a vertex
  46850. */
  46851. export class PositionNormalTextureVertex {
  46852. /** the position of the vertex (defaut: 0,0,0) */
  46853. position: Vector3;
  46854. /** the normal of the vertex (defaut: 0,1,0) */
  46855. normal: Vector3;
  46856. /** the uv of the vertex (default: 0,0) */
  46857. uv: Vector2;
  46858. /**
  46859. * Creates a PositionNormalTextureVertex
  46860. * @param position the position of the vertex (defaut: 0,0,0)
  46861. * @param normal the normal of the vertex (defaut: 0,1,0)
  46862. * @param uv the uv of the vertex (default: 0,0)
  46863. */
  46864. constructor(
  46865. /** the position of the vertex (defaut: 0,0,0) */
  46866. position?: Vector3,
  46867. /** the normal of the vertex (defaut: 0,1,0) */
  46868. normal?: Vector3,
  46869. /** the uv of the vertex (default: 0,0) */
  46870. uv?: Vector2);
  46871. /**
  46872. * Clones the PositionNormalTextureVertex
  46873. * @returns the cloned PositionNormalTextureVertex
  46874. */
  46875. clone(): PositionNormalTextureVertex;
  46876. }
  46877. }
  46878. declare module "babylonjs/Maths/math" {
  46879. export * from "babylonjs/Maths/math.axis";
  46880. export * from "babylonjs/Maths/math.color";
  46881. export * from "babylonjs/Maths/math.constants";
  46882. export * from "babylonjs/Maths/math.frustum";
  46883. export * from "babylonjs/Maths/math.path";
  46884. export * from "babylonjs/Maths/math.plane";
  46885. export * from "babylonjs/Maths/math.size";
  46886. export * from "babylonjs/Maths/math.vector";
  46887. export * from "babylonjs/Maths/math.vertexFormat";
  46888. export * from "babylonjs/Maths/math.viewport";
  46889. }
  46890. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46891. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46892. /** @hidden */
  46893. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46894. private _genericAttributeLocation;
  46895. private _varyingLocationCount;
  46896. private _varyingLocationMap;
  46897. private _replacements;
  46898. private _textureCount;
  46899. private _uniforms;
  46900. lineProcessor(line: string): string;
  46901. attributeProcessor(attribute: string): string;
  46902. varyingProcessor(varying: string, isFragment: boolean): string;
  46903. uniformProcessor(uniform: string): string;
  46904. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46905. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46906. }
  46907. }
  46908. declare module "babylonjs/Engines/nativeEngine" {
  46909. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46910. import { Engine } from "babylonjs/Engines/engine";
  46911. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46914. import { Effect } from "babylonjs/Materials/effect";
  46915. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46916. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46917. import { Scene } from "babylonjs/scene";
  46918. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46919. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46920. /**
  46921. * Container for accessors for natively-stored mesh data buffers.
  46922. */
  46923. class NativeDataBuffer extends DataBuffer {
  46924. /**
  46925. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46926. */
  46927. nativeIndexBuffer?: any;
  46928. /**
  46929. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46930. */
  46931. nativeVertexBuffer?: any;
  46932. }
  46933. /** @hidden */
  46934. class NativeTexture extends InternalTexture {
  46935. getInternalTexture(): InternalTexture;
  46936. getViewCount(): number;
  46937. }
  46938. /** @hidden */
  46939. export class NativeEngine extends Engine {
  46940. private readonly _native;
  46941. getHardwareScalingLevel(): number;
  46942. constructor();
  46943. /**
  46944. * Can be used to override the current requestAnimationFrame requester.
  46945. * @hidden
  46946. */
  46947. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46948. /**
  46949. * Override default engine behavior.
  46950. * @param color
  46951. * @param backBuffer
  46952. * @param depth
  46953. * @param stencil
  46954. */
  46955. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46956. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46957. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46958. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46959. recordVertexArrayObject(vertexBuffers: {
  46960. [key: string]: VertexBuffer;
  46961. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46962. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46963. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46964. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46965. /**
  46966. * Draw a list of indexed primitives
  46967. * @param fillMode defines the primitive to use
  46968. * @param indexStart defines the starting index
  46969. * @param indexCount defines the number of index to draw
  46970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46971. */
  46972. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46973. /**
  46974. * Draw a list of unindexed primitives
  46975. * @param fillMode defines the primitive to use
  46976. * @param verticesStart defines the index of first vertex to draw
  46977. * @param verticesCount defines the count of vertices to draw
  46978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46979. */
  46980. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46981. createPipelineContext(): IPipelineContext;
  46982. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46983. /** @hidden */
  46984. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46985. /** @hidden */
  46986. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46987. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46988. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46989. protected _setProgram(program: WebGLProgram): void;
  46990. _releaseEffect(effect: Effect): void;
  46991. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46992. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46993. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46994. bindSamplers(effect: Effect): void;
  46995. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46996. getRenderWidth(useScreen?: boolean): number;
  46997. getRenderHeight(useScreen?: boolean): number;
  46998. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46999. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47000. /**
  47001. * Set the z offset to apply to current rendering
  47002. * @param value defines the offset to apply
  47003. */
  47004. setZOffset(value: number): void;
  47005. /**
  47006. * Gets the current value of the zOffset
  47007. * @returns the current zOffset state
  47008. */
  47009. getZOffset(): number;
  47010. /**
  47011. * Enable or disable depth buffering
  47012. * @param enable defines the state to set
  47013. */
  47014. setDepthBuffer(enable: boolean): void;
  47015. /**
  47016. * Gets a boolean indicating if depth writing is enabled
  47017. * @returns the current depth writing state
  47018. */
  47019. getDepthWrite(): boolean;
  47020. /**
  47021. * Enable or disable depth writing
  47022. * @param enable defines the state to set
  47023. */
  47024. setDepthWrite(enable: boolean): void;
  47025. /**
  47026. * Enable or disable color writing
  47027. * @param enable defines the state to set
  47028. */
  47029. setColorWrite(enable: boolean): void;
  47030. /**
  47031. * Gets a boolean indicating if color writing is enabled
  47032. * @returns the current color writing state
  47033. */
  47034. getColorWrite(): boolean;
  47035. /**
  47036. * Sets alpha constants used by some alpha blending modes
  47037. * @param r defines the red component
  47038. * @param g defines the green component
  47039. * @param b defines the blue component
  47040. * @param a defines the alpha component
  47041. */
  47042. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47043. /**
  47044. * Sets the current alpha mode
  47045. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47046. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47048. */
  47049. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47050. /**
  47051. * Gets the current alpha mode
  47052. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47053. * @returns the current alpha mode
  47054. */
  47055. getAlphaMode(): number;
  47056. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47057. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47058. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47059. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47060. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47061. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47062. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47063. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47064. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47065. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47066. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47067. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47068. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47069. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47070. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47071. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47072. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47073. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47074. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47075. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47076. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47077. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47078. wipeCaches(bruteForce?: boolean): void;
  47079. _createTexture(): WebGLTexture;
  47080. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47081. /**
  47082. * Usually called from BABYLON.Texture.ts.
  47083. * Passed information to create a WebGLTexture
  47084. * @param urlArg defines a value which contains one of the following:
  47085. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47086. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47087. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47088. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47089. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47090. * @param scene needed for loading to the correct scene
  47091. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47092. * @param onLoad optional callback to be called upon successful completion
  47093. * @param onError optional callback to be called upon failure
  47094. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47095. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47096. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47097. * @param forcedExtension defines the extension to use to pick the right loader
  47098. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47099. */
  47100. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47101. /**
  47102. * Creates a cube texture
  47103. * @param rootUrl defines the url where the files to load is located
  47104. * @param scene defines the current scene
  47105. * @param files defines the list of files to load (1 per face)
  47106. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47107. * @param onLoad defines an optional callback raised when the texture is loaded
  47108. * @param onError defines an optional callback raised if there is an issue to load the texture
  47109. * @param format defines the format of the data
  47110. * @param forcedExtension defines the extension to use to pick the right loader
  47111. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47112. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47113. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47114. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47115. * @returns the cube texture as an InternalTexture
  47116. */
  47117. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47118. private _getSamplingFilter;
  47119. private static _GetNativeTextureFormat;
  47120. createRenderTargetTexture(size: number | {
  47121. width: number;
  47122. height: number;
  47123. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47124. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47125. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47126. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47127. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47128. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47129. /**
  47130. * Updates a dynamic vertex buffer.
  47131. * @param vertexBuffer the vertex buffer to update
  47132. * @param data the data used to update the vertex buffer
  47133. * @param byteOffset the byte offset of the data (optional)
  47134. * @param byteLength the byte length of the data (optional)
  47135. */
  47136. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47137. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47138. private _updateAnisotropicLevel;
  47139. private _getAddressMode;
  47140. /** @hidden */
  47141. _bindTexture(channel: number, texture: InternalTexture): void;
  47142. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47143. releaseEffects(): void;
  47144. /** @hidden */
  47145. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47146. /** @hidden */
  47147. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47148. /** @hidden */
  47149. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47150. /** @hidden */
  47151. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47152. }
  47153. }
  47154. declare module "babylonjs/Engines/index" {
  47155. export * from "babylonjs/Engines/constants";
  47156. export * from "babylonjs/Engines/engineCapabilities";
  47157. export * from "babylonjs/Engines/instancingAttributeInfo";
  47158. export * from "babylonjs/Engines/thinEngine";
  47159. export * from "babylonjs/Engines/engine";
  47160. export * from "babylonjs/Engines/engineStore";
  47161. export * from "babylonjs/Engines/nullEngine";
  47162. export * from "babylonjs/Engines/Extensions/index";
  47163. export * from "babylonjs/Engines/IPipelineContext";
  47164. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47165. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47166. export * from "babylonjs/Engines/nativeEngine";
  47167. }
  47168. declare module "babylonjs/Events/clipboardEvents" {
  47169. /**
  47170. * Gather the list of clipboard event types as constants.
  47171. */
  47172. export class ClipboardEventTypes {
  47173. /**
  47174. * The clipboard event is fired when a copy command is active (pressed).
  47175. */
  47176. static readonly COPY: number;
  47177. /**
  47178. * The clipboard event is fired when a cut command is active (pressed).
  47179. */
  47180. static readonly CUT: number;
  47181. /**
  47182. * The clipboard event is fired when a paste command is active (pressed).
  47183. */
  47184. static readonly PASTE: number;
  47185. }
  47186. /**
  47187. * This class is used to store clipboard related info for the onClipboardObservable event.
  47188. */
  47189. export class ClipboardInfo {
  47190. /**
  47191. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47192. */
  47193. type: number;
  47194. /**
  47195. * Defines the related dom event
  47196. */
  47197. event: ClipboardEvent;
  47198. /**
  47199. *Creates an instance of ClipboardInfo.
  47200. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47201. * @param event Defines the related dom event
  47202. */
  47203. constructor(
  47204. /**
  47205. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47206. */
  47207. type: number,
  47208. /**
  47209. * Defines the related dom event
  47210. */
  47211. event: ClipboardEvent);
  47212. /**
  47213. * Get the clipboard event's type from the keycode.
  47214. * @param keyCode Defines the keyCode for the current keyboard event.
  47215. * @return {number}
  47216. */
  47217. static GetTypeFromCharacter(keyCode: number): number;
  47218. }
  47219. }
  47220. declare module "babylonjs/Events/index" {
  47221. export * from "babylonjs/Events/keyboardEvents";
  47222. export * from "babylonjs/Events/pointerEvents";
  47223. export * from "babylonjs/Events/clipboardEvents";
  47224. }
  47225. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47226. import { Scene } from "babylonjs/scene";
  47227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47228. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47229. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47230. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47231. /**
  47232. * Google Daydream controller
  47233. */
  47234. export class DaydreamController extends WebVRController {
  47235. /**
  47236. * Base Url for the controller model.
  47237. */
  47238. static MODEL_BASE_URL: string;
  47239. /**
  47240. * File name for the controller model.
  47241. */
  47242. static MODEL_FILENAME: string;
  47243. /**
  47244. * Gamepad Id prefix used to identify Daydream Controller.
  47245. */
  47246. static readonly GAMEPAD_ID_PREFIX: string;
  47247. /**
  47248. * Creates a new DaydreamController from a gamepad
  47249. * @param vrGamepad the gamepad that the controller should be created from
  47250. */
  47251. constructor(vrGamepad: any);
  47252. /**
  47253. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47254. * @param scene scene in which to add meshes
  47255. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47256. */
  47257. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47258. /**
  47259. * Called once for each button that changed state since the last frame
  47260. * @param buttonIdx Which button index changed
  47261. * @param state New state of the button
  47262. * @param changes Which properties on the state changed since last frame
  47263. */
  47264. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47265. }
  47266. }
  47267. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47268. import { Scene } from "babylonjs/scene";
  47269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47270. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47271. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47272. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47273. /**
  47274. * Gear VR Controller
  47275. */
  47276. export class GearVRController extends WebVRController {
  47277. /**
  47278. * Base Url for the controller model.
  47279. */
  47280. static MODEL_BASE_URL: string;
  47281. /**
  47282. * File name for the controller model.
  47283. */
  47284. static MODEL_FILENAME: string;
  47285. /**
  47286. * Gamepad Id prefix used to identify this controller.
  47287. */
  47288. static readonly GAMEPAD_ID_PREFIX: string;
  47289. private readonly _buttonIndexToObservableNameMap;
  47290. /**
  47291. * Creates a new GearVRController from a gamepad
  47292. * @param vrGamepad the gamepad that the controller should be created from
  47293. */
  47294. constructor(vrGamepad: any);
  47295. /**
  47296. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47297. * @param scene scene in which to add meshes
  47298. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47299. */
  47300. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47301. /**
  47302. * Called once for each button that changed state since the last frame
  47303. * @param buttonIdx Which button index changed
  47304. * @param state New state of the button
  47305. * @param changes Which properties on the state changed since last frame
  47306. */
  47307. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47308. }
  47309. }
  47310. declare module "babylonjs/Gamepads/Controllers/index" {
  47311. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47312. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47313. export * from "babylonjs/Gamepads/Controllers/genericController";
  47314. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47315. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47316. export * from "babylonjs/Gamepads/Controllers/viveController";
  47317. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47318. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47319. }
  47320. declare module "babylonjs/Gamepads/index" {
  47321. export * from "babylonjs/Gamepads/Controllers/index";
  47322. export * from "babylonjs/Gamepads/gamepad";
  47323. export * from "babylonjs/Gamepads/gamepadManager";
  47324. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47325. export * from "babylonjs/Gamepads/xboxGamepad";
  47326. export * from "babylonjs/Gamepads/dualShockGamepad";
  47327. }
  47328. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47329. import { Scene } from "babylonjs/scene";
  47330. import { Vector4 } from "babylonjs/Maths/math.vector";
  47331. import { Color4 } from "babylonjs/Maths/math.color";
  47332. import { Mesh } from "babylonjs/Meshes/mesh";
  47333. import { Nullable } from "babylonjs/types";
  47334. /**
  47335. * Class containing static functions to help procedurally build meshes
  47336. */
  47337. export class PolyhedronBuilder {
  47338. /**
  47339. * Creates a polyhedron mesh
  47340. * * 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
  47341. * * The parameter `size` (positive float, default 1) sets the polygon size
  47342. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47343. * * 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`
  47344. * * 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
  47345. * * 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)`)
  47346. * * 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
  47347. * * 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
  47348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47351. * @param name defines the name of the mesh
  47352. * @param options defines the options used to create the mesh
  47353. * @param scene defines the hosting scene
  47354. * @returns the polyhedron mesh
  47355. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47356. */
  47357. static CreatePolyhedron(name: string, options: {
  47358. type?: number;
  47359. size?: number;
  47360. sizeX?: number;
  47361. sizeY?: number;
  47362. sizeZ?: number;
  47363. custom?: any;
  47364. faceUV?: Vector4[];
  47365. faceColors?: Color4[];
  47366. flat?: boolean;
  47367. updatable?: boolean;
  47368. sideOrientation?: number;
  47369. frontUVs?: Vector4;
  47370. backUVs?: Vector4;
  47371. }, scene?: Nullable<Scene>): Mesh;
  47372. }
  47373. }
  47374. declare module "babylonjs/Gizmos/scaleGizmo" {
  47375. import { Observable } from "babylonjs/Misc/observable";
  47376. import { Nullable } from "babylonjs/types";
  47377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47378. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47379. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47380. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47381. /**
  47382. * Gizmo that enables scaling a mesh along 3 axis
  47383. */
  47384. export class ScaleGizmo extends Gizmo {
  47385. /**
  47386. * Internal gizmo used for interactions on the x axis
  47387. */
  47388. xGizmo: AxisScaleGizmo;
  47389. /**
  47390. * Internal gizmo used for interactions on the y axis
  47391. */
  47392. yGizmo: AxisScaleGizmo;
  47393. /**
  47394. * Internal gizmo used for interactions on the z axis
  47395. */
  47396. zGizmo: AxisScaleGizmo;
  47397. /**
  47398. * Internal gizmo used to scale all axis equally
  47399. */
  47400. uniformScaleGizmo: AxisScaleGizmo;
  47401. private _meshAttached;
  47402. private _updateGizmoRotationToMatchAttachedMesh;
  47403. private _snapDistance;
  47404. private _scaleRatio;
  47405. private _uniformScalingMesh;
  47406. private _octahedron;
  47407. /** Fires an event when any of it's sub gizmos are dragged */
  47408. onDragStartObservable: Observable<unknown>;
  47409. /** Fires an event when any of it's sub gizmos are released from dragging */
  47410. onDragEndObservable: Observable<unknown>;
  47411. attachedMesh: Nullable<AbstractMesh>;
  47412. /**
  47413. * Creates a ScaleGizmo
  47414. * @param gizmoLayer The utility layer the gizmo will be added to
  47415. */
  47416. constructor(gizmoLayer?: UtilityLayerRenderer);
  47417. updateGizmoRotationToMatchAttachedMesh: boolean;
  47418. /**
  47419. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47420. */
  47421. snapDistance: number;
  47422. /**
  47423. * Ratio for the scale of the gizmo (Default: 1)
  47424. */
  47425. scaleRatio: number;
  47426. /**
  47427. * Disposes of the gizmo
  47428. */
  47429. dispose(): void;
  47430. }
  47431. }
  47432. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47433. import { Observable } from "babylonjs/Misc/observable";
  47434. import { Nullable } from "babylonjs/types";
  47435. import { Vector3 } from "babylonjs/Maths/math.vector";
  47436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47437. import { Mesh } from "babylonjs/Meshes/mesh";
  47438. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47439. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47441. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47442. import { Color3 } from "babylonjs/Maths/math.color";
  47443. /**
  47444. * Single axis scale gizmo
  47445. */
  47446. export class AxisScaleGizmo extends Gizmo {
  47447. /**
  47448. * Drag behavior responsible for the gizmos dragging interactions
  47449. */
  47450. dragBehavior: PointerDragBehavior;
  47451. private _pointerObserver;
  47452. /**
  47453. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47454. */
  47455. snapDistance: number;
  47456. /**
  47457. * Event that fires each time the gizmo snaps to a new location.
  47458. * * snapDistance is the the change in distance
  47459. */
  47460. onSnapObservable: Observable<{
  47461. snapDistance: number;
  47462. }>;
  47463. /**
  47464. * If the scaling operation should be done on all axis (default: false)
  47465. */
  47466. uniformScaling: boolean;
  47467. private _isEnabled;
  47468. private _parent;
  47469. private _arrow;
  47470. private _coloredMaterial;
  47471. private _hoverMaterial;
  47472. /**
  47473. * Creates an AxisScaleGizmo
  47474. * @param gizmoLayer The utility layer the gizmo will be added to
  47475. * @param dragAxis The axis which the gizmo will be able to scale on
  47476. * @param color The color of the gizmo
  47477. */
  47478. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47479. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47480. /**
  47481. * If the gizmo is enabled
  47482. */
  47483. isEnabled: boolean;
  47484. /**
  47485. * Disposes of the gizmo
  47486. */
  47487. dispose(): void;
  47488. /**
  47489. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47490. * @param mesh The mesh to replace the default mesh of the gizmo
  47491. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47492. */
  47493. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47494. }
  47495. }
  47496. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47497. import { Observable } from "babylonjs/Misc/observable";
  47498. import { Nullable } from "babylonjs/types";
  47499. import { Vector3 } from "babylonjs/Maths/math.vector";
  47500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47501. import { Mesh } from "babylonjs/Meshes/mesh";
  47502. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47503. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47504. import { Color3 } from "babylonjs/Maths/math.color";
  47505. import "babylonjs/Meshes/Builders/boxBuilder";
  47506. /**
  47507. * Bounding box gizmo
  47508. */
  47509. export class BoundingBoxGizmo extends Gizmo {
  47510. private _lineBoundingBox;
  47511. private _rotateSpheresParent;
  47512. private _scaleBoxesParent;
  47513. private _boundingDimensions;
  47514. private _renderObserver;
  47515. private _pointerObserver;
  47516. private _scaleDragSpeed;
  47517. private _tmpQuaternion;
  47518. private _tmpVector;
  47519. private _tmpRotationMatrix;
  47520. /**
  47521. * 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)
  47522. */
  47523. ignoreChildren: boolean;
  47524. /**
  47525. * 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)
  47526. */
  47527. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47528. /**
  47529. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47530. */
  47531. rotationSphereSize: number;
  47532. /**
  47533. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47534. */
  47535. scaleBoxSize: number;
  47536. /**
  47537. * 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)
  47538. */
  47539. fixedDragMeshScreenSize: boolean;
  47540. /**
  47541. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47542. */
  47543. fixedDragMeshScreenSizeDistanceFactor: number;
  47544. /**
  47545. * Fired when a rotation sphere or scale box is dragged
  47546. */
  47547. onDragStartObservable: Observable<{}>;
  47548. /**
  47549. * Fired when a scale box is dragged
  47550. */
  47551. onScaleBoxDragObservable: Observable<{}>;
  47552. /**
  47553. * Fired when a scale box drag is ended
  47554. */
  47555. onScaleBoxDragEndObservable: Observable<{}>;
  47556. /**
  47557. * Fired when a rotation sphere is dragged
  47558. */
  47559. onRotationSphereDragObservable: Observable<{}>;
  47560. /**
  47561. * Fired when a rotation sphere drag is ended
  47562. */
  47563. onRotationSphereDragEndObservable: Observable<{}>;
  47564. /**
  47565. * 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)
  47566. */
  47567. scalePivot: Nullable<Vector3>;
  47568. /**
  47569. * Mesh used as a pivot to rotate the attached mesh
  47570. */
  47571. private _anchorMesh;
  47572. private _existingMeshScale;
  47573. private _dragMesh;
  47574. private pointerDragBehavior;
  47575. private coloredMaterial;
  47576. private hoverColoredMaterial;
  47577. /**
  47578. * Sets the color of the bounding box gizmo
  47579. * @param color the color to set
  47580. */
  47581. setColor(color: Color3): void;
  47582. /**
  47583. * Creates an BoundingBoxGizmo
  47584. * @param gizmoLayer The utility layer the gizmo will be added to
  47585. * @param color The color of the gizmo
  47586. */
  47587. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47589. private _selectNode;
  47590. /**
  47591. * Updates the bounding box information for the Gizmo
  47592. */
  47593. updateBoundingBox(): void;
  47594. private _updateRotationSpheres;
  47595. private _updateScaleBoxes;
  47596. /**
  47597. * Enables rotation on the specified axis and disables rotation on the others
  47598. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47599. */
  47600. setEnabledRotationAxis(axis: string): void;
  47601. /**
  47602. * Enables/disables scaling
  47603. * @param enable if scaling should be enabled
  47604. */
  47605. setEnabledScaling(enable: boolean): void;
  47606. private _updateDummy;
  47607. /**
  47608. * Enables a pointer drag behavior on the bounding box of the gizmo
  47609. */
  47610. enableDragBehavior(): void;
  47611. /**
  47612. * Disposes of the gizmo
  47613. */
  47614. dispose(): void;
  47615. /**
  47616. * 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)
  47617. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47618. * @returns the bounding box mesh with the passed in mesh as a child
  47619. */
  47620. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47621. /**
  47622. * CustomMeshes are not supported by this gizmo
  47623. * @param mesh The mesh to replace the default mesh of the gizmo
  47624. */
  47625. setCustomMesh(mesh: Mesh): void;
  47626. }
  47627. }
  47628. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47629. import { Observable } from "babylonjs/Misc/observable";
  47630. import { Nullable } from "babylonjs/types";
  47631. import { Vector3 } from "babylonjs/Maths/math.vector";
  47632. import { Color3 } from "babylonjs/Maths/math.color";
  47633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47634. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47635. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47636. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47637. import "babylonjs/Meshes/Builders/linesBuilder";
  47638. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47639. /**
  47640. * Single plane rotation gizmo
  47641. */
  47642. export class PlaneRotationGizmo extends Gizmo {
  47643. /**
  47644. * Drag behavior responsible for the gizmos dragging interactions
  47645. */
  47646. dragBehavior: PointerDragBehavior;
  47647. private _pointerObserver;
  47648. /**
  47649. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47650. */
  47651. snapDistance: number;
  47652. /**
  47653. * Event that fires each time the gizmo snaps to a new location.
  47654. * * snapDistance is the the change in distance
  47655. */
  47656. onSnapObservable: Observable<{
  47657. snapDistance: number;
  47658. }>;
  47659. private _isEnabled;
  47660. private _parent;
  47661. /**
  47662. * Creates a PlaneRotationGizmo
  47663. * @param gizmoLayer The utility layer the gizmo will be added to
  47664. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47665. * @param color The color of the gizmo
  47666. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47667. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47668. */
  47669. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47670. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47671. /**
  47672. * If the gizmo is enabled
  47673. */
  47674. isEnabled: boolean;
  47675. /**
  47676. * Disposes of the gizmo
  47677. */
  47678. dispose(): void;
  47679. }
  47680. }
  47681. declare module "babylonjs/Gizmos/rotationGizmo" {
  47682. import { Observable } from "babylonjs/Misc/observable";
  47683. import { Nullable } from "babylonjs/types";
  47684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47685. import { Mesh } from "babylonjs/Meshes/mesh";
  47686. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47687. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47689. /**
  47690. * Gizmo that enables rotating a mesh along 3 axis
  47691. */
  47692. export class RotationGizmo extends Gizmo {
  47693. /**
  47694. * Internal gizmo used for interactions on the x axis
  47695. */
  47696. xGizmo: PlaneRotationGizmo;
  47697. /**
  47698. * Internal gizmo used for interactions on the y axis
  47699. */
  47700. yGizmo: PlaneRotationGizmo;
  47701. /**
  47702. * Internal gizmo used for interactions on the z axis
  47703. */
  47704. zGizmo: PlaneRotationGizmo;
  47705. /** Fires an event when any of it's sub gizmos are dragged */
  47706. onDragStartObservable: Observable<unknown>;
  47707. /** Fires an event when any of it's sub gizmos are released from dragging */
  47708. onDragEndObservable: Observable<unknown>;
  47709. private _meshAttached;
  47710. attachedMesh: Nullable<AbstractMesh>;
  47711. /**
  47712. * Creates a RotationGizmo
  47713. * @param gizmoLayer The utility layer the gizmo will be added to
  47714. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47715. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47716. */
  47717. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47718. updateGizmoRotationToMatchAttachedMesh: boolean;
  47719. /**
  47720. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47721. */
  47722. snapDistance: number;
  47723. /**
  47724. * Ratio for the scale of the gizmo (Default: 1)
  47725. */
  47726. scaleRatio: number;
  47727. /**
  47728. * Disposes of the gizmo
  47729. */
  47730. dispose(): void;
  47731. /**
  47732. * CustomMeshes are not supported by this gizmo
  47733. * @param mesh The mesh to replace the default mesh of the gizmo
  47734. */
  47735. setCustomMesh(mesh: Mesh): void;
  47736. }
  47737. }
  47738. declare module "babylonjs/Gizmos/gizmoManager" {
  47739. import { Observable } from "babylonjs/Misc/observable";
  47740. import { Nullable } from "babylonjs/types";
  47741. import { Scene, IDisposable } from "babylonjs/scene";
  47742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47743. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47744. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47745. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47746. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47747. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47748. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47749. /**
  47750. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47751. */
  47752. export class GizmoManager implements IDisposable {
  47753. private scene;
  47754. /**
  47755. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47756. */
  47757. gizmos: {
  47758. positionGizmo: Nullable<PositionGizmo>;
  47759. rotationGizmo: Nullable<RotationGizmo>;
  47760. scaleGizmo: Nullable<ScaleGizmo>;
  47761. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47762. };
  47763. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47764. clearGizmoOnEmptyPointerEvent: boolean;
  47765. /** Fires an event when the manager is attached to a mesh */
  47766. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47767. private _gizmosEnabled;
  47768. private _pointerObserver;
  47769. private _attachedMesh;
  47770. private _boundingBoxColor;
  47771. private _defaultUtilityLayer;
  47772. private _defaultKeepDepthUtilityLayer;
  47773. /**
  47774. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47775. */
  47776. boundingBoxDragBehavior: SixDofDragBehavior;
  47777. /**
  47778. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47779. */
  47780. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47781. /**
  47782. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47783. */
  47784. usePointerToAttachGizmos: boolean;
  47785. /**
  47786. * Utility layer that the bounding box gizmo belongs to
  47787. */
  47788. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47789. /**
  47790. * Utility layer that all gizmos besides bounding box belong to
  47791. */
  47792. readonly utilityLayer: UtilityLayerRenderer;
  47793. /**
  47794. * Instatiates a gizmo manager
  47795. * @param scene the scene to overlay the gizmos on top of
  47796. */
  47797. constructor(scene: Scene);
  47798. /**
  47799. * Attaches a set of gizmos to the specified mesh
  47800. * @param mesh The mesh the gizmo's should be attached to
  47801. */
  47802. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47803. /**
  47804. * If the position gizmo is enabled
  47805. */
  47806. positionGizmoEnabled: boolean;
  47807. /**
  47808. * If the rotation gizmo is enabled
  47809. */
  47810. rotationGizmoEnabled: boolean;
  47811. /**
  47812. * If the scale gizmo is enabled
  47813. */
  47814. scaleGizmoEnabled: boolean;
  47815. /**
  47816. * If the boundingBox gizmo is enabled
  47817. */
  47818. boundingBoxGizmoEnabled: boolean;
  47819. /**
  47820. * Disposes of the gizmo manager
  47821. */
  47822. dispose(): void;
  47823. }
  47824. }
  47825. declare module "babylonjs/Lights/directionalLight" {
  47826. import { Camera } from "babylonjs/Cameras/camera";
  47827. import { Scene } from "babylonjs/scene";
  47828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47830. import { Light } from "babylonjs/Lights/light";
  47831. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47832. import { Effect } from "babylonjs/Materials/effect";
  47833. /**
  47834. * A directional light is defined by a direction (what a surprise!).
  47835. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47836. * 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.
  47837. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47838. */
  47839. export class DirectionalLight extends ShadowLight {
  47840. private _shadowFrustumSize;
  47841. /**
  47842. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47843. */
  47844. /**
  47845. * Specifies a fix frustum size for the shadow generation.
  47846. */
  47847. shadowFrustumSize: number;
  47848. private _shadowOrthoScale;
  47849. /**
  47850. * Gets the shadow projection scale against the optimal computed one.
  47851. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47852. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47853. */
  47854. /**
  47855. * Sets the shadow projection scale against the optimal computed one.
  47856. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47857. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47858. */
  47859. shadowOrthoScale: number;
  47860. /**
  47861. * Automatically compute the projection matrix to best fit (including all the casters)
  47862. * on each frame.
  47863. */
  47864. autoUpdateExtends: boolean;
  47865. private _orthoLeft;
  47866. private _orthoRight;
  47867. private _orthoTop;
  47868. private _orthoBottom;
  47869. /**
  47870. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47871. * The directional light is emitted from everywhere in the given direction.
  47872. * It can cast shadows.
  47873. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47874. * @param name The friendly name of the light
  47875. * @param direction The direction of the light
  47876. * @param scene The scene the light belongs to
  47877. */
  47878. constructor(name: string, direction: Vector3, scene: Scene);
  47879. /**
  47880. * Returns the string "DirectionalLight".
  47881. * @return The class name
  47882. */
  47883. getClassName(): string;
  47884. /**
  47885. * Returns the integer 1.
  47886. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47887. */
  47888. getTypeID(): number;
  47889. /**
  47890. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47891. * Returns the DirectionalLight Shadow projection matrix.
  47892. */
  47893. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47894. /**
  47895. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47896. * Returns the DirectionalLight Shadow projection matrix.
  47897. */
  47898. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47899. /**
  47900. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47901. * Returns the DirectionalLight Shadow projection matrix.
  47902. */
  47903. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47904. protected _buildUniformLayout(): void;
  47905. /**
  47906. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47907. * @param effect The effect to update
  47908. * @param lightIndex The index of the light in the effect to update
  47909. * @returns The directional light
  47910. */
  47911. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47912. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47913. /**
  47914. * Gets the minZ used for shadow according to both the scene and the light.
  47915. *
  47916. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47917. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47918. * @param activeCamera The camera we are returning the min for
  47919. * @returns the depth min z
  47920. */
  47921. getDepthMinZ(activeCamera: Camera): number;
  47922. /**
  47923. * Gets the maxZ used for shadow according to both the scene and the light.
  47924. *
  47925. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47926. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47927. * @param activeCamera The camera we are returning the max for
  47928. * @returns the depth max z
  47929. */
  47930. getDepthMaxZ(activeCamera: Camera): number;
  47931. /**
  47932. * Prepares the list of defines specific to the light type.
  47933. * @param defines the list of defines
  47934. * @param lightIndex defines the index of the light for the effect
  47935. */
  47936. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47937. }
  47938. }
  47939. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47940. import { Mesh } from "babylonjs/Meshes/mesh";
  47941. /**
  47942. * Class containing static functions to help procedurally build meshes
  47943. */
  47944. export class HemisphereBuilder {
  47945. /**
  47946. * Creates a hemisphere mesh
  47947. * @param name defines the name of the mesh
  47948. * @param options defines the options used to create the mesh
  47949. * @param scene defines the hosting scene
  47950. * @returns the hemisphere mesh
  47951. */
  47952. static CreateHemisphere(name: string, options: {
  47953. segments?: number;
  47954. diameter?: number;
  47955. sideOrientation?: number;
  47956. }, scene: any): Mesh;
  47957. }
  47958. }
  47959. declare module "babylonjs/Lights/spotLight" {
  47960. import { Nullable } from "babylonjs/types";
  47961. import { Scene } from "babylonjs/scene";
  47962. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47964. import { Effect } from "babylonjs/Materials/effect";
  47965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47966. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47967. /**
  47968. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47969. * These values define a cone of light starting from the position, emitting toward the direction.
  47970. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47971. * and the exponent defines the speed of the decay of the light with distance (reach).
  47972. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47973. */
  47974. export class SpotLight extends ShadowLight {
  47975. private _angle;
  47976. private _innerAngle;
  47977. private _cosHalfAngle;
  47978. private _lightAngleScale;
  47979. private _lightAngleOffset;
  47980. /**
  47981. * Gets the cone angle of the spot light in Radians.
  47982. */
  47983. /**
  47984. * Sets the cone angle of the spot light in Radians.
  47985. */
  47986. angle: number;
  47987. /**
  47988. * Only used in gltf falloff mode, this defines the angle where
  47989. * the directional falloff will start before cutting at angle which could be seen
  47990. * as outer angle.
  47991. */
  47992. /**
  47993. * Only used in gltf falloff mode, this defines the angle where
  47994. * the directional falloff will start before cutting at angle which could be seen
  47995. * as outer angle.
  47996. */
  47997. innerAngle: number;
  47998. private _shadowAngleScale;
  47999. /**
  48000. * Allows scaling the angle of the light for shadow generation only.
  48001. */
  48002. /**
  48003. * Allows scaling the angle of the light for shadow generation only.
  48004. */
  48005. shadowAngleScale: number;
  48006. /**
  48007. * The light decay speed with the distance from the emission spot.
  48008. */
  48009. exponent: number;
  48010. private _projectionTextureMatrix;
  48011. /**
  48012. * Allows reading the projecton texture
  48013. */
  48014. readonly projectionTextureMatrix: Matrix;
  48015. protected _projectionTextureLightNear: number;
  48016. /**
  48017. * Gets the near clip of the Spotlight for texture projection.
  48018. */
  48019. /**
  48020. * Sets the near clip of the Spotlight for texture projection.
  48021. */
  48022. projectionTextureLightNear: number;
  48023. protected _projectionTextureLightFar: number;
  48024. /**
  48025. * Gets the far clip of the Spotlight for texture projection.
  48026. */
  48027. /**
  48028. * Sets the far clip of the Spotlight for texture projection.
  48029. */
  48030. projectionTextureLightFar: number;
  48031. protected _projectionTextureUpDirection: Vector3;
  48032. /**
  48033. * Gets the Up vector of the Spotlight for texture projection.
  48034. */
  48035. /**
  48036. * Sets the Up vector of the Spotlight for texture projection.
  48037. */
  48038. projectionTextureUpDirection: Vector3;
  48039. private _projectionTexture;
  48040. /**
  48041. * Gets the projection texture of the light.
  48042. */
  48043. /**
  48044. * Sets the projection texture of the light.
  48045. */
  48046. projectionTexture: Nullable<BaseTexture>;
  48047. private _projectionTextureViewLightDirty;
  48048. private _projectionTextureProjectionLightDirty;
  48049. private _projectionTextureDirty;
  48050. private _projectionTextureViewTargetVector;
  48051. private _projectionTextureViewLightMatrix;
  48052. private _projectionTextureProjectionLightMatrix;
  48053. private _projectionTextureScalingMatrix;
  48054. /**
  48055. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48056. * It can cast shadows.
  48057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48058. * @param name The light friendly name
  48059. * @param position The position of the spot light in the scene
  48060. * @param direction The direction of the light in the scene
  48061. * @param angle The cone angle of the light in Radians
  48062. * @param exponent The light decay speed with the distance from the emission spot
  48063. * @param scene The scene the lights belongs to
  48064. */
  48065. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48066. /**
  48067. * Returns the string "SpotLight".
  48068. * @returns the class name
  48069. */
  48070. getClassName(): string;
  48071. /**
  48072. * Returns the integer 2.
  48073. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48074. */
  48075. getTypeID(): number;
  48076. /**
  48077. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48078. */
  48079. protected _setDirection(value: Vector3): void;
  48080. /**
  48081. * Overrides the position setter to recompute the projection texture view light Matrix.
  48082. */
  48083. protected _setPosition(value: Vector3): void;
  48084. /**
  48085. * 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.
  48086. * Returns the SpotLight.
  48087. */
  48088. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48089. protected _computeProjectionTextureViewLightMatrix(): void;
  48090. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48091. /**
  48092. * Main function for light texture projection matrix computing.
  48093. */
  48094. protected _computeProjectionTextureMatrix(): void;
  48095. protected _buildUniformLayout(): void;
  48096. private _computeAngleValues;
  48097. /**
  48098. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48099. * @param effect The effect to update
  48100. * @param lightIndex The index of the light in the effect to update
  48101. * @returns The spot light
  48102. */
  48103. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48104. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48105. /**
  48106. * Disposes the light and the associated resources.
  48107. */
  48108. dispose(): void;
  48109. /**
  48110. * Prepares the list of defines specific to the light type.
  48111. * @param defines the list of defines
  48112. * @param lightIndex defines the index of the light for the effect
  48113. */
  48114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48115. }
  48116. }
  48117. declare module "babylonjs/Gizmos/lightGizmo" {
  48118. import { Nullable } from "babylonjs/types";
  48119. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48120. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48121. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48122. import { Light } from "babylonjs/Lights/light";
  48123. /**
  48124. * Gizmo that enables viewing a light
  48125. */
  48126. export class LightGizmo extends Gizmo {
  48127. private _lightMesh;
  48128. private _material;
  48129. private cachedPosition;
  48130. private cachedForward;
  48131. /**
  48132. * Creates a LightGizmo
  48133. * @param gizmoLayer The utility layer the gizmo will be added to
  48134. */
  48135. constructor(gizmoLayer?: UtilityLayerRenderer);
  48136. private _light;
  48137. /**
  48138. * The light that the gizmo is attached to
  48139. */
  48140. light: Nullable<Light>;
  48141. /**
  48142. * Gets the material used to render the light gizmo
  48143. */
  48144. readonly material: StandardMaterial;
  48145. /**
  48146. * @hidden
  48147. * Updates the gizmo to match the attached mesh's position/rotation
  48148. */
  48149. protected _update(): void;
  48150. private static _Scale;
  48151. /**
  48152. * Creates the lines for a light mesh
  48153. */
  48154. private static _createLightLines;
  48155. /**
  48156. * Disposes of the light gizmo
  48157. */
  48158. dispose(): void;
  48159. private static _CreateHemisphericLightMesh;
  48160. private static _CreatePointLightMesh;
  48161. private static _CreateSpotLightMesh;
  48162. private static _CreateDirectionalLightMesh;
  48163. }
  48164. }
  48165. declare module "babylonjs/Gizmos/index" {
  48166. export * from "babylonjs/Gizmos/axisDragGizmo";
  48167. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48168. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48169. export * from "babylonjs/Gizmos/gizmo";
  48170. export * from "babylonjs/Gizmos/gizmoManager";
  48171. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48172. export * from "babylonjs/Gizmos/positionGizmo";
  48173. export * from "babylonjs/Gizmos/rotationGizmo";
  48174. export * from "babylonjs/Gizmos/scaleGizmo";
  48175. export * from "babylonjs/Gizmos/lightGizmo";
  48176. export * from "babylonjs/Gizmos/planeDragGizmo";
  48177. }
  48178. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48179. /** @hidden */
  48180. export var backgroundFragmentDeclaration: {
  48181. name: string;
  48182. shader: string;
  48183. };
  48184. }
  48185. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48186. /** @hidden */
  48187. export var backgroundUboDeclaration: {
  48188. name: string;
  48189. shader: string;
  48190. };
  48191. }
  48192. declare module "babylonjs/Shaders/background.fragment" {
  48193. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48194. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48195. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48196. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48197. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48198. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48199. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48200. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48201. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48202. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48203. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48204. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48205. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48206. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48207. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48208. /** @hidden */
  48209. export var backgroundPixelShader: {
  48210. name: string;
  48211. shader: string;
  48212. };
  48213. }
  48214. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48215. /** @hidden */
  48216. export var backgroundVertexDeclaration: {
  48217. name: string;
  48218. shader: string;
  48219. };
  48220. }
  48221. declare module "babylonjs/Shaders/background.vertex" {
  48222. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48223. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48224. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48225. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48226. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48227. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48228. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48229. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48230. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48231. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48232. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48233. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48234. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48235. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48236. /** @hidden */
  48237. export var backgroundVertexShader: {
  48238. name: string;
  48239. shader: string;
  48240. };
  48241. }
  48242. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48243. import { Nullable, int, float } from "babylonjs/types";
  48244. import { Scene } from "babylonjs/scene";
  48245. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48248. import { Mesh } from "babylonjs/Meshes/mesh";
  48249. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48250. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48251. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48253. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48254. import { Color3 } from "babylonjs/Maths/math.color";
  48255. import "babylonjs/Shaders/background.fragment";
  48256. import "babylonjs/Shaders/background.vertex";
  48257. /**
  48258. * Background material used to create an efficient environement around your scene.
  48259. */
  48260. export class BackgroundMaterial extends PushMaterial {
  48261. /**
  48262. * Standard reflectance value at parallel view angle.
  48263. */
  48264. static StandardReflectance0: number;
  48265. /**
  48266. * Standard reflectance value at grazing angle.
  48267. */
  48268. static StandardReflectance90: number;
  48269. protected _primaryColor: Color3;
  48270. /**
  48271. * Key light Color (multiply against the environement texture)
  48272. */
  48273. primaryColor: Color3;
  48274. protected __perceptualColor: Nullable<Color3>;
  48275. /**
  48276. * Experimental Internal Use Only.
  48277. *
  48278. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48279. * This acts as a helper to set the primary color to a more "human friendly" value.
  48280. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48281. * output color as close as possible from the chosen value.
  48282. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48283. * part of lighting setup.)
  48284. */
  48285. _perceptualColor: Nullable<Color3>;
  48286. protected _primaryColorShadowLevel: float;
  48287. /**
  48288. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48289. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48290. */
  48291. primaryColorShadowLevel: float;
  48292. protected _primaryColorHighlightLevel: float;
  48293. /**
  48294. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48295. * The primary color is used at the level chosen to define what the white area would look.
  48296. */
  48297. primaryColorHighlightLevel: float;
  48298. protected _reflectionTexture: Nullable<BaseTexture>;
  48299. /**
  48300. * Reflection Texture used in the material.
  48301. * Should be author in a specific way for the best result (refer to the documentation).
  48302. */
  48303. reflectionTexture: Nullable<BaseTexture>;
  48304. protected _reflectionBlur: float;
  48305. /**
  48306. * Reflection Texture level of blur.
  48307. *
  48308. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48309. * texture twice.
  48310. */
  48311. reflectionBlur: float;
  48312. protected _diffuseTexture: Nullable<BaseTexture>;
  48313. /**
  48314. * Diffuse Texture used in the material.
  48315. * Should be author in a specific way for the best result (refer to the documentation).
  48316. */
  48317. diffuseTexture: Nullable<BaseTexture>;
  48318. protected _shadowLights: Nullable<IShadowLight[]>;
  48319. /**
  48320. * Specify the list of lights casting shadow on the material.
  48321. * All scene shadow lights will be included if null.
  48322. */
  48323. shadowLights: Nullable<IShadowLight[]>;
  48324. protected _shadowLevel: float;
  48325. /**
  48326. * Helps adjusting the shadow to a softer level if required.
  48327. * 0 means black shadows and 1 means no shadows.
  48328. */
  48329. shadowLevel: float;
  48330. protected _sceneCenter: Vector3;
  48331. /**
  48332. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48333. * It is usually zero but might be interesting to modify according to your setup.
  48334. */
  48335. sceneCenter: Vector3;
  48336. protected _opacityFresnel: boolean;
  48337. /**
  48338. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48339. * This helps ensuring a nice transition when the camera goes under the ground.
  48340. */
  48341. opacityFresnel: boolean;
  48342. protected _reflectionFresnel: boolean;
  48343. /**
  48344. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48345. * This helps adding a mirror texture on the ground.
  48346. */
  48347. reflectionFresnel: boolean;
  48348. protected _reflectionFalloffDistance: number;
  48349. /**
  48350. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48351. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48352. */
  48353. reflectionFalloffDistance: number;
  48354. protected _reflectionAmount: number;
  48355. /**
  48356. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48357. */
  48358. reflectionAmount: number;
  48359. protected _reflectionReflectance0: number;
  48360. /**
  48361. * This specifies the weight of the reflection at grazing angle.
  48362. */
  48363. reflectionReflectance0: number;
  48364. protected _reflectionReflectance90: number;
  48365. /**
  48366. * This specifies the weight of the reflection at a perpendicular point of view.
  48367. */
  48368. reflectionReflectance90: number;
  48369. /**
  48370. * Sets the reflection reflectance fresnel values according to the default standard
  48371. * empirically know to work well :-)
  48372. */
  48373. reflectionStandardFresnelWeight: number;
  48374. protected _useRGBColor: boolean;
  48375. /**
  48376. * Helps to directly use the maps channels instead of their level.
  48377. */
  48378. useRGBColor: boolean;
  48379. protected _enableNoise: boolean;
  48380. /**
  48381. * This helps reducing the banding effect that could occur on the background.
  48382. */
  48383. enableNoise: boolean;
  48384. /**
  48385. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48386. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48387. * Recommended to be keep at 1.0 except for special cases.
  48388. */
  48389. fovMultiplier: number;
  48390. private _fovMultiplier;
  48391. /**
  48392. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48393. */
  48394. useEquirectangularFOV: boolean;
  48395. private _maxSimultaneousLights;
  48396. /**
  48397. * Number of Simultaneous lights allowed on the material.
  48398. */
  48399. maxSimultaneousLights: int;
  48400. /**
  48401. * Default configuration related to image processing available in the Background Material.
  48402. */
  48403. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48404. /**
  48405. * Keep track of the image processing observer to allow dispose and replace.
  48406. */
  48407. private _imageProcessingObserver;
  48408. /**
  48409. * Attaches a new image processing configuration to the PBR Material.
  48410. * @param configuration (if null the scene configuration will be use)
  48411. */
  48412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48413. /**
  48414. * Gets the image processing configuration used either in this material.
  48415. */
  48416. /**
  48417. * Sets the Default image processing configuration used either in the this material.
  48418. *
  48419. * If sets to null, the scene one is in use.
  48420. */
  48421. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48422. /**
  48423. * Gets wether the color curves effect is enabled.
  48424. */
  48425. /**
  48426. * Sets wether the color curves effect is enabled.
  48427. */
  48428. cameraColorCurvesEnabled: boolean;
  48429. /**
  48430. * Gets wether the color grading effect is enabled.
  48431. */
  48432. /**
  48433. * Gets wether the color grading effect is enabled.
  48434. */
  48435. cameraColorGradingEnabled: boolean;
  48436. /**
  48437. * Gets wether tonemapping is enabled or not.
  48438. */
  48439. /**
  48440. * Sets wether tonemapping is enabled or not
  48441. */
  48442. cameraToneMappingEnabled: boolean;
  48443. /**
  48444. * The camera exposure used on this material.
  48445. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48446. * This corresponds to a photographic exposure.
  48447. */
  48448. /**
  48449. * The camera exposure used on this material.
  48450. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48451. * This corresponds to a photographic exposure.
  48452. */
  48453. cameraExposure: float;
  48454. /**
  48455. * Gets The camera contrast used on this material.
  48456. */
  48457. /**
  48458. * Sets The camera contrast used on this material.
  48459. */
  48460. cameraContrast: float;
  48461. /**
  48462. * Gets the Color Grading 2D Lookup Texture.
  48463. */
  48464. /**
  48465. * Sets the Color Grading 2D Lookup Texture.
  48466. */
  48467. cameraColorGradingTexture: Nullable<BaseTexture>;
  48468. /**
  48469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48471. * 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;
  48472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48473. */
  48474. /**
  48475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48477. * 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;
  48478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48479. */
  48480. cameraColorCurves: Nullable<ColorCurves>;
  48481. /**
  48482. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48483. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48484. */
  48485. switchToBGR: boolean;
  48486. private _renderTargets;
  48487. private _reflectionControls;
  48488. private _white;
  48489. private _primaryShadowColor;
  48490. private _primaryHighlightColor;
  48491. /**
  48492. * Instantiates a Background Material in the given scene
  48493. * @param name The friendly name of the material
  48494. * @param scene The scene to add the material to
  48495. */
  48496. constructor(name: string, scene: Scene);
  48497. /**
  48498. * Gets a boolean indicating that current material needs to register RTT
  48499. */
  48500. readonly hasRenderTargetTextures: boolean;
  48501. /**
  48502. * The entire material has been created in order to prevent overdraw.
  48503. * @returns false
  48504. */
  48505. needAlphaTesting(): boolean;
  48506. /**
  48507. * The entire material has been created in order to prevent overdraw.
  48508. * @returns true if blending is enable
  48509. */
  48510. needAlphaBlending(): boolean;
  48511. /**
  48512. * Checks wether the material is ready to be rendered for a given mesh.
  48513. * @param mesh The mesh to render
  48514. * @param subMesh The submesh to check against
  48515. * @param useInstances Specify wether or not the material is used with instances
  48516. * @returns true if all the dependencies are ready (Textures, Effects...)
  48517. */
  48518. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48519. /**
  48520. * Compute the primary color according to the chosen perceptual color.
  48521. */
  48522. private _computePrimaryColorFromPerceptualColor;
  48523. /**
  48524. * Compute the highlights and shadow colors according to their chosen levels.
  48525. */
  48526. private _computePrimaryColors;
  48527. /**
  48528. * Build the uniform buffer used in the material.
  48529. */
  48530. buildUniformLayout(): void;
  48531. /**
  48532. * Unbind the material.
  48533. */
  48534. unbind(): void;
  48535. /**
  48536. * Bind only the world matrix to the material.
  48537. * @param world The world matrix to bind.
  48538. */
  48539. bindOnlyWorldMatrix(world: Matrix): void;
  48540. /**
  48541. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48542. * @param world The world matrix to bind.
  48543. * @param subMesh The submesh to bind for.
  48544. */
  48545. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48546. /**
  48547. * Checks to see if a texture is used in the material.
  48548. * @param texture - Base texture to use.
  48549. * @returns - Boolean specifying if a texture is used in the material.
  48550. */
  48551. hasTexture(texture: BaseTexture): boolean;
  48552. /**
  48553. * Dispose the material.
  48554. * @param forceDisposeEffect Force disposal of the associated effect.
  48555. * @param forceDisposeTextures Force disposal of the associated textures.
  48556. */
  48557. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48558. /**
  48559. * Clones the material.
  48560. * @param name The cloned name.
  48561. * @returns The cloned material.
  48562. */
  48563. clone(name: string): BackgroundMaterial;
  48564. /**
  48565. * Serializes the current material to its JSON representation.
  48566. * @returns The JSON representation.
  48567. */
  48568. serialize(): any;
  48569. /**
  48570. * Gets the class name of the material
  48571. * @returns "BackgroundMaterial"
  48572. */
  48573. getClassName(): string;
  48574. /**
  48575. * Parse a JSON input to create back a background material.
  48576. * @param source The JSON data to parse
  48577. * @param scene The scene to create the parsed material in
  48578. * @param rootUrl The root url of the assets the material depends upon
  48579. * @returns the instantiated BackgroundMaterial.
  48580. */
  48581. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48582. }
  48583. }
  48584. declare module "babylonjs/Helpers/environmentHelper" {
  48585. import { Observable } from "babylonjs/Misc/observable";
  48586. import { Nullable } from "babylonjs/types";
  48587. import { Scene } from "babylonjs/scene";
  48588. import { Vector3 } from "babylonjs/Maths/math.vector";
  48589. import { Color3 } from "babylonjs/Maths/math.color";
  48590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48591. import { Mesh } from "babylonjs/Meshes/mesh";
  48592. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48593. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48594. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48595. import "babylonjs/Meshes/Builders/planeBuilder";
  48596. import "babylonjs/Meshes/Builders/boxBuilder";
  48597. /**
  48598. * Represents the different options available during the creation of
  48599. * a Environment helper.
  48600. *
  48601. * This can control the default ground, skybox and image processing setup of your scene.
  48602. */
  48603. export interface IEnvironmentHelperOptions {
  48604. /**
  48605. * Specifies wether or not to create a ground.
  48606. * True by default.
  48607. */
  48608. createGround: boolean;
  48609. /**
  48610. * Specifies the ground size.
  48611. * 15 by default.
  48612. */
  48613. groundSize: number;
  48614. /**
  48615. * The texture used on the ground for the main color.
  48616. * Comes from the BabylonJS CDN by default.
  48617. *
  48618. * Remarks: Can be either a texture or a url.
  48619. */
  48620. groundTexture: string | BaseTexture;
  48621. /**
  48622. * The color mixed in the ground texture by default.
  48623. * BabylonJS clearColor by default.
  48624. */
  48625. groundColor: Color3;
  48626. /**
  48627. * Specifies the ground opacity.
  48628. * 1 by default.
  48629. */
  48630. groundOpacity: number;
  48631. /**
  48632. * Enables the ground to receive shadows.
  48633. * True by default.
  48634. */
  48635. enableGroundShadow: boolean;
  48636. /**
  48637. * Helps preventing the shadow to be fully black on the ground.
  48638. * 0.5 by default.
  48639. */
  48640. groundShadowLevel: number;
  48641. /**
  48642. * Creates a mirror texture attach to the ground.
  48643. * false by default.
  48644. */
  48645. enableGroundMirror: boolean;
  48646. /**
  48647. * Specifies the ground mirror size ratio.
  48648. * 0.3 by default as the default kernel is 64.
  48649. */
  48650. groundMirrorSizeRatio: number;
  48651. /**
  48652. * Specifies the ground mirror blur kernel size.
  48653. * 64 by default.
  48654. */
  48655. groundMirrorBlurKernel: number;
  48656. /**
  48657. * Specifies the ground mirror visibility amount.
  48658. * 1 by default
  48659. */
  48660. groundMirrorAmount: number;
  48661. /**
  48662. * Specifies the ground mirror reflectance weight.
  48663. * This uses the standard weight of the background material to setup the fresnel effect
  48664. * of the mirror.
  48665. * 1 by default.
  48666. */
  48667. groundMirrorFresnelWeight: number;
  48668. /**
  48669. * Specifies the ground mirror Falloff distance.
  48670. * This can helps reducing the size of the reflection.
  48671. * 0 by Default.
  48672. */
  48673. groundMirrorFallOffDistance: number;
  48674. /**
  48675. * Specifies the ground mirror texture type.
  48676. * Unsigned Int by Default.
  48677. */
  48678. groundMirrorTextureType: number;
  48679. /**
  48680. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48681. * the shown objects.
  48682. */
  48683. groundYBias: number;
  48684. /**
  48685. * Specifies wether or not to create a skybox.
  48686. * True by default.
  48687. */
  48688. createSkybox: boolean;
  48689. /**
  48690. * Specifies the skybox size.
  48691. * 20 by default.
  48692. */
  48693. skyboxSize: number;
  48694. /**
  48695. * The texture used on the skybox for the main color.
  48696. * Comes from the BabylonJS CDN by default.
  48697. *
  48698. * Remarks: Can be either a texture or a url.
  48699. */
  48700. skyboxTexture: string | BaseTexture;
  48701. /**
  48702. * The color mixed in the skybox texture by default.
  48703. * BabylonJS clearColor by default.
  48704. */
  48705. skyboxColor: Color3;
  48706. /**
  48707. * The background rotation around the Y axis of the scene.
  48708. * This helps aligning the key lights of your scene with the background.
  48709. * 0 by default.
  48710. */
  48711. backgroundYRotation: number;
  48712. /**
  48713. * Compute automatically the size of the elements to best fit with the scene.
  48714. */
  48715. sizeAuto: boolean;
  48716. /**
  48717. * Default position of the rootMesh if autoSize is not true.
  48718. */
  48719. rootPosition: Vector3;
  48720. /**
  48721. * Sets up the image processing in the scene.
  48722. * true by default.
  48723. */
  48724. setupImageProcessing: boolean;
  48725. /**
  48726. * The texture used as your environment texture in the scene.
  48727. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48728. *
  48729. * Remarks: Can be either a texture or a url.
  48730. */
  48731. environmentTexture: string | BaseTexture;
  48732. /**
  48733. * The value of the exposure to apply to the scene.
  48734. * 0.6 by default if setupImageProcessing is true.
  48735. */
  48736. cameraExposure: number;
  48737. /**
  48738. * The value of the contrast to apply to the scene.
  48739. * 1.6 by default if setupImageProcessing is true.
  48740. */
  48741. cameraContrast: number;
  48742. /**
  48743. * Specifies wether or not tonemapping should be enabled in the scene.
  48744. * true by default if setupImageProcessing is true.
  48745. */
  48746. toneMappingEnabled: boolean;
  48747. }
  48748. /**
  48749. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48750. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48751. * It also helps with the default setup of your imageProcessing configuration.
  48752. */
  48753. export class EnvironmentHelper {
  48754. /**
  48755. * Default ground texture URL.
  48756. */
  48757. private static _groundTextureCDNUrl;
  48758. /**
  48759. * Default skybox texture URL.
  48760. */
  48761. private static _skyboxTextureCDNUrl;
  48762. /**
  48763. * Default environment texture URL.
  48764. */
  48765. private static _environmentTextureCDNUrl;
  48766. /**
  48767. * Creates the default options for the helper.
  48768. */
  48769. private static _getDefaultOptions;
  48770. private _rootMesh;
  48771. /**
  48772. * Gets the root mesh created by the helper.
  48773. */
  48774. readonly rootMesh: Mesh;
  48775. private _skybox;
  48776. /**
  48777. * Gets the skybox created by the helper.
  48778. */
  48779. readonly skybox: Nullable<Mesh>;
  48780. private _skyboxTexture;
  48781. /**
  48782. * Gets the skybox texture created by the helper.
  48783. */
  48784. readonly skyboxTexture: Nullable<BaseTexture>;
  48785. private _skyboxMaterial;
  48786. /**
  48787. * Gets the skybox material created by the helper.
  48788. */
  48789. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48790. private _ground;
  48791. /**
  48792. * Gets the ground mesh created by the helper.
  48793. */
  48794. readonly ground: Nullable<Mesh>;
  48795. private _groundTexture;
  48796. /**
  48797. * Gets the ground texture created by the helper.
  48798. */
  48799. readonly groundTexture: Nullable<BaseTexture>;
  48800. private _groundMirror;
  48801. /**
  48802. * Gets the ground mirror created by the helper.
  48803. */
  48804. readonly groundMirror: Nullable<MirrorTexture>;
  48805. /**
  48806. * Gets the ground mirror render list to helps pushing the meshes
  48807. * you wish in the ground reflection.
  48808. */
  48809. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48810. private _groundMaterial;
  48811. /**
  48812. * Gets the ground material created by the helper.
  48813. */
  48814. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48815. /**
  48816. * Stores the creation options.
  48817. */
  48818. private readonly _scene;
  48819. private _options;
  48820. /**
  48821. * This observable will be notified with any error during the creation of the environment,
  48822. * mainly texture creation errors.
  48823. */
  48824. onErrorObservable: Observable<{
  48825. message?: string;
  48826. exception?: any;
  48827. }>;
  48828. /**
  48829. * constructor
  48830. * @param options Defines the options we want to customize the helper
  48831. * @param scene The scene to add the material to
  48832. */
  48833. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48834. /**
  48835. * Updates the background according to the new options
  48836. * @param options
  48837. */
  48838. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48839. /**
  48840. * Sets the primary color of all the available elements.
  48841. * @param color the main color to affect to the ground and the background
  48842. */
  48843. setMainColor(color: Color3): void;
  48844. /**
  48845. * Setup the image processing according to the specified options.
  48846. */
  48847. private _setupImageProcessing;
  48848. /**
  48849. * Setup the environment texture according to the specified options.
  48850. */
  48851. private _setupEnvironmentTexture;
  48852. /**
  48853. * Setup the background according to the specified options.
  48854. */
  48855. private _setupBackground;
  48856. /**
  48857. * Get the scene sizes according to the setup.
  48858. */
  48859. private _getSceneSize;
  48860. /**
  48861. * Setup the ground according to the specified options.
  48862. */
  48863. private _setupGround;
  48864. /**
  48865. * Setup the ground material according to the specified options.
  48866. */
  48867. private _setupGroundMaterial;
  48868. /**
  48869. * Setup the ground diffuse texture according to the specified options.
  48870. */
  48871. private _setupGroundDiffuseTexture;
  48872. /**
  48873. * Setup the ground mirror texture according to the specified options.
  48874. */
  48875. private _setupGroundMirrorTexture;
  48876. /**
  48877. * Setup the ground to receive the mirror texture.
  48878. */
  48879. private _setupMirrorInGroundMaterial;
  48880. /**
  48881. * Setup the skybox according to the specified options.
  48882. */
  48883. private _setupSkybox;
  48884. /**
  48885. * Setup the skybox material according to the specified options.
  48886. */
  48887. private _setupSkyboxMaterial;
  48888. /**
  48889. * Setup the skybox reflection texture according to the specified options.
  48890. */
  48891. private _setupSkyboxReflectionTexture;
  48892. private _errorHandler;
  48893. /**
  48894. * Dispose all the elements created by the Helper.
  48895. */
  48896. dispose(): void;
  48897. }
  48898. }
  48899. declare module "babylonjs/Helpers/photoDome" {
  48900. import { Observable } from "babylonjs/Misc/observable";
  48901. import { Nullable } from "babylonjs/types";
  48902. import { Scene } from "babylonjs/scene";
  48903. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48904. import { Mesh } from "babylonjs/Meshes/mesh";
  48905. import { Texture } from "babylonjs/Materials/Textures/texture";
  48906. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48907. import "babylonjs/Meshes/Builders/sphereBuilder";
  48908. /**
  48909. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48910. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48911. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48912. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48913. */
  48914. export class PhotoDome extends TransformNode {
  48915. /**
  48916. * Define the image as a Monoscopic panoramic 360 image.
  48917. */
  48918. static readonly MODE_MONOSCOPIC: number;
  48919. /**
  48920. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48921. */
  48922. static readonly MODE_TOPBOTTOM: number;
  48923. /**
  48924. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48925. */
  48926. static readonly MODE_SIDEBYSIDE: number;
  48927. private _useDirectMapping;
  48928. /**
  48929. * The texture being displayed on the sphere
  48930. */
  48931. protected _photoTexture: Texture;
  48932. /**
  48933. * Gets or sets the texture being displayed on the sphere
  48934. */
  48935. photoTexture: Texture;
  48936. /**
  48937. * Observable raised when an error occured while loading the 360 image
  48938. */
  48939. onLoadErrorObservable: Observable<string>;
  48940. /**
  48941. * The skybox material
  48942. */
  48943. protected _material: BackgroundMaterial;
  48944. /**
  48945. * The surface used for the skybox
  48946. */
  48947. protected _mesh: Mesh;
  48948. /**
  48949. * Gets the mesh used for the skybox.
  48950. */
  48951. readonly mesh: Mesh;
  48952. /**
  48953. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48954. * Also see the options.resolution property.
  48955. */
  48956. fovMultiplier: number;
  48957. private _imageMode;
  48958. /**
  48959. * Gets or set the current video mode for the video. It can be:
  48960. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48961. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48962. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48963. */
  48964. imageMode: number;
  48965. /**
  48966. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48967. * @param name Element's name, child elements will append suffixes for their own names.
  48968. * @param urlsOfPhoto defines the url of the photo to display
  48969. * @param options defines an object containing optional or exposed sub element properties
  48970. * @param onError defines a callback called when an error occured while loading the texture
  48971. */
  48972. constructor(name: string, urlOfPhoto: string, options: {
  48973. resolution?: number;
  48974. size?: number;
  48975. useDirectMapping?: boolean;
  48976. faceForward?: boolean;
  48977. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48978. private _onBeforeCameraRenderObserver;
  48979. private _changeImageMode;
  48980. /**
  48981. * Releases resources associated with this node.
  48982. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48983. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48984. */
  48985. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48986. }
  48987. }
  48988. declare module "babylonjs/Misc/rgbdTextureTools" {
  48989. import "babylonjs/Shaders/rgbdDecode.fragment";
  48990. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48991. import { Texture } from "babylonjs/Materials/Textures/texture";
  48992. /**
  48993. * Class used to host RGBD texture specific utilities
  48994. */
  48995. export class RGBDTextureTools {
  48996. /**
  48997. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48998. * @param texture the texture to expand.
  48999. */
  49000. static ExpandRGBDTexture(texture: Texture): void;
  49001. }
  49002. }
  49003. declare module "babylonjs/Misc/brdfTextureTools" {
  49004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49005. import { Scene } from "babylonjs/scene";
  49006. /**
  49007. * Class used to host texture specific utilities
  49008. */
  49009. export class BRDFTextureTools {
  49010. /**
  49011. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49012. * @param scene defines the hosting scene
  49013. * @returns the environment BRDF texture
  49014. */
  49015. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49016. private static _environmentBRDFBase64Texture;
  49017. }
  49018. }
  49019. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49020. import { Nullable } from "babylonjs/types";
  49021. import { Color3 } from "babylonjs/Maths/math.color";
  49022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49023. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49024. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49025. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49026. import { Engine } from "babylonjs/Engines/engine";
  49027. import { Scene } from "babylonjs/scene";
  49028. /**
  49029. * @hidden
  49030. */
  49031. export interface IMaterialClearCoatDefines {
  49032. CLEARCOAT: boolean;
  49033. CLEARCOAT_DEFAULTIOR: boolean;
  49034. CLEARCOAT_TEXTURE: boolean;
  49035. CLEARCOAT_TEXTUREDIRECTUV: number;
  49036. CLEARCOAT_BUMP: boolean;
  49037. CLEARCOAT_BUMPDIRECTUV: number;
  49038. CLEARCOAT_TINT: boolean;
  49039. CLEARCOAT_TINT_TEXTURE: boolean;
  49040. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49041. /** @hidden */
  49042. _areTexturesDirty: boolean;
  49043. }
  49044. /**
  49045. * Define the code related to the clear coat parameters of the pbr material.
  49046. */
  49047. export class PBRClearCoatConfiguration {
  49048. /**
  49049. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49050. * The default fits with a polyurethane material.
  49051. */
  49052. private static readonly _DefaultIndexOfRefraction;
  49053. private _isEnabled;
  49054. /**
  49055. * Defines if the clear coat is enabled in the material.
  49056. */
  49057. isEnabled: boolean;
  49058. /**
  49059. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49060. */
  49061. intensity: number;
  49062. /**
  49063. * Defines the clear coat layer roughness.
  49064. */
  49065. roughness: number;
  49066. private _indexOfRefraction;
  49067. /**
  49068. * Defines the index of refraction of the clear coat.
  49069. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49070. * The default fits with a polyurethane material.
  49071. * Changing the default value is more performance intensive.
  49072. */
  49073. indexOfRefraction: number;
  49074. private _texture;
  49075. /**
  49076. * Stores the clear coat values in a texture.
  49077. */
  49078. texture: Nullable<BaseTexture>;
  49079. private _bumpTexture;
  49080. /**
  49081. * Define the clear coat specific bump texture.
  49082. */
  49083. bumpTexture: Nullable<BaseTexture>;
  49084. private _isTintEnabled;
  49085. /**
  49086. * Defines if the clear coat tint is enabled in the material.
  49087. */
  49088. isTintEnabled: boolean;
  49089. /**
  49090. * Defines the clear coat tint of the material.
  49091. * This is only use if tint is enabled
  49092. */
  49093. tintColor: Color3;
  49094. /**
  49095. * Defines the distance at which the tint color should be found in the
  49096. * clear coat media.
  49097. * This is only use if tint is enabled
  49098. */
  49099. tintColorAtDistance: number;
  49100. /**
  49101. * Defines the clear coat layer thickness.
  49102. * This is only use if tint is enabled
  49103. */
  49104. tintThickness: number;
  49105. private _tintTexture;
  49106. /**
  49107. * Stores the clear tint values in a texture.
  49108. * rgb is tint
  49109. * a is a thickness factor
  49110. */
  49111. tintTexture: Nullable<BaseTexture>;
  49112. /** @hidden */
  49113. private _internalMarkAllSubMeshesAsTexturesDirty;
  49114. /** @hidden */
  49115. _markAllSubMeshesAsTexturesDirty(): void;
  49116. /**
  49117. * Instantiate a new istance of clear coat configuration.
  49118. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49119. */
  49120. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49121. /**
  49122. * Gets wehter the submesh is ready to be used or not.
  49123. * @param defines the list of "defines" to update.
  49124. * @param scene defines the scene the material belongs to.
  49125. * @param engine defines the engine the material belongs to.
  49126. * @param disableBumpMap defines wether the material disables bump or not.
  49127. * @returns - boolean indicating that the submesh is ready or not.
  49128. */
  49129. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49130. /**
  49131. * Checks to see if a texture is used in the material.
  49132. * @param defines the list of "defines" to update.
  49133. * @param scene defines the scene to the material belongs to.
  49134. */
  49135. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49136. /**
  49137. * Binds the material data.
  49138. * @param uniformBuffer defines the Uniform buffer to fill in.
  49139. * @param scene defines the scene the material belongs to.
  49140. * @param engine defines the engine the material belongs to.
  49141. * @param disableBumpMap defines wether the material disables bump or not.
  49142. * @param isFrozen defines wether the material is frozen or not.
  49143. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49144. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49145. */
  49146. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49147. /**
  49148. * Checks to see if a texture is used in the material.
  49149. * @param texture - Base texture to use.
  49150. * @returns - Boolean specifying if a texture is used in the material.
  49151. */
  49152. hasTexture(texture: BaseTexture): boolean;
  49153. /**
  49154. * Returns an array of the actively used textures.
  49155. * @param activeTextures Array of BaseTextures
  49156. */
  49157. getActiveTextures(activeTextures: BaseTexture[]): void;
  49158. /**
  49159. * Returns the animatable textures.
  49160. * @param animatables Array of animatable textures.
  49161. */
  49162. getAnimatables(animatables: IAnimatable[]): void;
  49163. /**
  49164. * Disposes the resources of the material.
  49165. * @param forceDisposeTextures - Forces the disposal of all textures.
  49166. */
  49167. dispose(forceDisposeTextures?: boolean): void;
  49168. /**
  49169. * Get the current class name of the texture useful for serialization or dynamic coding.
  49170. * @returns "PBRClearCoatConfiguration"
  49171. */
  49172. getClassName(): string;
  49173. /**
  49174. * Add fallbacks to the effect fallbacks list.
  49175. * @param defines defines the Base texture to use.
  49176. * @param fallbacks defines the current fallback list.
  49177. * @param currentRank defines the current fallback rank.
  49178. * @returns the new fallback rank.
  49179. */
  49180. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49181. /**
  49182. * Add the required uniforms to the current list.
  49183. * @param uniforms defines the current uniform list.
  49184. */
  49185. static AddUniforms(uniforms: string[]): void;
  49186. /**
  49187. * Add the required samplers to the current list.
  49188. * @param samplers defines the current sampler list.
  49189. */
  49190. static AddSamplers(samplers: string[]): void;
  49191. /**
  49192. * Add the required uniforms to the current buffer.
  49193. * @param uniformBuffer defines the current uniform buffer.
  49194. */
  49195. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49196. /**
  49197. * Makes a duplicate of the current configuration into another one.
  49198. * @param clearCoatConfiguration define the config where to copy the info
  49199. */
  49200. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49201. /**
  49202. * Serializes this clear coat configuration.
  49203. * @returns - An object with the serialized config.
  49204. */
  49205. serialize(): any;
  49206. /**
  49207. * Parses a anisotropy Configuration from a serialized object.
  49208. * @param source - Serialized object.
  49209. * @param scene Defines the scene we are parsing for
  49210. * @param rootUrl Defines the rootUrl to load from
  49211. */
  49212. parse(source: any, scene: Scene, rootUrl: string): void;
  49213. }
  49214. }
  49215. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49216. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49218. import { Vector2 } from "babylonjs/Maths/math.vector";
  49219. import { Scene } from "babylonjs/scene";
  49220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49221. import { Nullable } from "babylonjs/types";
  49222. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49223. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49224. /**
  49225. * @hidden
  49226. */
  49227. export interface IMaterialAnisotropicDefines {
  49228. ANISOTROPIC: boolean;
  49229. ANISOTROPIC_TEXTURE: boolean;
  49230. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49231. MAINUV1: boolean;
  49232. _areTexturesDirty: boolean;
  49233. _needUVs: boolean;
  49234. }
  49235. /**
  49236. * Define the code related to the anisotropic parameters of the pbr material.
  49237. */
  49238. export class PBRAnisotropicConfiguration {
  49239. private _isEnabled;
  49240. /**
  49241. * Defines if the anisotropy is enabled in the material.
  49242. */
  49243. isEnabled: boolean;
  49244. /**
  49245. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49246. */
  49247. intensity: number;
  49248. /**
  49249. * Defines if the effect is along the tangents, bitangents or in between.
  49250. * By default, the effect is "strectching" the highlights along the tangents.
  49251. */
  49252. direction: Vector2;
  49253. private _texture;
  49254. /**
  49255. * Stores the anisotropy values in a texture.
  49256. * rg is direction (like normal from -1 to 1)
  49257. * b is a intensity
  49258. */
  49259. texture: Nullable<BaseTexture>;
  49260. /** @hidden */
  49261. private _internalMarkAllSubMeshesAsTexturesDirty;
  49262. /** @hidden */
  49263. _markAllSubMeshesAsTexturesDirty(): void;
  49264. /**
  49265. * Instantiate a new istance of anisotropy configuration.
  49266. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49267. */
  49268. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49269. /**
  49270. * Specifies that the submesh is ready to be used.
  49271. * @param defines the list of "defines" to update.
  49272. * @param scene defines the scene the material belongs to.
  49273. * @returns - boolean indicating that the submesh is ready or not.
  49274. */
  49275. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49276. /**
  49277. * Checks to see if a texture is used in the material.
  49278. * @param defines the list of "defines" to update.
  49279. * @param mesh the mesh we are preparing the defines for.
  49280. * @param scene defines the scene the material belongs to.
  49281. */
  49282. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49283. /**
  49284. * Binds the material data.
  49285. * @param uniformBuffer defines the Uniform buffer to fill in.
  49286. * @param scene defines the scene the material belongs to.
  49287. * @param isFrozen defines wether the material is frozen or not.
  49288. */
  49289. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49290. /**
  49291. * Checks to see if a texture is used in the material.
  49292. * @param texture - Base texture to use.
  49293. * @returns - Boolean specifying if a texture is used in the material.
  49294. */
  49295. hasTexture(texture: BaseTexture): boolean;
  49296. /**
  49297. * Returns an array of the actively used textures.
  49298. * @param activeTextures Array of BaseTextures
  49299. */
  49300. getActiveTextures(activeTextures: BaseTexture[]): void;
  49301. /**
  49302. * Returns the animatable textures.
  49303. * @param animatables Array of animatable textures.
  49304. */
  49305. getAnimatables(animatables: IAnimatable[]): void;
  49306. /**
  49307. * Disposes the resources of the material.
  49308. * @param forceDisposeTextures - Forces the disposal of all textures.
  49309. */
  49310. dispose(forceDisposeTextures?: boolean): void;
  49311. /**
  49312. * Get the current class name of the texture useful for serialization or dynamic coding.
  49313. * @returns "PBRAnisotropicConfiguration"
  49314. */
  49315. getClassName(): string;
  49316. /**
  49317. * Add fallbacks to the effect fallbacks list.
  49318. * @param defines defines the Base texture to use.
  49319. * @param fallbacks defines the current fallback list.
  49320. * @param currentRank defines the current fallback rank.
  49321. * @returns the new fallback rank.
  49322. */
  49323. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49324. /**
  49325. * Add the required uniforms to the current list.
  49326. * @param uniforms defines the current uniform list.
  49327. */
  49328. static AddUniforms(uniforms: string[]): void;
  49329. /**
  49330. * Add the required uniforms to the current buffer.
  49331. * @param uniformBuffer defines the current uniform buffer.
  49332. */
  49333. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49334. /**
  49335. * Add the required samplers to the current list.
  49336. * @param samplers defines the current sampler list.
  49337. */
  49338. static AddSamplers(samplers: string[]): void;
  49339. /**
  49340. * Makes a duplicate of the current configuration into another one.
  49341. * @param anisotropicConfiguration define the config where to copy the info
  49342. */
  49343. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49344. /**
  49345. * Serializes this anisotropy configuration.
  49346. * @returns - An object with the serialized config.
  49347. */
  49348. serialize(): any;
  49349. /**
  49350. * Parses a anisotropy Configuration from a serialized object.
  49351. * @param source - Serialized object.
  49352. * @param scene Defines the scene we are parsing for
  49353. * @param rootUrl Defines the rootUrl to load from
  49354. */
  49355. parse(source: any, scene: Scene, rootUrl: string): void;
  49356. }
  49357. }
  49358. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49359. import { Scene } from "babylonjs/scene";
  49360. /**
  49361. * @hidden
  49362. */
  49363. export interface IMaterialBRDFDefines {
  49364. BRDF_V_HEIGHT_CORRELATED: boolean;
  49365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49366. SPHERICAL_HARMONICS: boolean;
  49367. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49368. /** @hidden */
  49369. _areMiscDirty: boolean;
  49370. }
  49371. /**
  49372. * Define the code related to the BRDF parameters of the pbr material.
  49373. */
  49374. export class PBRBRDFConfiguration {
  49375. /**
  49376. * Default value used for the energy conservation.
  49377. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49378. */
  49379. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49380. /**
  49381. * Default value used for the Smith Visibility Height Correlated mode.
  49382. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49383. */
  49384. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49385. /**
  49386. * Default value used for the IBL diffuse part.
  49387. * This can help switching back to the polynomials mode globally which is a tiny bit
  49388. * less GPU intensive at the drawback of a lower quality.
  49389. */
  49390. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49391. /**
  49392. * Default value used for activating energy conservation for the specular workflow.
  49393. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49394. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49395. */
  49396. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49397. private _useEnergyConservation;
  49398. /**
  49399. * Defines if the material uses energy conservation.
  49400. */
  49401. useEnergyConservation: boolean;
  49402. private _useSmithVisibilityHeightCorrelated;
  49403. /**
  49404. * LEGACY Mode set to false
  49405. * Defines if the material uses height smith correlated visibility term.
  49406. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49407. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49408. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49409. * Not relying on height correlated will also disable energy conservation.
  49410. */
  49411. useSmithVisibilityHeightCorrelated: boolean;
  49412. private _useSphericalHarmonics;
  49413. /**
  49414. * LEGACY Mode set to false
  49415. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49416. * diffuse part of the IBL.
  49417. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49418. * to the ground truth.
  49419. */
  49420. useSphericalHarmonics: boolean;
  49421. private _useSpecularGlossinessInputEnergyConservation;
  49422. /**
  49423. * Defines if the material uses energy conservation, when the specular workflow is active.
  49424. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49425. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49426. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49427. */
  49428. useSpecularGlossinessInputEnergyConservation: boolean;
  49429. /** @hidden */
  49430. private _internalMarkAllSubMeshesAsMiscDirty;
  49431. /** @hidden */
  49432. _markAllSubMeshesAsMiscDirty(): void;
  49433. /**
  49434. * Instantiate a new istance of clear coat configuration.
  49435. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49436. */
  49437. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49438. /**
  49439. * Checks to see if a texture is used in the material.
  49440. * @param defines the list of "defines" to update.
  49441. */
  49442. prepareDefines(defines: IMaterialBRDFDefines): void;
  49443. /**
  49444. * Get the current class name of the texture useful for serialization or dynamic coding.
  49445. * @returns "PBRClearCoatConfiguration"
  49446. */
  49447. getClassName(): string;
  49448. /**
  49449. * Makes a duplicate of the current configuration into another one.
  49450. * @param brdfConfiguration define the config where to copy the info
  49451. */
  49452. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49453. /**
  49454. * Serializes this BRDF configuration.
  49455. * @returns - An object with the serialized config.
  49456. */
  49457. serialize(): any;
  49458. /**
  49459. * Parses a anisotropy Configuration from a serialized object.
  49460. * @param source - Serialized object.
  49461. * @param scene Defines the scene we are parsing for
  49462. * @param rootUrl Defines the rootUrl to load from
  49463. */
  49464. parse(source: any, scene: Scene, rootUrl: string): void;
  49465. }
  49466. }
  49467. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49468. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49469. import { Color3 } from "babylonjs/Maths/math.color";
  49470. import { Scene } from "babylonjs/scene";
  49471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49472. import { Nullable } from "babylonjs/types";
  49473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49474. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49475. /**
  49476. * @hidden
  49477. */
  49478. export interface IMaterialSheenDefines {
  49479. SHEEN: boolean;
  49480. SHEEN_TEXTURE: boolean;
  49481. SHEEN_TEXTUREDIRECTUV: number;
  49482. SHEEN_LINKWITHALBEDO: boolean;
  49483. /** @hidden */
  49484. _areTexturesDirty: boolean;
  49485. }
  49486. /**
  49487. * Define the code related to the Sheen parameters of the pbr material.
  49488. */
  49489. export class PBRSheenConfiguration {
  49490. private _isEnabled;
  49491. /**
  49492. * Defines if the material uses sheen.
  49493. */
  49494. isEnabled: boolean;
  49495. private _linkSheenWithAlbedo;
  49496. /**
  49497. * Defines if the sheen is linked to the sheen color.
  49498. */
  49499. linkSheenWithAlbedo: boolean;
  49500. /**
  49501. * Defines the sheen intensity.
  49502. */
  49503. intensity: number;
  49504. /**
  49505. * Defines the sheen color.
  49506. */
  49507. color: Color3;
  49508. private _texture;
  49509. /**
  49510. * Stores the sheen tint values in a texture.
  49511. * rgb is tint
  49512. * a is a intensity
  49513. */
  49514. texture: Nullable<BaseTexture>;
  49515. /** @hidden */
  49516. private _internalMarkAllSubMeshesAsTexturesDirty;
  49517. /** @hidden */
  49518. _markAllSubMeshesAsTexturesDirty(): void;
  49519. /**
  49520. * Instantiate a new istance of clear coat configuration.
  49521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49522. */
  49523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49524. /**
  49525. * Specifies that the submesh is ready to be used.
  49526. * @param defines the list of "defines" to update.
  49527. * @param scene defines the scene the material belongs to.
  49528. * @returns - boolean indicating that the submesh is ready or not.
  49529. */
  49530. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49531. /**
  49532. * Checks to see if a texture is used in the material.
  49533. * @param defines the list of "defines" to update.
  49534. * @param scene defines the scene the material belongs to.
  49535. */
  49536. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49537. /**
  49538. * Binds the material data.
  49539. * @param uniformBuffer defines the Uniform buffer to fill in.
  49540. * @param scene defines the scene the material belongs to.
  49541. * @param isFrozen defines wether the material is frozen or not.
  49542. */
  49543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49544. /**
  49545. * Checks to see if a texture is used in the material.
  49546. * @param texture - Base texture to use.
  49547. * @returns - Boolean specifying if a texture is used in the material.
  49548. */
  49549. hasTexture(texture: BaseTexture): boolean;
  49550. /**
  49551. * Returns an array of the actively used textures.
  49552. * @param activeTextures Array of BaseTextures
  49553. */
  49554. getActiveTextures(activeTextures: BaseTexture[]): void;
  49555. /**
  49556. * Returns the animatable textures.
  49557. * @param animatables Array of animatable textures.
  49558. */
  49559. getAnimatables(animatables: IAnimatable[]): void;
  49560. /**
  49561. * Disposes the resources of the material.
  49562. * @param forceDisposeTextures - Forces the disposal of all textures.
  49563. */
  49564. dispose(forceDisposeTextures?: boolean): void;
  49565. /**
  49566. * Get the current class name of the texture useful for serialization or dynamic coding.
  49567. * @returns "PBRSheenConfiguration"
  49568. */
  49569. getClassName(): string;
  49570. /**
  49571. * Add fallbacks to the effect fallbacks list.
  49572. * @param defines defines the Base texture to use.
  49573. * @param fallbacks defines the current fallback list.
  49574. * @param currentRank defines the current fallback rank.
  49575. * @returns the new fallback rank.
  49576. */
  49577. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49578. /**
  49579. * Add the required uniforms to the current list.
  49580. * @param uniforms defines the current uniform list.
  49581. */
  49582. static AddUniforms(uniforms: string[]): void;
  49583. /**
  49584. * Add the required uniforms to the current buffer.
  49585. * @param uniformBuffer defines the current uniform buffer.
  49586. */
  49587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49588. /**
  49589. * Add the required samplers to the current list.
  49590. * @param samplers defines the current sampler list.
  49591. */
  49592. static AddSamplers(samplers: string[]): void;
  49593. /**
  49594. * Makes a duplicate of the current configuration into another one.
  49595. * @param sheenConfiguration define the config where to copy the info
  49596. */
  49597. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49598. /**
  49599. * Serializes this BRDF configuration.
  49600. * @returns - An object with the serialized config.
  49601. */
  49602. serialize(): any;
  49603. /**
  49604. * Parses a anisotropy Configuration from a serialized object.
  49605. * @param source - Serialized object.
  49606. * @param scene Defines the scene we are parsing for
  49607. * @param rootUrl Defines the rootUrl to load from
  49608. */
  49609. parse(source: any, scene: Scene, rootUrl: string): void;
  49610. }
  49611. }
  49612. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49613. import { Nullable } from "babylonjs/types";
  49614. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49615. import { Color3 } from "babylonjs/Maths/math.color";
  49616. import { SmartArray } from "babylonjs/Misc/smartArray";
  49617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49619. import { Effect } from "babylonjs/Materials/effect";
  49620. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49621. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49622. import { Engine } from "babylonjs/Engines/engine";
  49623. import { Scene } from "babylonjs/scene";
  49624. /**
  49625. * @hidden
  49626. */
  49627. export interface IMaterialSubSurfaceDefines {
  49628. SUBSURFACE: boolean;
  49629. SS_REFRACTION: boolean;
  49630. SS_TRANSLUCENCY: boolean;
  49631. SS_SCATERRING: boolean;
  49632. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49633. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49634. SS_REFRACTIONMAP_3D: boolean;
  49635. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49636. SS_LODINREFRACTIONALPHA: boolean;
  49637. SS_GAMMAREFRACTION: boolean;
  49638. SS_RGBDREFRACTION: boolean;
  49639. SS_LINEARSPECULARREFRACTION: boolean;
  49640. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49641. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49642. /** @hidden */
  49643. _areTexturesDirty: boolean;
  49644. }
  49645. /**
  49646. * Define the code related to the sub surface parameters of the pbr material.
  49647. */
  49648. export class PBRSubSurfaceConfiguration {
  49649. private _isRefractionEnabled;
  49650. /**
  49651. * Defines if the refraction is enabled in the material.
  49652. */
  49653. isRefractionEnabled: boolean;
  49654. private _isTranslucencyEnabled;
  49655. /**
  49656. * Defines if the translucency is enabled in the material.
  49657. */
  49658. isTranslucencyEnabled: boolean;
  49659. private _isScatteringEnabled;
  49660. /**
  49661. * Defines the refraction intensity of the material.
  49662. * The refraction when enabled replaces the Diffuse part of the material.
  49663. * The intensity helps transitionning between diffuse and refraction.
  49664. */
  49665. refractionIntensity: number;
  49666. /**
  49667. * Defines the translucency intensity of the material.
  49668. * When translucency has been enabled, this defines how much of the "translucency"
  49669. * is addded to the diffuse part of the material.
  49670. */
  49671. translucencyIntensity: number;
  49672. /**
  49673. * Defines the scattering intensity of the material.
  49674. * When scattering has been enabled, this defines how much of the "scattered light"
  49675. * is addded to the diffuse part of the material.
  49676. */
  49677. scatteringIntensity: number;
  49678. private _thicknessTexture;
  49679. /**
  49680. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49681. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49682. * 0 would mean minimumThickness
  49683. * 1 would mean maximumThickness
  49684. * The other channels might be use as a mask to vary the different effects intensity.
  49685. */
  49686. thicknessTexture: Nullable<BaseTexture>;
  49687. private _refractionTexture;
  49688. /**
  49689. * Defines the texture to use for refraction.
  49690. */
  49691. refractionTexture: Nullable<BaseTexture>;
  49692. private _indexOfRefraction;
  49693. /**
  49694. * Defines the index of refraction used in the material.
  49695. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49696. */
  49697. indexOfRefraction: number;
  49698. private _invertRefractionY;
  49699. /**
  49700. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49701. */
  49702. invertRefractionY: boolean;
  49703. private _linkRefractionWithTransparency;
  49704. /**
  49705. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49706. * Materials half opaque for instance using refraction could benefit from this control.
  49707. */
  49708. linkRefractionWithTransparency: boolean;
  49709. /**
  49710. * Defines the minimum thickness stored in the thickness map.
  49711. * If no thickness map is defined, this value will be used to simulate thickness.
  49712. */
  49713. minimumThickness: number;
  49714. /**
  49715. * Defines the maximum thickness stored in the thickness map.
  49716. */
  49717. maximumThickness: number;
  49718. /**
  49719. * Defines the volume tint of the material.
  49720. * This is used for both translucency and scattering.
  49721. */
  49722. tintColor: Color3;
  49723. /**
  49724. * Defines the distance at which the tint color should be found in the media.
  49725. * This is used for refraction only.
  49726. */
  49727. tintColorAtDistance: number;
  49728. /**
  49729. * Defines how far each channel transmit through the media.
  49730. * It is defined as a color to simplify it selection.
  49731. */
  49732. diffusionDistance: Color3;
  49733. private _useMaskFromThicknessTexture;
  49734. /**
  49735. * Stores the intensity of the different subsurface effects in the thickness texture.
  49736. * * the green channel is the translucency intensity.
  49737. * * the blue channel is the scattering intensity.
  49738. * * the alpha channel is the refraction intensity.
  49739. */
  49740. useMaskFromThicknessTexture: boolean;
  49741. /** @hidden */
  49742. private _internalMarkAllSubMeshesAsTexturesDirty;
  49743. /** @hidden */
  49744. _markAllSubMeshesAsTexturesDirty(): void;
  49745. /**
  49746. * Instantiate a new istance of sub surface configuration.
  49747. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49748. */
  49749. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49750. /**
  49751. * Gets wehter the submesh is ready to be used or not.
  49752. * @param defines the list of "defines" to update.
  49753. * @param scene defines the scene the material belongs to.
  49754. * @returns - boolean indicating that the submesh is ready or not.
  49755. */
  49756. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49757. /**
  49758. * Checks to see if a texture is used in the material.
  49759. * @param defines the list of "defines" to update.
  49760. * @param scene defines the scene to the material belongs to.
  49761. */
  49762. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49763. /**
  49764. * Binds the material data.
  49765. * @param uniformBuffer defines the Uniform buffer to fill in.
  49766. * @param scene defines the scene the material belongs to.
  49767. * @param engine defines the engine the material belongs to.
  49768. * @param isFrozen defines wether the material is frozen or not.
  49769. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49770. */
  49771. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49772. /**
  49773. * Unbinds the material from the mesh.
  49774. * @param activeEffect defines the effect that should be unbound from.
  49775. * @returns true if unbound, otherwise false
  49776. */
  49777. unbind(activeEffect: Effect): boolean;
  49778. /**
  49779. * Returns the texture used for refraction or null if none is used.
  49780. * @param scene defines the scene the material belongs to.
  49781. * @returns - Refraction texture if present. If no refraction texture and refraction
  49782. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49783. */
  49784. private _getRefractionTexture;
  49785. /**
  49786. * Returns true if alpha blending should be disabled.
  49787. */
  49788. readonly disableAlphaBlending: boolean;
  49789. /**
  49790. * Fills the list of render target textures.
  49791. * @param renderTargets the list of render targets to update
  49792. */
  49793. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49794. /**
  49795. * Checks to see if a texture is used in the material.
  49796. * @param texture - Base texture to use.
  49797. * @returns - Boolean specifying if a texture is used in the material.
  49798. */
  49799. hasTexture(texture: BaseTexture): boolean;
  49800. /**
  49801. * Gets a boolean indicating that current material needs to register RTT
  49802. * @returns true if this uses a render target otherwise false.
  49803. */
  49804. hasRenderTargetTextures(): boolean;
  49805. /**
  49806. * Returns an array of the actively used textures.
  49807. * @param activeTextures Array of BaseTextures
  49808. */
  49809. getActiveTextures(activeTextures: BaseTexture[]): void;
  49810. /**
  49811. * Returns the animatable textures.
  49812. * @param animatables Array of animatable textures.
  49813. */
  49814. getAnimatables(animatables: IAnimatable[]): void;
  49815. /**
  49816. * Disposes the resources of the material.
  49817. * @param forceDisposeTextures - Forces the disposal of all textures.
  49818. */
  49819. dispose(forceDisposeTextures?: boolean): void;
  49820. /**
  49821. * Get the current class name of the texture useful for serialization or dynamic coding.
  49822. * @returns "PBRSubSurfaceConfiguration"
  49823. */
  49824. getClassName(): string;
  49825. /**
  49826. * Add fallbacks to the effect fallbacks list.
  49827. * @param defines defines the Base texture to use.
  49828. * @param fallbacks defines the current fallback list.
  49829. * @param currentRank defines the current fallback rank.
  49830. * @returns the new fallback rank.
  49831. */
  49832. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49833. /**
  49834. * Add the required uniforms to the current list.
  49835. * @param uniforms defines the current uniform list.
  49836. */
  49837. static AddUniforms(uniforms: string[]): void;
  49838. /**
  49839. * Add the required samplers to the current list.
  49840. * @param samplers defines the current sampler list.
  49841. */
  49842. static AddSamplers(samplers: string[]): void;
  49843. /**
  49844. * Add the required uniforms to the current buffer.
  49845. * @param uniformBuffer defines the current uniform buffer.
  49846. */
  49847. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49848. /**
  49849. * Makes a duplicate of the current configuration into another one.
  49850. * @param configuration define the config where to copy the info
  49851. */
  49852. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49853. /**
  49854. * Serializes this Sub Surface configuration.
  49855. * @returns - An object with the serialized config.
  49856. */
  49857. serialize(): any;
  49858. /**
  49859. * Parses a anisotropy Configuration from a serialized object.
  49860. * @param source - Serialized object.
  49861. * @param scene Defines the scene we are parsing for
  49862. * @param rootUrl Defines the rootUrl to load from
  49863. */
  49864. parse(source: any, scene: Scene, rootUrl: string): void;
  49865. }
  49866. }
  49867. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49868. /** @hidden */
  49869. export var pbrFragmentDeclaration: {
  49870. name: string;
  49871. shader: string;
  49872. };
  49873. }
  49874. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49875. /** @hidden */
  49876. export var pbrUboDeclaration: {
  49877. name: string;
  49878. shader: string;
  49879. };
  49880. }
  49881. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49882. /** @hidden */
  49883. export var pbrFragmentExtraDeclaration: {
  49884. name: string;
  49885. shader: string;
  49886. };
  49887. }
  49888. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49889. /** @hidden */
  49890. export var pbrFragmentSamplersDeclaration: {
  49891. name: string;
  49892. shader: string;
  49893. };
  49894. }
  49895. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49896. /** @hidden */
  49897. export var pbrHelperFunctions: {
  49898. name: string;
  49899. shader: string;
  49900. };
  49901. }
  49902. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49903. /** @hidden */
  49904. export var harmonicsFunctions: {
  49905. name: string;
  49906. shader: string;
  49907. };
  49908. }
  49909. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49910. /** @hidden */
  49911. export var pbrDirectLightingSetupFunctions: {
  49912. name: string;
  49913. shader: string;
  49914. };
  49915. }
  49916. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49917. /** @hidden */
  49918. export var pbrDirectLightingFalloffFunctions: {
  49919. name: string;
  49920. shader: string;
  49921. };
  49922. }
  49923. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49924. /** @hidden */
  49925. export var pbrBRDFFunctions: {
  49926. name: string;
  49927. shader: string;
  49928. };
  49929. }
  49930. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49931. /** @hidden */
  49932. export var pbrDirectLightingFunctions: {
  49933. name: string;
  49934. shader: string;
  49935. };
  49936. }
  49937. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49938. /** @hidden */
  49939. export var pbrIBLFunctions: {
  49940. name: string;
  49941. shader: string;
  49942. };
  49943. }
  49944. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49945. /** @hidden */
  49946. export var pbrDebug: {
  49947. name: string;
  49948. shader: string;
  49949. };
  49950. }
  49951. declare module "babylonjs/Shaders/pbr.fragment" {
  49952. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49953. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49954. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49955. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49956. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49957. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49958. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49959. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49960. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49961. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49962. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49963. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49964. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49965. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49966. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49967. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49968. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49969. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49970. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49971. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49972. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49973. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49974. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49975. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49976. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49977. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49978. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49979. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49980. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49981. /** @hidden */
  49982. export var pbrPixelShader: {
  49983. name: string;
  49984. shader: string;
  49985. };
  49986. }
  49987. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49988. /** @hidden */
  49989. export var pbrVertexDeclaration: {
  49990. name: string;
  49991. shader: string;
  49992. };
  49993. }
  49994. declare module "babylonjs/Shaders/pbr.vertex" {
  49995. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49996. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49998. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49999. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50000. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50001. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50002. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50003. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50004. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50005. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50008. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50009. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50010. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50011. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50012. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50013. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50014. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50015. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50016. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50017. /** @hidden */
  50018. export var pbrVertexShader: {
  50019. name: string;
  50020. shader: string;
  50021. };
  50022. }
  50023. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50024. import { Nullable } from "babylonjs/types";
  50025. import { Scene } from "babylonjs/scene";
  50026. import { Matrix } from "babylonjs/Maths/math.vector";
  50027. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50029. import { Mesh } from "babylonjs/Meshes/mesh";
  50030. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50031. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50032. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50033. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50034. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50035. import { Color3 } from "babylonjs/Maths/math.color";
  50036. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50037. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50038. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50039. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50041. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50042. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50043. import "babylonjs/Shaders/pbr.fragment";
  50044. import "babylonjs/Shaders/pbr.vertex";
  50045. /**
  50046. * Manages the defines for the PBR Material.
  50047. * @hidden
  50048. */
  50049. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50050. PBR: boolean;
  50051. MAINUV1: boolean;
  50052. MAINUV2: boolean;
  50053. UV1: boolean;
  50054. UV2: boolean;
  50055. ALBEDO: boolean;
  50056. ALBEDODIRECTUV: number;
  50057. VERTEXCOLOR: boolean;
  50058. AMBIENT: boolean;
  50059. AMBIENTDIRECTUV: number;
  50060. AMBIENTINGRAYSCALE: boolean;
  50061. OPACITY: boolean;
  50062. VERTEXALPHA: boolean;
  50063. OPACITYDIRECTUV: number;
  50064. OPACITYRGB: boolean;
  50065. ALPHATEST: boolean;
  50066. DEPTHPREPASS: boolean;
  50067. ALPHABLEND: boolean;
  50068. ALPHAFROMALBEDO: boolean;
  50069. ALPHATESTVALUE: string;
  50070. SPECULAROVERALPHA: boolean;
  50071. RADIANCEOVERALPHA: boolean;
  50072. ALPHAFRESNEL: boolean;
  50073. LINEARALPHAFRESNEL: boolean;
  50074. PREMULTIPLYALPHA: boolean;
  50075. EMISSIVE: boolean;
  50076. EMISSIVEDIRECTUV: number;
  50077. REFLECTIVITY: boolean;
  50078. REFLECTIVITYDIRECTUV: number;
  50079. SPECULARTERM: boolean;
  50080. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50081. MICROSURFACEAUTOMATIC: boolean;
  50082. LODBASEDMICROSFURACE: boolean;
  50083. MICROSURFACEMAP: boolean;
  50084. MICROSURFACEMAPDIRECTUV: number;
  50085. METALLICWORKFLOW: boolean;
  50086. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50087. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50088. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50089. AOSTOREINMETALMAPRED: boolean;
  50090. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50091. ENVIRONMENTBRDF: boolean;
  50092. ENVIRONMENTBRDF_RGBD: boolean;
  50093. NORMAL: boolean;
  50094. TANGENT: boolean;
  50095. BUMP: boolean;
  50096. BUMPDIRECTUV: number;
  50097. OBJECTSPACE_NORMALMAP: boolean;
  50098. PARALLAX: boolean;
  50099. PARALLAXOCCLUSION: boolean;
  50100. NORMALXYSCALE: boolean;
  50101. LIGHTMAP: boolean;
  50102. LIGHTMAPDIRECTUV: number;
  50103. USELIGHTMAPASSHADOWMAP: boolean;
  50104. GAMMALIGHTMAP: boolean;
  50105. RGBDLIGHTMAP: boolean;
  50106. REFLECTION: boolean;
  50107. REFLECTIONMAP_3D: boolean;
  50108. REFLECTIONMAP_SPHERICAL: boolean;
  50109. REFLECTIONMAP_PLANAR: boolean;
  50110. REFLECTIONMAP_CUBIC: boolean;
  50111. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50112. REFLECTIONMAP_PROJECTION: boolean;
  50113. REFLECTIONMAP_SKYBOX: boolean;
  50114. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50115. REFLECTIONMAP_EXPLICIT: boolean;
  50116. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50117. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50118. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50119. INVERTCUBICMAP: boolean;
  50120. USESPHERICALFROMREFLECTIONMAP: boolean;
  50121. USEIRRADIANCEMAP: boolean;
  50122. SPHERICAL_HARMONICS: boolean;
  50123. USESPHERICALINVERTEX: boolean;
  50124. REFLECTIONMAP_OPPOSITEZ: boolean;
  50125. LODINREFLECTIONALPHA: boolean;
  50126. GAMMAREFLECTION: boolean;
  50127. RGBDREFLECTION: boolean;
  50128. LINEARSPECULARREFLECTION: boolean;
  50129. RADIANCEOCCLUSION: boolean;
  50130. HORIZONOCCLUSION: boolean;
  50131. INSTANCES: boolean;
  50132. NUM_BONE_INFLUENCERS: number;
  50133. BonesPerMesh: number;
  50134. BONETEXTURE: boolean;
  50135. NONUNIFORMSCALING: boolean;
  50136. MORPHTARGETS: boolean;
  50137. MORPHTARGETS_NORMAL: boolean;
  50138. MORPHTARGETS_TANGENT: boolean;
  50139. MORPHTARGETS_UV: boolean;
  50140. NUM_MORPH_INFLUENCERS: number;
  50141. IMAGEPROCESSING: boolean;
  50142. VIGNETTE: boolean;
  50143. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50144. VIGNETTEBLENDMODEOPAQUE: boolean;
  50145. TONEMAPPING: boolean;
  50146. TONEMAPPING_ACES: boolean;
  50147. CONTRAST: boolean;
  50148. COLORCURVES: boolean;
  50149. COLORGRADING: boolean;
  50150. COLORGRADING3D: boolean;
  50151. SAMPLER3DGREENDEPTH: boolean;
  50152. SAMPLER3DBGRMAP: boolean;
  50153. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50154. EXPOSURE: boolean;
  50155. MULTIVIEW: boolean;
  50156. USEPHYSICALLIGHTFALLOFF: boolean;
  50157. USEGLTFLIGHTFALLOFF: boolean;
  50158. TWOSIDEDLIGHTING: boolean;
  50159. SHADOWFLOAT: boolean;
  50160. CLIPPLANE: boolean;
  50161. CLIPPLANE2: boolean;
  50162. CLIPPLANE3: boolean;
  50163. CLIPPLANE4: boolean;
  50164. POINTSIZE: boolean;
  50165. FOG: boolean;
  50166. LOGARITHMICDEPTH: boolean;
  50167. FORCENORMALFORWARD: boolean;
  50168. SPECULARAA: boolean;
  50169. CLEARCOAT: boolean;
  50170. CLEARCOAT_DEFAULTIOR: boolean;
  50171. CLEARCOAT_TEXTURE: boolean;
  50172. CLEARCOAT_TEXTUREDIRECTUV: number;
  50173. CLEARCOAT_BUMP: boolean;
  50174. CLEARCOAT_BUMPDIRECTUV: number;
  50175. CLEARCOAT_TINT: boolean;
  50176. CLEARCOAT_TINT_TEXTURE: boolean;
  50177. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50178. ANISOTROPIC: boolean;
  50179. ANISOTROPIC_TEXTURE: boolean;
  50180. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50181. BRDF_V_HEIGHT_CORRELATED: boolean;
  50182. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50183. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50184. SHEEN: boolean;
  50185. SHEEN_TEXTURE: boolean;
  50186. SHEEN_TEXTUREDIRECTUV: number;
  50187. SHEEN_LINKWITHALBEDO: boolean;
  50188. SUBSURFACE: boolean;
  50189. SS_REFRACTION: boolean;
  50190. SS_TRANSLUCENCY: boolean;
  50191. SS_SCATERRING: boolean;
  50192. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50193. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50194. SS_REFRACTIONMAP_3D: boolean;
  50195. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50196. SS_LODINREFRACTIONALPHA: boolean;
  50197. SS_GAMMAREFRACTION: boolean;
  50198. SS_RGBDREFRACTION: boolean;
  50199. SS_LINEARSPECULARREFRACTION: boolean;
  50200. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50201. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50202. UNLIT: boolean;
  50203. DEBUGMODE: number;
  50204. /**
  50205. * Initializes the PBR Material defines.
  50206. */
  50207. constructor();
  50208. /**
  50209. * Resets the PBR Material defines.
  50210. */
  50211. reset(): void;
  50212. }
  50213. /**
  50214. * The Physically based material base class of BJS.
  50215. *
  50216. * This offers the main features of a standard PBR material.
  50217. * For more information, please refer to the documentation :
  50218. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50219. */
  50220. export abstract class PBRBaseMaterial extends PushMaterial {
  50221. /**
  50222. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50223. */
  50224. static readonly PBRMATERIAL_OPAQUE: number;
  50225. /**
  50226. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50227. */
  50228. static readonly PBRMATERIAL_ALPHATEST: number;
  50229. /**
  50230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50231. */
  50232. static readonly PBRMATERIAL_ALPHABLEND: number;
  50233. /**
  50234. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50235. * They are also discarded below the alpha cutoff threshold to improve performances.
  50236. */
  50237. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50238. /**
  50239. * Defines the default value of how much AO map is occluding the analytical lights
  50240. * (point spot...).
  50241. */
  50242. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50243. /**
  50244. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50245. */
  50246. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50247. /**
  50248. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50249. * to enhance interoperability with other engines.
  50250. */
  50251. static readonly LIGHTFALLOFF_GLTF: number;
  50252. /**
  50253. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50254. * to enhance interoperability with other materials.
  50255. */
  50256. static readonly LIGHTFALLOFF_STANDARD: number;
  50257. /**
  50258. * Intensity of the direct lights e.g. the four lights available in your scene.
  50259. * This impacts both the direct diffuse and specular highlights.
  50260. */
  50261. protected _directIntensity: number;
  50262. /**
  50263. * Intensity of the emissive part of the material.
  50264. * This helps controlling the emissive effect without modifying the emissive color.
  50265. */
  50266. protected _emissiveIntensity: number;
  50267. /**
  50268. * Intensity of the environment e.g. how much the environment will light the object
  50269. * either through harmonics for rough material or through the refelction for shiny ones.
  50270. */
  50271. protected _environmentIntensity: number;
  50272. /**
  50273. * This is a special control allowing the reduction of the specular highlights coming from the
  50274. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50275. */
  50276. protected _specularIntensity: number;
  50277. /**
  50278. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50279. */
  50280. private _lightingInfos;
  50281. /**
  50282. * Debug Control allowing disabling the bump map on this material.
  50283. */
  50284. protected _disableBumpMap: boolean;
  50285. /**
  50286. * AKA Diffuse Texture in standard nomenclature.
  50287. */
  50288. protected _albedoTexture: Nullable<BaseTexture>;
  50289. /**
  50290. * AKA Occlusion Texture in other nomenclature.
  50291. */
  50292. protected _ambientTexture: Nullable<BaseTexture>;
  50293. /**
  50294. * AKA Occlusion Texture Intensity in other nomenclature.
  50295. */
  50296. protected _ambientTextureStrength: number;
  50297. /**
  50298. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50299. * 1 means it completely occludes it
  50300. * 0 mean it has no impact
  50301. */
  50302. protected _ambientTextureImpactOnAnalyticalLights: number;
  50303. /**
  50304. * Stores the alpha values in a texture.
  50305. */
  50306. protected _opacityTexture: Nullable<BaseTexture>;
  50307. /**
  50308. * Stores the reflection values in a texture.
  50309. */
  50310. protected _reflectionTexture: Nullable<BaseTexture>;
  50311. /**
  50312. * Stores the emissive values in a texture.
  50313. */
  50314. protected _emissiveTexture: Nullable<BaseTexture>;
  50315. /**
  50316. * AKA Specular texture in other nomenclature.
  50317. */
  50318. protected _reflectivityTexture: Nullable<BaseTexture>;
  50319. /**
  50320. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50321. */
  50322. protected _metallicTexture: Nullable<BaseTexture>;
  50323. /**
  50324. * Specifies the metallic scalar of the metallic/roughness workflow.
  50325. * Can also be used to scale the metalness values of the metallic texture.
  50326. */
  50327. protected _metallic: Nullable<number>;
  50328. /**
  50329. * Specifies the roughness scalar of the metallic/roughness workflow.
  50330. * Can also be used to scale the roughness values of the metallic texture.
  50331. */
  50332. protected _roughness: Nullable<number>;
  50333. /**
  50334. * Specifies the an F0 factor to help configuring the material F0.
  50335. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50336. * to 0.5 the previously hard coded value stays the same.
  50337. * Can also be used to scale the F0 values of the metallic texture.
  50338. */
  50339. protected _metallicF0Factor: number;
  50340. /**
  50341. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50342. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50343. * your expectation as it multiplies with the texture data.
  50344. */
  50345. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50346. /**
  50347. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50348. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50349. */
  50350. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50351. /**
  50352. * Stores surface normal data used to displace a mesh in a texture.
  50353. */
  50354. protected _bumpTexture: Nullable<BaseTexture>;
  50355. /**
  50356. * Stores the pre-calculated light information of a mesh in a texture.
  50357. */
  50358. protected _lightmapTexture: Nullable<BaseTexture>;
  50359. /**
  50360. * The color of a material in ambient lighting.
  50361. */
  50362. protected _ambientColor: Color3;
  50363. /**
  50364. * AKA Diffuse Color in other nomenclature.
  50365. */
  50366. protected _albedoColor: Color3;
  50367. /**
  50368. * AKA Specular Color in other nomenclature.
  50369. */
  50370. protected _reflectivityColor: Color3;
  50371. /**
  50372. * The color applied when light is reflected from a material.
  50373. */
  50374. protected _reflectionColor: Color3;
  50375. /**
  50376. * The color applied when light is emitted from a material.
  50377. */
  50378. protected _emissiveColor: Color3;
  50379. /**
  50380. * AKA Glossiness in other nomenclature.
  50381. */
  50382. protected _microSurface: number;
  50383. /**
  50384. * Specifies that the material will use the light map as a show map.
  50385. */
  50386. protected _useLightmapAsShadowmap: boolean;
  50387. /**
  50388. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50389. * makes the reflect vector face the model (under horizon).
  50390. */
  50391. protected _useHorizonOcclusion: boolean;
  50392. /**
  50393. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50394. * too much the area relying on ambient texture to define their ambient occlusion.
  50395. */
  50396. protected _useRadianceOcclusion: boolean;
  50397. /**
  50398. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50399. */
  50400. protected _useAlphaFromAlbedoTexture: boolean;
  50401. /**
  50402. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50403. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50404. */
  50405. protected _useSpecularOverAlpha: boolean;
  50406. /**
  50407. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50408. */
  50409. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50410. /**
  50411. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50412. */
  50413. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50414. /**
  50415. * Specifies if the metallic texture contains the roughness information in its green channel.
  50416. */
  50417. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50418. /**
  50419. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50420. */
  50421. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50422. /**
  50423. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50424. */
  50425. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50426. /**
  50427. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50428. */
  50429. protected _useAmbientInGrayScale: boolean;
  50430. /**
  50431. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50432. * The material will try to infer what glossiness each pixel should be.
  50433. */
  50434. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50435. /**
  50436. * Defines the falloff type used in this material.
  50437. * It by default is Physical.
  50438. */
  50439. protected _lightFalloff: number;
  50440. /**
  50441. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50442. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50443. */
  50444. protected _useRadianceOverAlpha: boolean;
  50445. /**
  50446. * Allows using an object space normal map (instead of tangent space).
  50447. */
  50448. protected _useObjectSpaceNormalMap: boolean;
  50449. /**
  50450. * Allows using the bump map in parallax mode.
  50451. */
  50452. protected _useParallax: boolean;
  50453. /**
  50454. * Allows using the bump map in parallax occlusion mode.
  50455. */
  50456. protected _useParallaxOcclusion: boolean;
  50457. /**
  50458. * Controls the scale bias of the parallax mode.
  50459. */
  50460. protected _parallaxScaleBias: number;
  50461. /**
  50462. * If sets to true, disables all the lights affecting the material.
  50463. */
  50464. protected _disableLighting: boolean;
  50465. /**
  50466. * Number of Simultaneous lights allowed on the material.
  50467. */
  50468. protected _maxSimultaneousLights: number;
  50469. /**
  50470. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50471. */
  50472. protected _invertNormalMapX: boolean;
  50473. /**
  50474. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50475. */
  50476. protected _invertNormalMapY: boolean;
  50477. /**
  50478. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50479. */
  50480. protected _twoSidedLighting: boolean;
  50481. /**
  50482. * Defines the alpha limits in alpha test mode.
  50483. */
  50484. protected _alphaCutOff: number;
  50485. /**
  50486. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50487. */
  50488. protected _forceAlphaTest: boolean;
  50489. /**
  50490. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50491. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50492. */
  50493. protected _useAlphaFresnel: boolean;
  50494. /**
  50495. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50496. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50497. */
  50498. protected _useLinearAlphaFresnel: boolean;
  50499. /**
  50500. * The transparency mode of the material.
  50501. */
  50502. protected _transparencyMode: Nullable<number>;
  50503. /**
  50504. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50505. * from cos thetav and roughness:
  50506. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50507. */
  50508. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50509. /**
  50510. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50511. */
  50512. protected _forceIrradianceInFragment: boolean;
  50513. /**
  50514. * Force normal to face away from face.
  50515. */
  50516. protected _forceNormalForward: boolean;
  50517. /**
  50518. * Enables specular anti aliasing in the PBR shader.
  50519. * It will both interacts on the Geometry for analytical and IBL lighting.
  50520. * It also prefilter the roughness map based on the bump values.
  50521. */
  50522. protected _enableSpecularAntiAliasing: boolean;
  50523. /**
  50524. * Default configuration related to image processing available in the PBR Material.
  50525. */
  50526. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50527. /**
  50528. * Keep track of the image processing observer to allow dispose and replace.
  50529. */
  50530. private _imageProcessingObserver;
  50531. /**
  50532. * Attaches a new image processing configuration to the PBR Material.
  50533. * @param configuration
  50534. */
  50535. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50536. /**
  50537. * Stores the available render targets.
  50538. */
  50539. private _renderTargets;
  50540. /**
  50541. * Sets the global ambient color for the material used in lighting calculations.
  50542. */
  50543. private _globalAmbientColor;
  50544. /**
  50545. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50546. */
  50547. private _useLogarithmicDepth;
  50548. /**
  50549. * If set to true, no lighting calculations will be applied.
  50550. */
  50551. private _unlit;
  50552. private _debugMode;
  50553. /**
  50554. * @hidden
  50555. * This is reserved for the inspector.
  50556. * Defines the material debug mode.
  50557. * It helps seeing only some components of the material while troubleshooting.
  50558. */
  50559. debugMode: number;
  50560. /**
  50561. * @hidden
  50562. * This is reserved for the inspector.
  50563. * Specify from where on screen the debug mode should start.
  50564. * The value goes from -1 (full screen) to 1 (not visible)
  50565. * It helps with side by side comparison against the final render
  50566. * This defaults to -1
  50567. */
  50568. private debugLimit;
  50569. /**
  50570. * @hidden
  50571. * This is reserved for the inspector.
  50572. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50573. * You can use the factor to better multiply the final value.
  50574. */
  50575. private debugFactor;
  50576. /**
  50577. * Defines the clear coat layer parameters for the material.
  50578. */
  50579. readonly clearCoat: PBRClearCoatConfiguration;
  50580. /**
  50581. * Defines the anisotropic parameters for the material.
  50582. */
  50583. readonly anisotropy: PBRAnisotropicConfiguration;
  50584. /**
  50585. * Defines the BRDF parameters for the material.
  50586. */
  50587. readonly brdf: PBRBRDFConfiguration;
  50588. /**
  50589. * Defines the Sheen parameters for the material.
  50590. */
  50591. readonly sheen: PBRSheenConfiguration;
  50592. /**
  50593. * Defines the SubSurface parameters for the material.
  50594. */
  50595. readonly subSurface: PBRSubSurfaceConfiguration;
  50596. /**
  50597. * Custom callback helping to override the default shader used in the material.
  50598. */
  50599. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50600. protected _rebuildInParallel: boolean;
  50601. /**
  50602. * Instantiates a new PBRMaterial instance.
  50603. *
  50604. * @param name The material name
  50605. * @param scene The scene the material will be use in.
  50606. */
  50607. constructor(name: string, scene: Scene);
  50608. /**
  50609. * Gets a boolean indicating that current material needs to register RTT
  50610. */
  50611. readonly hasRenderTargetTextures: boolean;
  50612. /**
  50613. * Gets the name of the material class.
  50614. */
  50615. getClassName(): string;
  50616. /**
  50617. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50618. */
  50619. /**
  50620. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50621. */
  50622. useLogarithmicDepth: boolean;
  50623. /**
  50624. * Gets the current transparency mode.
  50625. */
  50626. /**
  50627. * Sets the transparency mode of the material.
  50628. *
  50629. * | Value | Type | Description |
  50630. * | ----- | ----------------------------------- | ----------- |
  50631. * | 0 | OPAQUE | |
  50632. * | 1 | ALPHATEST | |
  50633. * | 2 | ALPHABLEND | |
  50634. * | 3 | ALPHATESTANDBLEND | |
  50635. *
  50636. */
  50637. transparencyMode: Nullable<number>;
  50638. /**
  50639. * Returns true if alpha blending should be disabled.
  50640. */
  50641. private readonly _disableAlphaBlending;
  50642. /**
  50643. * Specifies whether or not this material should be rendered in alpha blend mode.
  50644. */
  50645. needAlphaBlending(): boolean;
  50646. /**
  50647. * Specifies if the mesh will require alpha blending.
  50648. * @param mesh - BJS mesh.
  50649. */
  50650. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50651. /**
  50652. * Specifies whether or not this material should be rendered in alpha test mode.
  50653. */
  50654. needAlphaTesting(): boolean;
  50655. /**
  50656. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50657. */
  50658. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50659. /**
  50660. * Gets the texture used for the alpha test.
  50661. */
  50662. getAlphaTestTexture(): Nullable<BaseTexture>;
  50663. /**
  50664. * Specifies that the submesh is ready to be used.
  50665. * @param mesh - BJS mesh.
  50666. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50667. * @param useInstances - Specifies that instances should be used.
  50668. * @returns - boolean indicating that the submesh is ready or not.
  50669. */
  50670. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50671. /**
  50672. * Specifies if the material uses metallic roughness workflow.
  50673. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50674. */
  50675. isMetallicWorkflow(): boolean;
  50676. private _prepareEffect;
  50677. private _prepareDefines;
  50678. /**
  50679. * Force shader compilation
  50680. */
  50681. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50682. /**
  50683. * Initializes the uniform buffer layout for the shader.
  50684. */
  50685. buildUniformLayout(): void;
  50686. /**
  50687. * Unbinds the material from the mesh
  50688. */
  50689. unbind(): void;
  50690. /**
  50691. * Binds the submesh data.
  50692. * @param world - The world matrix.
  50693. * @param mesh - The BJS mesh.
  50694. * @param subMesh - A submesh of the BJS mesh.
  50695. */
  50696. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50697. /**
  50698. * Returns the animatable textures.
  50699. * @returns - Array of animatable textures.
  50700. */
  50701. getAnimatables(): IAnimatable[];
  50702. /**
  50703. * Returns the texture used for reflections.
  50704. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50705. */
  50706. private _getReflectionTexture;
  50707. /**
  50708. * Returns an array of the actively used textures.
  50709. * @returns - Array of BaseTextures
  50710. */
  50711. getActiveTextures(): BaseTexture[];
  50712. /**
  50713. * Checks to see if a texture is used in the material.
  50714. * @param texture - Base texture to use.
  50715. * @returns - Boolean specifying if a texture is used in the material.
  50716. */
  50717. hasTexture(texture: BaseTexture): boolean;
  50718. /**
  50719. * Disposes the resources of the material.
  50720. * @param forceDisposeEffect - Forces the disposal of effects.
  50721. * @param forceDisposeTextures - Forces the disposal of all textures.
  50722. */
  50723. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50724. }
  50725. }
  50726. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50727. import { Nullable } from "babylonjs/types";
  50728. import { Scene } from "babylonjs/scene";
  50729. import { Color3 } from "babylonjs/Maths/math.color";
  50730. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50731. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50733. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50734. /**
  50735. * The Physically based material of BJS.
  50736. *
  50737. * This offers the main features of a standard PBR material.
  50738. * For more information, please refer to the documentation :
  50739. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50740. */
  50741. export class PBRMaterial extends PBRBaseMaterial {
  50742. /**
  50743. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50744. */
  50745. static readonly PBRMATERIAL_OPAQUE: number;
  50746. /**
  50747. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50748. */
  50749. static readonly PBRMATERIAL_ALPHATEST: number;
  50750. /**
  50751. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50752. */
  50753. static readonly PBRMATERIAL_ALPHABLEND: number;
  50754. /**
  50755. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50756. * They are also discarded below the alpha cutoff threshold to improve performances.
  50757. */
  50758. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50759. /**
  50760. * Defines the default value of how much AO map is occluding the analytical lights
  50761. * (point spot...).
  50762. */
  50763. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50764. /**
  50765. * Intensity of the direct lights e.g. the four lights available in your scene.
  50766. * This impacts both the direct diffuse and specular highlights.
  50767. */
  50768. directIntensity: number;
  50769. /**
  50770. * Intensity of the emissive part of the material.
  50771. * This helps controlling the emissive effect without modifying the emissive color.
  50772. */
  50773. emissiveIntensity: number;
  50774. /**
  50775. * Intensity of the environment e.g. how much the environment will light the object
  50776. * either through harmonics for rough material or through the refelction for shiny ones.
  50777. */
  50778. environmentIntensity: number;
  50779. /**
  50780. * This is a special control allowing the reduction of the specular highlights coming from the
  50781. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50782. */
  50783. specularIntensity: number;
  50784. /**
  50785. * Debug Control allowing disabling the bump map on this material.
  50786. */
  50787. disableBumpMap: boolean;
  50788. /**
  50789. * AKA Diffuse Texture in standard nomenclature.
  50790. */
  50791. albedoTexture: BaseTexture;
  50792. /**
  50793. * AKA Occlusion Texture in other nomenclature.
  50794. */
  50795. ambientTexture: BaseTexture;
  50796. /**
  50797. * AKA Occlusion Texture Intensity in other nomenclature.
  50798. */
  50799. ambientTextureStrength: number;
  50800. /**
  50801. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50802. * 1 means it completely occludes it
  50803. * 0 mean it has no impact
  50804. */
  50805. ambientTextureImpactOnAnalyticalLights: number;
  50806. /**
  50807. * Stores the alpha values in a texture.
  50808. */
  50809. opacityTexture: BaseTexture;
  50810. /**
  50811. * Stores the reflection values in a texture.
  50812. */
  50813. reflectionTexture: Nullable<BaseTexture>;
  50814. /**
  50815. * Stores the emissive values in a texture.
  50816. */
  50817. emissiveTexture: BaseTexture;
  50818. /**
  50819. * AKA Specular texture in other nomenclature.
  50820. */
  50821. reflectivityTexture: BaseTexture;
  50822. /**
  50823. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50824. */
  50825. metallicTexture: BaseTexture;
  50826. /**
  50827. * Specifies the metallic scalar of the metallic/roughness workflow.
  50828. * Can also be used to scale the metalness values of the metallic texture.
  50829. */
  50830. metallic: Nullable<number>;
  50831. /**
  50832. * Specifies the roughness scalar of the metallic/roughness workflow.
  50833. * Can also be used to scale the roughness values of the metallic texture.
  50834. */
  50835. roughness: Nullable<number>;
  50836. /**
  50837. * Specifies the an F0 factor to help configuring the material F0.
  50838. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50839. * to 0.5 the previously hard coded value stays the same.
  50840. * Can also be used to scale the F0 values of the metallic texture.
  50841. */
  50842. metallicF0Factor: number;
  50843. /**
  50844. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50845. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50846. * your expectation as it multiplies with the texture data.
  50847. */
  50848. useMetallicF0FactorFromMetallicTexture: boolean;
  50849. /**
  50850. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50851. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50852. */
  50853. microSurfaceTexture: BaseTexture;
  50854. /**
  50855. * Stores surface normal data used to displace a mesh in a texture.
  50856. */
  50857. bumpTexture: BaseTexture;
  50858. /**
  50859. * Stores the pre-calculated light information of a mesh in a texture.
  50860. */
  50861. lightmapTexture: BaseTexture;
  50862. /**
  50863. * Stores the refracted light information in a texture.
  50864. */
  50865. refractionTexture: Nullable<BaseTexture>;
  50866. /**
  50867. * The color of a material in ambient lighting.
  50868. */
  50869. ambientColor: Color3;
  50870. /**
  50871. * AKA Diffuse Color in other nomenclature.
  50872. */
  50873. albedoColor: Color3;
  50874. /**
  50875. * AKA Specular Color in other nomenclature.
  50876. */
  50877. reflectivityColor: Color3;
  50878. /**
  50879. * The color reflected from the material.
  50880. */
  50881. reflectionColor: Color3;
  50882. /**
  50883. * The color emitted from the material.
  50884. */
  50885. emissiveColor: Color3;
  50886. /**
  50887. * AKA Glossiness in other nomenclature.
  50888. */
  50889. microSurface: number;
  50890. /**
  50891. * source material index of refraction (IOR)' / 'destination material IOR.
  50892. */
  50893. indexOfRefraction: number;
  50894. /**
  50895. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50896. */
  50897. invertRefractionY: boolean;
  50898. /**
  50899. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50900. * Materials half opaque for instance using refraction could benefit from this control.
  50901. */
  50902. linkRefractionWithTransparency: boolean;
  50903. /**
  50904. * If true, the light map contains occlusion information instead of lighting info.
  50905. */
  50906. useLightmapAsShadowmap: boolean;
  50907. /**
  50908. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50909. */
  50910. useAlphaFromAlbedoTexture: boolean;
  50911. /**
  50912. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50913. */
  50914. forceAlphaTest: boolean;
  50915. /**
  50916. * Defines the alpha limits in alpha test mode.
  50917. */
  50918. alphaCutOff: number;
  50919. /**
  50920. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50921. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50922. */
  50923. useSpecularOverAlpha: boolean;
  50924. /**
  50925. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50926. */
  50927. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50928. /**
  50929. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50930. */
  50931. useRoughnessFromMetallicTextureAlpha: boolean;
  50932. /**
  50933. * Specifies if the metallic texture contains the roughness information in its green channel.
  50934. */
  50935. useRoughnessFromMetallicTextureGreen: boolean;
  50936. /**
  50937. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50938. */
  50939. useMetallnessFromMetallicTextureBlue: boolean;
  50940. /**
  50941. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50942. */
  50943. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50944. /**
  50945. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50946. */
  50947. useAmbientInGrayScale: boolean;
  50948. /**
  50949. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50950. * The material will try to infer what glossiness each pixel should be.
  50951. */
  50952. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50953. /**
  50954. * BJS is using an harcoded light falloff based on a manually sets up range.
  50955. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50956. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50957. */
  50958. /**
  50959. * BJS is using an harcoded light falloff based on a manually sets up range.
  50960. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50961. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50962. */
  50963. usePhysicalLightFalloff: boolean;
  50964. /**
  50965. * In order to support the falloff compatibility with gltf, a special mode has been added
  50966. * to reproduce the gltf light falloff.
  50967. */
  50968. /**
  50969. * In order to support the falloff compatibility with gltf, a special mode has been added
  50970. * to reproduce the gltf light falloff.
  50971. */
  50972. useGLTFLightFalloff: boolean;
  50973. /**
  50974. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50975. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50976. */
  50977. useRadianceOverAlpha: boolean;
  50978. /**
  50979. * Allows using an object space normal map (instead of tangent space).
  50980. */
  50981. useObjectSpaceNormalMap: boolean;
  50982. /**
  50983. * Allows using the bump map in parallax mode.
  50984. */
  50985. useParallax: boolean;
  50986. /**
  50987. * Allows using the bump map in parallax occlusion mode.
  50988. */
  50989. useParallaxOcclusion: boolean;
  50990. /**
  50991. * Controls the scale bias of the parallax mode.
  50992. */
  50993. parallaxScaleBias: number;
  50994. /**
  50995. * If sets to true, disables all the lights affecting the material.
  50996. */
  50997. disableLighting: boolean;
  50998. /**
  50999. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51000. */
  51001. forceIrradianceInFragment: boolean;
  51002. /**
  51003. * Number of Simultaneous lights allowed on the material.
  51004. */
  51005. maxSimultaneousLights: number;
  51006. /**
  51007. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51008. */
  51009. invertNormalMapX: boolean;
  51010. /**
  51011. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51012. */
  51013. invertNormalMapY: boolean;
  51014. /**
  51015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51016. */
  51017. twoSidedLighting: boolean;
  51018. /**
  51019. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51020. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51021. */
  51022. useAlphaFresnel: boolean;
  51023. /**
  51024. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51025. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51026. */
  51027. useLinearAlphaFresnel: boolean;
  51028. /**
  51029. * Let user defines the brdf lookup texture used for IBL.
  51030. * A default 8bit version is embedded but you could point at :
  51031. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51032. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51033. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51034. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51035. */
  51036. environmentBRDFTexture: Nullable<BaseTexture>;
  51037. /**
  51038. * Force normal to face away from face.
  51039. */
  51040. forceNormalForward: boolean;
  51041. /**
  51042. * Enables specular anti aliasing in the PBR shader.
  51043. * It will both interacts on the Geometry for analytical and IBL lighting.
  51044. * It also prefilter the roughness map based on the bump values.
  51045. */
  51046. enableSpecularAntiAliasing: boolean;
  51047. /**
  51048. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51049. * makes the reflect vector face the model (under horizon).
  51050. */
  51051. useHorizonOcclusion: boolean;
  51052. /**
  51053. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51054. * too much the area relying on ambient texture to define their ambient occlusion.
  51055. */
  51056. useRadianceOcclusion: boolean;
  51057. /**
  51058. * If set to true, no lighting calculations will be applied.
  51059. */
  51060. unlit: boolean;
  51061. /**
  51062. * Gets the image processing configuration used either in this material.
  51063. */
  51064. /**
  51065. * Sets the Default image processing configuration used either in the this material.
  51066. *
  51067. * If sets to null, the scene one is in use.
  51068. */
  51069. imageProcessingConfiguration: ImageProcessingConfiguration;
  51070. /**
  51071. * Gets wether the color curves effect is enabled.
  51072. */
  51073. /**
  51074. * Sets wether the color curves effect is enabled.
  51075. */
  51076. cameraColorCurvesEnabled: boolean;
  51077. /**
  51078. * Gets wether the color grading effect is enabled.
  51079. */
  51080. /**
  51081. * Gets wether the color grading effect is enabled.
  51082. */
  51083. cameraColorGradingEnabled: boolean;
  51084. /**
  51085. * Gets wether tonemapping is enabled or not.
  51086. */
  51087. /**
  51088. * Sets wether tonemapping is enabled or not
  51089. */
  51090. cameraToneMappingEnabled: boolean;
  51091. /**
  51092. * The camera exposure used on this material.
  51093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51094. * This corresponds to a photographic exposure.
  51095. */
  51096. /**
  51097. * The camera exposure used on this material.
  51098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51099. * This corresponds to a photographic exposure.
  51100. */
  51101. cameraExposure: number;
  51102. /**
  51103. * Gets The camera contrast used on this material.
  51104. */
  51105. /**
  51106. * Sets The camera contrast used on this material.
  51107. */
  51108. cameraContrast: number;
  51109. /**
  51110. * Gets the Color Grading 2D Lookup Texture.
  51111. */
  51112. /**
  51113. * Sets the Color Grading 2D Lookup Texture.
  51114. */
  51115. cameraColorGradingTexture: Nullable<BaseTexture>;
  51116. /**
  51117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51119. * 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;
  51120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51121. */
  51122. /**
  51123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51125. * 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;
  51126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51127. */
  51128. cameraColorCurves: Nullable<ColorCurves>;
  51129. /**
  51130. * Instantiates a new PBRMaterial instance.
  51131. *
  51132. * @param name The material name
  51133. * @param scene The scene the material will be use in.
  51134. */
  51135. constructor(name: string, scene: Scene);
  51136. /**
  51137. * Returns the name of this material class.
  51138. */
  51139. getClassName(): string;
  51140. /**
  51141. * Makes a duplicate of the current material.
  51142. * @param name - name to use for the new material.
  51143. */
  51144. clone(name: string): PBRMaterial;
  51145. /**
  51146. * Serializes this PBR Material.
  51147. * @returns - An object with the serialized material.
  51148. */
  51149. serialize(): any;
  51150. /**
  51151. * Parses a PBR Material from a serialized object.
  51152. * @param source - Serialized object.
  51153. * @param scene - BJS scene instance.
  51154. * @param rootUrl - url for the scene object
  51155. * @returns - PBRMaterial
  51156. */
  51157. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51158. }
  51159. }
  51160. declare module "babylonjs/Misc/dds" {
  51161. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51163. import { Nullable } from "babylonjs/types";
  51164. import { Scene } from "babylonjs/scene";
  51165. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51166. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51167. /**
  51168. * Direct draw surface info
  51169. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51170. */
  51171. export interface DDSInfo {
  51172. /**
  51173. * Width of the texture
  51174. */
  51175. width: number;
  51176. /**
  51177. * Width of the texture
  51178. */
  51179. height: number;
  51180. /**
  51181. * Number of Mipmaps for the texture
  51182. * @see https://en.wikipedia.org/wiki/Mipmap
  51183. */
  51184. mipmapCount: number;
  51185. /**
  51186. * If the textures format is a known fourCC format
  51187. * @see https://www.fourcc.org/
  51188. */
  51189. isFourCC: boolean;
  51190. /**
  51191. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51192. */
  51193. isRGB: boolean;
  51194. /**
  51195. * If the texture is a lumincance format
  51196. */
  51197. isLuminance: boolean;
  51198. /**
  51199. * If this is a cube texture
  51200. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51201. */
  51202. isCube: boolean;
  51203. /**
  51204. * If the texture is a compressed format eg. FOURCC_DXT1
  51205. */
  51206. isCompressed: boolean;
  51207. /**
  51208. * The dxgiFormat of the texture
  51209. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51210. */
  51211. dxgiFormat: number;
  51212. /**
  51213. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51214. */
  51215. textureType: number;
  51216. /**
  51217. * Sphericle polynomial created for the dds texture
  51218. */
  51219. sphericalPolynomial?: SphericalPolynomial;
  51220. }
  51221. /**
  51222. * Class used to provide DDS decompression tools
  51223. */
  51224. export class DDSTools {
  51225. /**
  51226. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51227. */
  51228. static StoreLODInAlphaChannel: boolean;
  51229. /**
  51230. * Gets DDS information from an array buffer
  51231. * @param arrayBuffer defines the array buffer to read data from
  51232. * @returns the DDS information
  51233. */
  51234. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51235. private static _FloatView;
  51236. private static _Int32View;
  51237. private static _ToHalfFloat;
  51238. private static _FromHalfFloat;
  51239. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51240. private static _GetHalfFloatRGBAArrayBuffer;
  51241. private static _GetFloatRGBAArrayBuffer;
  51242. private static _GetFloatAsUIntRGBAArrayBuffer;
  51243. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51244. private static _GetRGBAArrayBuffer;
  51245. private static _ExtractLongWordOrder;
  51246. private static _GetRGBArrayBuffer;
  51247. private static _GetLuminanceArrayBuffer;
  51248. /**
  51249. * Uploads DDS Levels to a Babylon Texture
  51250. * @hidden
  51251. */
  51252. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51253. }
  51254. module "babylonjs/Engines/thinEngine" {
  51255. interface ThinEngine {
  51256. /**
  51257. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51258. * @param rootUrl defines the url where the file to load is located
  51259. * @param scene defines the current scene
  51260. * @param lodScale defines scale to apply to the mip map selection
  51261. * @param lodOffset defines offset to apply to the mip map selection
  51262. * @param onLoad defines an optional callback raised when the texture is loaded
  51263. * @param onError defines an optional callback raised if there is an issue to load the texture
  51264. * @param format defines the format of the data
  51265. * @param forcedExtension defines the extension to use to pick the right loader
  51266. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51267. * @returns the cube texture as an InternalTexture
  51268. */
  51269. 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;
  51270. }
  51271. }
  51272. }
  51273. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51274. import { Nullable } from "babylonjs/types";
  51275. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51276. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51277. /**
  51278. * Implementation of the DDS Texture Loader.
  51279. * @hidden
  51280. */
  51281. export class _DDSTextureLoader implements IInternalTextureLoader {
  51282. /**
  51283. * Defines wether the loader supports cascade loading the different faces.
  51284. */
  51285. readonly supportCascades: boolean;
  51286. /**
  51287. * This returns if the loader support the current file information.
  51288. * @param extension defines the file extension of the file being loaded
  51289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51290. * @param fallback defines the fallback internal texture if any
  51291. * @param isBase64 defines whether the texture is encoded as a base64
  51292. * @param isBuffer defines whether the texture data are stored as a buffer
  51293. * @returns true if the loader can load the specified file
  51294. */
  51295. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51296. /**
  51297. * Transform the url before loading if required.
  51298. * @param rootUrl the url of the texture
  51299. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51300. * @returns the transformed texture
  51301. */
  51302. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51303. /**
  51304. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51305. * @param rootUrl the url of the texture
  51306. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51307. * @returns the fallback texture
  51308. */
  51309. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51310. /**
  51311. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51312. * @param data contains the texture data
  51313. * @param texture defines the BabylonJS internal texture
  51314. * @param createPolynomials will be true if polynomials have been requested
  51315. * @param onLoad defines the callback to trigger once the texture is ready
  51316. * @param onError defines the callback to trigger in case of error
  51317. */
  51318. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51319. /**
  51320. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51321. * @param data contains the texture data
  51322. * @param texture defines the BabylonJS internal texture
  51323. * @param callback defines the method to call once ready to upload
  51324. */
  51325. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51326. }
  51327. }
  51328. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51329. import { Nullable } from "babylonjs/types";
  51330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51331. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51332. /**
  51333. * Implementation of the ENV Texture Loader.
  51334. * @hidden
  51335. */
  51336. export class _ENVTextureLoader implements IInternalTextureLoader {
  51337. /**
  51338. * Defines wether the loader supports cascade loading the different faces.
  51339. */
  51340. readonly supportCascades: boolean;
  51341. /**
  51342. * This returns if the loader support the current file information.
  51343. * @param extension defines the file extension of the file being loaded
  51344. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51345. * @param fallback defines the fallback internal texture if any
  51346. * @param isBase64 defines whether the texture is encoded as a base64
  51347. * @param isBuffer defines whether the texture data are stored as a buffer
  51348. * @returns true if the loader can load the specified file
  51349. */
  51350. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51351. /**
  51352. * Transform the url before loading if required.
  51353. * @param rootUrl the url of the texture
  51354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51355. * @returns the transformed texture
  51356. */
  51357. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51358. /**
  51359. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51360. * @param rootUrl the url of the texture
  51361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51362. * @returns the fallback texture
  51363. */
  51364. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51365. /**
  51366. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51367. * @param data contains the texture data
  51368. * @param texture defines the BabylonJS internal texture
  51369. * @param createPolynomials will be true if polynomials have been requested
  51370. * @param onLoad defines the callback to trigger once the texture is ready
  51371. * @param onError defines the callback to trigger in case of error
  51372. */
  51373. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51374. /**
  51375. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51376. * @param data contains the texture data
  51377. * @param texture defines the BabylonJS internal texture
  51378. * @param callback defines the method to call once ready to upload
  51379. */
  51380. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51381. }
  51382. }
  51383. declare module "babylonjs/Misc/khronosTextureContainer" {
  51384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51385. /**
  51386. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51387. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51388. */
  51389. export class KhronosTextureContainer {
  51390. /** contents of the KTX container file */
  51391. arrayBuffer: any;
  51392. private static HEADER_LEN;
  51393. private static COMPRESSED_2D;
  51394. private static COMPRESSED_3D;
  51395. private static TEX_2D;
  51396. private static TEX_3D;
  51397. /**
  51398. * Gets the openGL type
  51399. */
  51400. glType: number;
  51401. /**
  51402. * Gets the openGL type size
  51403. */
  51404. glTypeSize: number;
  51405. /**
  51406. * Gets the openGL format
  51407. */
  51408. glFormat: number;
  51409. /**
  51410. * Gets the openGL internal format
  51411. */
  51412. glInternalFormat: number;
  51413. /**
  51414. * Gets the base internal format
  51415. */
  51416. glBaseInternalFormat: number;
  51417. /**
  51418. * Gets image width in pixel
  51419. */
  51420. pixelWidth: number;
  51421. /**
  51422. * Gets image height in pixel
  51423. */
  51424. pixelHeight: number;
  51425. /**
  51426. * Gets image depth in pixels
  51427. */
  51428. pixelDepth: number;
  51429. /**
  51430. * Gets the number of array elements
  51431. */
  51432. numberOfArrayElements: number;
  51433. /**
  51434. * Gets the number of faces
  51435. */
  51436. numberOfFaces: number;
  51437. /**
  51438. * Gets the number of mipmap levels
  51439. */
  51440. numberOfMipmapLevels: number;
  51441. /**
  51442. * Gets the bytes of key value data
  51443. */
  51444. bytesOfKeyValueData: number;
  51445. /**
  51446. * Gets the load type
  51447. */
  51448. loadType: number;
  51449. /**
  51450. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51451. */
  51452. isInvalid: boolean;
  51453. /**
  51454. * Creates a new KhronosTextureContainer
  51455. * @param arrayBuffer contents of the KTX container file
  51456. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51457. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51458. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51459. */
  51460. constructor(
  51461. /** contents of the KTX container file */
  51462. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51463. /**
  51464. * Uploads KTX content to a Babylon Texture.
  51465. * It is assumed that the texture has already been created & is currently bound
  51466. * @hidden
  51467. */
  51468. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51469. private _upload2DCompressedLevels;
  51470. }
  51471. }
  51472. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51473. import { Nullable } from "babylonjs/types";
  51474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51475. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51476. /**
  51477. * Implementation of the KTX Texture Loader.
  51478. * @hidden
  51479. */
  51480. export class _KTXTextureLoader implements IInternalTextureLoader {
  51481. /**
  51482. * Defines wether the loader supports cascade loading the different faces.
  51483. */
  51484. readonly supportCascades: boolean;
  51485. /**
  51486. * This returns if the loader support the current file information.
  51487. * @param extension defines the file extension of the file being loaded
  51488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51489. * @param fallback defines the fallback internal texture if any
  51490. * @param isBase64 defines whether the texture is encoded as a base64
  51491. * @param isBuffer defines whether the texture data are stored as a buffer
  51492. * @returns true if the loader can load the specified file
  51493. */
  51494. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51495. /**
  51496. * Transform the url before loading if required.
  51497. * @param rootUrl the url of the texture
  51498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51499. * @returns the transformed texture
  51500. */
  51501. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51502. /**
  51503. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51504. * @param rootUrl the url of the texture
  51505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51506. * @returns the fallback texture
  51507. */
  51508. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51509. /**
  51510. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51511. * @param data contains the texture data
  51512. * @param texture defines the BabylonJS internal texture
  51513. * @param createPolynomials will be true if polynomials have been requested
  51514. * @param onLoad defines the callback to trigger once the texture is ready
  51515. * @param onError defines the callback to trigger in case of error
  51516. */
  51517. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51518. /**
  51519. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51520. * @param data contains the texture data
  51521. * @param texture defines the BabylonJS internal texture
  51522. * @param callback defines the method to call once ready to upload
  51523. */
  51524. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51525. }
  51526. }
  51527. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51528. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51529. import { Scene } from "babylonjs/scene";
  51530. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51531. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51532. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51533. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51534. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51535. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51537. /**
  51538. * Options for the default xr helper
  51539. */
  51540. export class WebXRDefaultExperienceOptions {
  51541. /**
  51542. * Floor meshes that should be used for teleporting
  51543. */
  51544. floorMeshes: Array<AbstractMesh>;
  51545. /**
  51546. * Enable or disable default UI to enter XR
  51547. */
  51548. disableDefaultUI: boolean;
  51549. }
  51550. /**
  51551. * Default experience which provides a similar setup to the previous webVRExperience
  51552. */
  51553. export class WebXRDefaultExperience {
  51554. /**
  51555. * Base experience
  51556. */
  51557. baseExperience: WebXRExperienceHelper;
  51558. /**
  51559. * Input experience extension
  51560. */
  51561. input: WebXRInput;
  51562. /**
  51563. * Loads the controller models
  51564. */
  51565. controllerModelLoader: WebXRControllerModelLoader;
  51566. /**
  51567. * Enables laser pointer and selection
  51568. */
  51569. pointerSelection: WebXRControllerPointerSelection;
  51570. /**
  51571. * Enables teleportation
  51572. */
  51573. teleportation: WebXRControllerTeleportation;
  51574. /**
  51575. * Enables ui for enetering/exiting xr
  51576. */
  51577. enterExitUI: WebXREnterExitUI;
  51578. /**
  51579. * Default target xr should render to
  51580. */
  51581. renderTarget: WebXRRenderTarget;
  51582. /**
  51583. * Creates the default xr experience
  51584. * @param scene scene
  51585. * @param options options for basic configuration
  51586. * @returns resulting WebXRDefaultExperience
  51587. */
  51588. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51589. private constructor();
  51590. /**
  51591. * DIsposes of the experience helper
  51592. */
  51593. dispose(): void;
  51594. }
  51595. }
  51596. declare module "babylonjs/Helpers/sceneHelpers" {
  51597. import { Nullable } from "babylonjs/types";
  51598. import { Mesh } from "babylonjs/Meshes/mesh";
  51599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51600. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51601. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51602. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51603. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51604. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51605. import "babylonjs/Meshes/Builders/boxBuilder";
  51606. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51607. /** @hidden */
  51608. export var _forceSceneHelpersToBundle: boolean;
  51609. module "babylonjs/scene" {
  51610. interface Scene {
  51611. /**
  51612. * Creates a default light for the scene.
  51613. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51614. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51615. */
  51616. createDefaultLight(replace?: boolean): void;
  51617. /**
  51618. * Creates a default camera for the scene.
  51619. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51620. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51621. * @param replace has default false, when true replaces the active camera in the scene
  51622. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51623. */
  51624. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51625. /**
  51626. * Creates a default camera and a default light.
  51627. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51628. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51629. * @param replace has the default false, when true replaces the active camera/light in the scene
  51630. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51631. */
  51632. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51633. /**
  51634. * Creates a new sky box
  51635. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51636. * @param environmentTexture defines the texture to use as environment texture
  51637. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51638. * @param scale defines the overall scale of the skybox
  51639. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51640. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51641. * @returns a new mesh holding the sky box
  51642. */
  51643. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51644. /**
  51645. * Creates a new environment
  51646. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51647. * @param options defines the options you can use to configure the environment
  51648. * @returns the new EnvironmentHelper
  51649. */
  51650. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51651. /**
  51652. * Creates a new VREXperienceHelper
  51653. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51654. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51655. * @returns a new VREXperienceHelper
  51656. */
  51657. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51658. /**
  51659. * Creates a new WebXRDefaultExperience
  51660. * @see http://doc.babylonjs.com/how_to/webxr
  51661. * @param options experience options
  51662. * @returns a promise for a new WebXRDefaultExperience
  51663. */
  51664. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51665. }
  51666. }
  51667. }
  51668. declare module "babylonjs/Helpers/videoDome" {
  51669. import { Scene } from "babylonjs/scene";
  51670. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51671. import { Mesh } from "babylonjs/Meshes/mesh";
  51672. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51673. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51674. import "babylonjs/Meshes/Builders/sphereBuilder";
  51675. /**
  51676. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51677. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51678. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51679. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51680. */
  51681. export class VideoDome extends TransformNode {
  51682. /**
  51683. * Define the video source as a Monoscopic panoramic 360 video.
  51684. */
  51685. static readonly MODE_MONOSCOPIC: number;
  51686. /**
  51687. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51688. */
  51689. static readonly MODE_TOPBOTTOM: number;
  51690. /**
  51691. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51692. */
  51693. static readonly MODE_SIDEBYSIDE: number;
  51694. private _halfDome;
  51695. private _useDirectMapping;
  51696. /**
  51697. * The video texture being displayed on the sphere
  51698. */
  51699. protected _videoTexture: VideoTexture;
  51700. /**
  51701. * Gets the video texture being displayed on the sphere
  51702. */
  51703. readonly videoTexture: VideoTexture;
  51704. /**
  51705. * The skybox material
  51706. */
  51707. protected _material: BackgroundMaterial;
  51708. /**
  51709. * The surface used for the skybox
  51710. */
  51711. protected _mesh: Mesh;
  51712. /**
  51713. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51714. */
  51715. private _halfDomeMask;
  51716. /**
  51717. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51718. * Also see the options.resolution property.
  51719. */
  51720. fovMultiplier: number;
  51721. private _videoMode;
  51722. /**
  51723. * Gets or set the current video mode for the video. It can be:
  51724. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51725. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51726. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51727. */
  51728. videoMode: number;
  51729. /**
  51730. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51731. *
  51732. */
  51733. /**
  51734. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51735. */
  51736. halfDome: boolean;
  51737. /**
  51738. * Oberserver used in Stereoscopic VR Mode.
  51739. */
  51740. private _onBeforeCameraRenderObserver;
  51741. /**
  51742. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51743. * @param name Element's name, child elements will append suffixes for their own names.
  51744. * @param urlsOrVideo defines the url(s) or the video element to use
  51745. * @param options An object containing optional or exposed sub element properties
  51746. */
  51747. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51748. resolution?: number;
  51749. clickToPlay?: boolean;
  51750. autoPlay?: boolean;
  51751. loop?: boolean;
  51752. size?: number;
  51753. poster?: string;
  51754. faceForward?: boolean;
  51755. useDirectMapping?: boolean;
  51756. halfDomeMode?: boolean;
  51757. }, scene: Scene);
  51758. private _changeVideoMode;
  51759. /**
  51760. * Releases resources associated with this node.
  51761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51763. */
  51764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51765. }
  51766. }
  51767. declare module "babylonjs/Helpers/index" {
  51768. export * from "babylonjs/Helpers/environmentHelper";
  51769. export * from "babylonjs/Helpers/photoDome";
  51770. export * from "babylonjs/Helpers/sceneHelpers";
  51771. export * from "babylonjs/Helpers/videoDome";
  51772. }
  51773. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51774. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51775. import { IDisposable } from "babylonjs/scene";
  51776. import { Engine } from "babylonjs/Engines/engine";
  51777. /**
  51778. * This class can be used to get instrumentation data from a Babylon engine
  51779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51780. */
  51781. export class EngineInstrumentation implements IDisposable {
  51782. /**
  51783. * Define the instrumented engine.
  51784. */
  51785. engine: Engine;
  51786. private _captureGPUFrameTime;
  51787. private _gpuFrameTimeToken;
  51788. private _gpuFrameTime;
  51789. private _captureShaderCompilationTime;
  51790. private _shaderCompilationTime;
  51791. private _onBeginFrameObserver;
  51792. private _onEndFrameObserver;
  51793. private _onBeforeShaderCompilationObserver;
  51794. private _onAfterShaderCompilationObserver;
  51795. /**
  51796. * Gets the perf counter used for GPU frame time
  51797. */
  51798. readonly gpuFrameTimeCounter: PerfCounter;
  51799. /**
  51800. * Gets the GPU frame time capture status
  51801. */
  51802. /**
  51803. * Enable or disable the GPU frame time capture
  51804. */
  51805. captureGPUFrameTime: boolean;
  51806. /**
  51807. * Gets the perf counter used for shader compilation time
  51808. */
  51809. readonly shaderCompilationTimeCounter: PerfCounter;
  51810. /**
  51811. * Gets the shader compilation time capture status
  51812. */
  51813. /**
  51814. * Enable or disable the shader compilation time capture
  51815. */
  51816. captureShaderCompilationTime: boolean;
  51817. /**
  51818. * Instantiates a new engine instrumentation.
  51819. * This class can be used to get instrumentation data from a Babylon engine
  51820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51821. * @param engine Defines the engine to instrument
  51822. */
  51823. constructor(
  51824. /**
  51825. * Define the instrumented engine.
  51826. */
  51827. engine: Engine);
  51828. /**
  51829. * Dispose and release associated resources.
  51830. */
  51831. dispose(): void;
  51832. }
  51833. }
  51834. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51835. import { Scene, IDisposable } from "babylonjs/scene";
  51836. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51837. /**
  51838. * This class can be used to get instrumentation data from a Babylon engine
  51839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51840. */
  51841. export class SceneInstrumentation implements IDisposable {
  51842. /**
  51843. * Defines the scene to instrument
  51844. */
  51845. scene: Scene;
  51846. private _captureActiveMeshesEvaluationTime;
  51847. private _activeMeshesEvaluationTime;
  51848. private _captureRenderTargetsRenderTime;
  51849. private _renderTargetsRenderTime;
  51850. private _captureFrameTime;
  51851. private _frameTime;
  51852. private _captureRenderTime;
  51853. private _renderTime;
  51854. private _captureInterFrameTime;
  51855. private _interFrameTime;
  51856. private _captureParticlesRenderTime;
  51857. private _particlesRenderTime;
  51858. private _captureSpritesRenderTime;
  51859. private _spritesRenderTime;
  51860. private _capturePhysicsTime;
  51861. private _physicsTime;
  51862. private _captureAnimationsTime;
  51863. private _animationsTime;
  51864. private _captureCameraRenderTime;
  51865. private _cameraRenderTime;
  51866. private _onBeforeActiveMeshesEvaluationObserver;
  51867. private _onAfterActiveMeshesEvaluationObserver;
  51868. private _onBeforeRenderTargetsRenderObserver;
  51869. private _onAfterRenderTargetsRenderObserver;
  51870. private _onAfterRenderObserver;
  51871. private _onBeforeDrawPhaseObserver;
  51872. private _onAfterDrawPhaseObserver;
  51873. private _onBeforeAnimationsObserver;
  51874. private _onBeforeParticlesRenderingObserver;
  51875. private _onAfterParticlesRenderingObserver;
  51876. private _onBeforeSpritesRenderingObserver;
  51877. private _onAfterSpritesRenderingObserver;
  51878. private _onBeforePhysicsObserver;
  51879. private _onAfterPhysicsObserver;
  51880. private _onAfterAnimationsObserver;
  51881. private _onBeforeCameraRenderObserver;
  51882. private _onAfterCameraRenderObserver;
  51883. /**
  51884. * Gets the perf counter used for active meshes evaluation time
  51885. */
  51886. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51887. /**
  51888. * Gets the active meshes evaluation time capture status
  51889. */
  51890. /**
  51891. * Enable or disable the active meshes evaluation time capture
  51892. */
  51893. captureActiveMeshesEvaluationTime: boolean;
  51894. /**
  51895. * Gets the perf counter used for render targets render time
  51896. */
  51897. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51898. /**
  51899. * Gets the render targets render time capture status
  51900. */
  51901. /**
  51902. * Enable or disable the render targets render time capture
  51903. */
  51904. captureRenderTargetsRenderTime: boolean;
  51905. /**
  51906. * Gets the perf counter used for particles render time
  51907. */
  51908. readonly particlesRenderTimeCounter: PerfCounter;
  51909. /**
  51910. * Gets the particles render time capture status
  51911. */
  51912. /**
  51913. * Enable or disable the particles render time capture
  51914. */
  51915. captureParticlesRenderTime: boolean;
  51916. /**
  51917. * Gets the perf counter used for sprites render time
  51918. */
  51919. readonly spritesRenderTimeCounter: PerfCounter;
  51920. /**
  51921. * Gets the sprites render time capture status
  51922. */
  51923. /**
  51924. * Enable or disable the sprites render time capture
  51925. */
  51926. captureSpritesRenderTime: boolean;
  51927. /**
  51928. * Gets the perf counter used for physics time
  51929. */
  51930. readonly physicsTimeCounter: PerfCounter;
  51931. /**
  51932. * Gets the physics time capture status
  51933. */
  51934. /**
  51935. * Enable or disable the physics time capture
  51936. */
  51937. capturePhysicsTime: boolean;
  51938. /**
  51939. * Gets the perf counter used for animations time
  51940. */
  51941. readonly animationsTimeCounter: PerfCounter;
  51942. /**
  51943. * Gets the animations time capture status
  51944. */
  51945. /**
  51946. * Enable or disable the animations time capture
  51947. */
  51948. captureAnimationsTime: boolean;
  51949. /**
  51950. * Gets the perf counter used for frame time capture
  51951. */
  51952. readonly frameTimeCounter: PerfCounter;
  51953. /**
  51954. * Gets the frame time capture status
  51955. */
  51956. /**
  51957. * Enable or disable the frame time capture
  51958. */
  51959. captureFrameTime: boolean;
  51960. /**
  51961. * Gets the perf counter used for inter-frames time capture
  51962. */
  51963. readonly interFrameTimeCounter: PerfCounter;
  51964. /**
  51965. * Gets the inter-frames time capture status
  51966. */
  51967. /**
  51968. * Enable or disable the inter-frames time capture
  51969. */
  51970. captureInterFrameTime: boolean;
  51971. /**
  51972. * Gets the perf counter used for render time capture
  51973. */
  51974. readonly renderTimeCounter: PerfCounter;
  51975. /**
  51976. * Gets the render time capture status
  51977. */
  51978. /**
  51979. * Enable or disable the render time capture
  51980. */
  51981. captureRenderTime: boolean;
  51982. /**
  51983. * Gets the perf counter used for camera render time capture
  51984. */
  51985. readonly cameraRenderTimeCounter: PerfCounter;
  51986. /**
  51987. * Gets the camera render time capture status
  51988. */
  51989. /**
  51990. * Enable or disable the camera render time capture
  51991. */
  51992. captureCameraRenderTime: boolean;
  51993. /**
  51994. * Gets the perf counter used for draw calls
  51995. */
  51996. readonly drawCallsCounter: PerfCounter;
  51997. /**
  51998. * Instantiates a new scene instrumentation.
  51999. * This class can be used to get instrumentation data from a Babylon engine
  52000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52001. * @param scene Defines the scene to instrument
  52002. */
  52003. constructor(
  52004. /**
  52005. * Defines the scene to instrument
  52006. */
  52007. scene: Scene);
  52008. /**
  52009. * Dispose and release associated resources.
  52010. */
  52011. dispose(): void;
  52012. }
  52013. }
  52014. declare module "babylonjs/Instrumentation/index" {
  52015. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52016. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52017. export * from "babylonjs/Instrumentation/timeToken";
  52018. }
  52019. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52020. /** @hidden */
  52021. export var glowMapGenerationPixelShader: {
  52022. name: string;
  52023. shader: string;
  52024. };
  52025. }
  52026. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52027. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52028. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52029. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52030. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52031. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52034. /** @hidden */
  52035. export var glowMapGenerationVertexShader: {
  52036. name: string;
  52037. shader: string;
  52038. };
  52039. }
  52040. declare module "babylonjs/Layers/effectLayer" {
  52041. import { Observable } from "babylonjs/Misc/observable";
  52042. import { Nullable } from "babylonjs/types";
  52043. import { Camera } from "babylonjs/Cameras/camera";
  52044. import { Scene } from "babylonjs/scene";
  52045. import { ISize } from "babylonjs/Maths/math.size";
  52046. import { Color4 } from "babylonjs/Maths/math.color";
  52047. import { Engine } from "babylonjs/Engines/engine";
  52048. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52050. import { Mesh } from "babylonjs/Meshes/mesh";
  52051. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52053. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52054. import { Effect } from "babylonjs/Materials/effect";
  52055. import { Material } from "babylonjs/Materials/material";
  52056. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52057. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52058. /**
  52059. * Effect layer options. This helps customizing the behaviour
  52060. * of the effect layer.
  52061. */
  52062. export interface IEffectLayerOptions {
  52063. /**
  52064. * Multiplication factor apply to the canvas size to compute the render target size
  52065. * used to generated the objects (the smaller the faster).
  52066. */
  52067. mainTextureRatio: number;
  52068. /**
  52069. * Enforces a fixed size texture to ensure effect stability across devices.
  52070. */
  52071. mainTextureFixedSize?: number;
  52072. /**
  52073. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52074. */
  52075. alphaBlendingMode: number;
  52076. /**
  52077. * The camera attached to the layer.
  52078. */
  52079. camera: Nullable<Camera>;
  52080. /**
  52081. * The rendering group to draw the layer in.
  52082. */
  52083. renderingGroupId: number;
  52084. }
  52085. /**
  52086. * The effect layer Helps adding post process effect blended with the main pass.
  52087. *
  52088. * This can be for instance use to generate glow or higlight effects on the scene.
  52089. *
  52090. * The effect layer class can not be used directly and is intented to inherited from to be
  52091. * customized per effects.
  52092. */
  52093. export abstract class EffectLayer {
  52094. private _vertexBuffers;
  52095. private _indexBuffer;
  52096. private _cachedDefines;
  52097. private _effectLayerMapGenerationEffect;
  52098. private _effectLayerOptions;
  52099. private _mergeEffect;
  52100. protected _scene: Scene;
  52101. protected _engine: Engine;
  52102. protected _maxSize: number;
  52103. protected _mainTextureDesiredSize: ISize;
  52104. protected _mainTexture: RenderTargetTexture;
  52105. protected _shouldRender: boolean;
  52106. protected _postProcesses: PostProcess[];
  52107. protected _textures: BaseTexture[];
  52108. protected _emissiveTextureAndColor: {
  52109. texture: Nullable<BaseTexture>;
  52110. color: Color4;
  52111. };
  52112. /**
  52113. * The name of the layer
  52114. */
  52115. name: string;
  52116. /**
  52117. * The clear color of the texture used to generate the glow map.
  52118. */
  52119. neutralColor: Color4;
  52120. /**
  52121. * Specifies wether the highlight layer is enabled or not.
  52122. */
  52123. isEnabled: boolean;
  52124. /**
  52125. * Gets the camera attached to the layer.
  52126. */
  52127. readonly camera: Nullable<Camera>;
  52128. /**
  52129. * Gets the rendering group id the layer should render in.
  52130. */
  52131. renderingGroupId: number;
  52132. /**
  52133. * An event triggered when the effect layer has been disposed.
  52134. */
  52135. onDisposeObservable: Observable<EffectLayer>;
  52136. /**
  52137. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52138. */
  52139. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52140. /**
  52141. * An event triggered when the generated texture is being merged in the scene.
  52142. */
  52143. onBeforeComposeObservable: Observable<EffectLayer>;
  52144. /**
  52145. * An event triggered when the mesh is rendered into the effect render target.
  52146. */
  52147. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52148. /**
  52149. * An event triggered after the mesh has been rendered into the effect render target.
  52150. */
  52151. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52152. /**
  52153. * An event triggered when the generated texture has been merged in the scene.
  52154. */
  52155. onAfterComposeObservable: Observable<EffectLayer>;
  52156. /**
  52157. * An event triggered when the efffect layer changes its size.
  52158. */
  52159. onSizeChangedObservable: Observable<EffectLayer>;
  52160. /** @hidden */
  52161. static _SceneComponentInitialization: (scene: Scene) => void;
  52162. /**
  52163. * Instantiates a new effect Layer and references it in the scene.
  52164. * @param name The name of the layer
  52165. * @param scene The scene to use the layer in
  52166. */
  52167. constructor(
  52168. /** The Friendly of the effect in the scene */
  52169. name: string, scene: Scene);
  52170. /**
  52171. * Get the effect name of the layer.
  52172. * @return The effect name
  52173. */
  52174. abstract getEffectName(): string;
  52175. /**
  52176. * Checks for the readiness of the element composing the layer.
  52177. * @param subMesh the mesh to check for
  52178. * @param useInstances specify wether or not to use instances to render the mesh
  52179. * @return true if ready otherwise, false
  52180. */
  52181. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52182. /**
  52183. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52184. * @returns true if the effect requires stencil during the main canvas render pass.
  52185. */
  52186. abstract needStencil(): boolean;
  52187. /**
  52188. * Create the merge effect. This is the shader use to blit the information back
  52189. * to the main canvas at the end of the scene rendering.
  52190. * @returns The effect containing the shader used to merge the effect on the main canvas
  52191. */
  52192. protected abstract _createMergeEffect(): Effect;
  52193. /**
  52194. * Creates the render target textures and post processes used in the effect layer.
  52195. */
  52196. protected abstract _createTextureAndPostProcesses(): void;
  52197. /**
  52198. * Implementation specific of rendering the generating effect on the main canvas.
  52199. * @param effect The effect used to render through
  52200. */
  52201. protected abstract _internalRender(effect: Effect): void;
  52202. /**
  52203. * Sets the required values for both the emissive texture and and the main color.
  52204. */
  52205. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52206. /**
  52207. * Free any resources and references associated to a mesh.
  52208. * Internal use
  52209. * @param mesh The mesh to free.
  52210. */
  52211. abstract _disposeMesh(mesh: Mesh): void;
  52212. /**
  52213. * Serializes this layer (Glow or Highlight for example)
  52214. * @returns a serialized layer object
  52215. */
  52216. abstract serialize?(): any;
  52217. /**
  52218. * Initializes the effect layer with the required options.
  52219. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52220. */
  52221. protected _init(options: Partial<IEffectLayerOptions>): void;
  52222. /**
  52223. * Generates the index buffer of the full screen quad blending to the main canvas.
  52224. */
  52225. private _generateIndexBuffer;
  52226. /**
  52227. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52228. */
  52229. private _generateVertexBuffer;
  52230. /**
  52231. * Sets the main texture desired size which is the closest power of two
  52232. * of the engine canvas size.
  52233. */
  52234. private _setMainTextureSize;
  52235. /**
  52236. * Creates the main texture for the effect layer.
  52237. */
  52238. protected _createMainTexture(): void;
  52239. /**
  52240. * Adds specific effects defines.
  52241. * @param defines The defines to add specifics to.
  52242. */
  52243. protected _addCustomEffectDefines(defines: string[]): void;
  52244. /**
  52245. * Checks for the readiness of the element composing the layer.
  52246. * @param subMesh the mesh to check for
  52247. * @param useInstances specify wether or not to use instances to render the mesh
  52248. * @param emissiveTexture the associated emissive texture used to generate the glow
  52249. * @return true if ready otherwise, false
  52250. */
  52251. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52252. /**
  52253. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52254. */
  52255. render(): void;
  52256. /**
  52257. * Determine if a given mesh will be used in the current effect.
  52258. * @param mesh mesh to test
  52259. * @returns true if the mesh will be used
  52260. */
  52261. hasMesh(mesh: AbstractMesh): boolean;
  52262. /**
  52263. * Returns true if the layer contains information to display, otherwise false.
  52264. * @returns true if the glow layer should be rendered
  52265. */
  52266. shouldRender(): boolean;
  52267. /**
  52268. * Returns true if the mesh should render, otherwise false.
  52269. * @param mesh The mesh to render
  52270. * @returns true if it should render otherwise false
  52271. */
  52272. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52273. /**
  52274. * Returns true if the mesh can be rendered, otherwise false.
  52275. * @param mesh The mesh to render
  52276. * @param material The material used on the mesh
  52277. * @returns true if it can be rendered otherwise false
  52278. */
  52279. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52280. /**
  52281. * Returns true if the mesh should render, otherwise false.
  52282. * @param mesh The mesh to render
  52283. * @returns true if it should render otherwise false
  52284. */
  52285. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52286. /**
  52287. * Renders the submesh passed in parameter to the generation map.
  52288. */
  52289. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52290. /**
  52291. * Defines wether the current material of the mesh should be use to render the effect.
  52292. * @param mesh defines the current mesh to render
  52293. */
  52294. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52295. /**
  52296. * Rebuild the required buffers.
  52297. * @hidden Internal use only.
  52298. */
  52299. _rebuild(): void;
  52300. /**
  52301. * Dispose only the render target textures and post process.
  52302. */
  52303. private _disposeTextureAndPostProcesses;
  52304. /**
  52305. * Dispose the highlight layer and free resources.
  52306. */
  52307. dispose(): void;
  52308. /**
  52309. * Gets the class name of the effect layer
  52310. * @returns the string with the class name of the effect layer
  52311. */
  52312. getClassName(): string;
  52313. /**
  52314. * Creates an effect layer from parsed effect layer data
  52315. * @param parsedEffectLayer defines effect layer data
  52316. * @param scene defines the current scene
  52317. * @param rootUrl defines the root URL containing the effect layer information
  52318. * @returns a parsed effect Layer
  52319. */
  52320. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52321. }
  52322. }
  52323. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52324. import { Scene } from "babylonjs/scene";
  52325. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52326. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52327. import { AbstractScene } from "babylonjs/abstractScene";
  52328. module "babylonjs/abstractScene" {
  52329. interface AbstractScene {
  52330. /**
  52331. * The list of effect layers (highlights/glow) added to the scene
  52332. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52333. * @see http://doc.babylonjs.com/how_to/glow_layer
  52334. */
  52335. effectLayers: Array<EffectLayer>;
  52336. /**
  52337. * Removes the given effect layer from this scene.
  52338. * @param toRemove defines the effect layer to remove
  52339. * @returns the index of the removed effect layer
  52340. */
  52341. removeEffectLayer(toRemove: EffectLayer): number;
  52342. /**
  52343. * Adds the given effect layer to this scene
  52344. * @param newEffectLayer defines the effect layer to add
  52345. */
  52346. addEffectLayer(newEffectLayer: EffectLayer): void;
  52347. }
  52348. }
  52349. /**
  52350. * Defines the layer scene component responsible to manage any effect layers
  52351. * in a given scene.
  52352. */
  52353. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52354. /**
  52355. * The component name helpfull to identify the component in the list of scene components.
  52356. */
  52357. readonly name: string;
  52358. /**
  52359. * The scene the component belongs to.
  52360. */
  52361. scene: Scene;
  52362. private _engine;
  52363. private _renderEffects;
  52364. private _needStencil;
  52365. private _previousStencilState;
  52366. /**
  52367. * Creates a new instance of the component for the given scene
  52368. * @param scene Defines the scene to register the component in
  52369. */
  52370. constructor(scene: Scene);
  52371. /**
  52372. * Registers the component in a given scene
  52373. */
  52374. register(): void;
  52375. /**
  52376. * Rebuilds the elements related to this component in case of
  52377. * context lost for instance.
  52378. */
  52379. rebuild(): void;
  52380. /**
  52381. * Serializes the component data to the specified json object
  52382. * @param serializationObject The object to serialize to
  52383. */
  52384. serialize(serializationObject: any): void;
  52385. /**
  52386. * Adds all the elements from the container to the scene
  52387. * @param container the container holding the elements
  52388. */
  52389. addFromContainer(container: AbstractScene): void;
  52390. /**
  52391. * Removes all the elements in the container from the scene
  52392. * @param container contains the elements to remove
  52393. * @param dispose if the removed element should be disposed (default: false)
  52394. */
  52395. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52396. /**
  52397. * Disposes the component and the associated ressources.
  52398. */
  52399. dispose(): void;
  52400. private _isReadyForMesh;
  52401. private _renderMainTexture;
  52402. private _setStencil;
  52403. private _setStencilBack;
  52404. private _draw;
  52405. private _drawCamera;
  52406. private _drawRenderingGroup;
  52407. }
  52408. }
  52409. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52410. /** @hidden */
  52411. export var glowMapMergePixelShader: {
  52412. name: string;
  52413. shader: string;
  52414. };
  52415. }
  52416. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52417. /** @hidden */
  52418. export var glowMapMergeVertexShader: {
  52419. name: string;
  52420. shader: string;
  52421. };
  52422. }
  52423. declare module "babylonjs/Layers/glowLayer" {
  52424. import { Nullable } from "babylonjs/types";
  52425. import { Camera } from "babylonjs/Cameras/camera";
  52426. import { Scene } from "babylonjs/scene";
  52427. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52429. import { Mesh } from "babylonjs/Meshes/mesh";
  52430. import { Texture } from "babylonjs/Materials/Textures/texture";
  52431. import { Effect } from "babylonjs/Materials/effect";
  52432. import { Material } from "babylonjs/Materials/material";
  52433. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52434. import { Color4 } from "babylonjs/Maths/math.color";
  52435. import "babylonjs/Shaders/glowMapMerge.fragment";
  52436. import "babylonjs/Shaders/glowMapMerge.vertex";
  52437. import "babylonjs/Layers/effectLayerSceneComponent";
  52438. module "babylonjs/abstractScene" {
  52439. interface AbstractScene {
  52440. /**
  52441. * Return a the first highlight layer of the scene with a given name.
  52442. * @param name The name of the highlight layer to look for.
  52443. * @return The highlight layer if found otherwise null.
  52444. */
  52445. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52446. }
  52447. }
  52448. /**
  52449. * Glow layer options. This helps customizing the behaviour
  52450. * of the glow layer.
  52451. */
  52452. export interface IGlowLayerOptions {
  52453. /**
  52454. * Multiplication factor apply to the canvas size to compute the render target size
  52455. * used to generated the glowing objects (the smaller the faster).
  52456. */
  52457. mainTextureRatio: number;
  52458. /**
  52459. * Enforces a fixed size texture to ensure resize independant blur.
  52460. */
  52461. mainTextureFixedSize?: number;
  52462. /**
  52463. * How big is the kernel of the blur texture.
  52464. */
  52465. blurKernelSize: number;
  52466. /**
  52467. * The camera attached to the layer.
  52468. */
  52469. camera: Nullable<Camera>;
  52470. /**
  52471. * Enable MSAA by chosing the number of samples.
  52472. */
  52473. mainTextureSamples?: number;
  52474. /**
  52475. * The rendering group to draw the layer in.
  52476. */
  52477. renderingGroupId: number;
  52478. }
  52479. /**
  52480. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52481. *
  52482. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52483. *
  52484. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52485. */
  52486. export class GlowLayer extends EffectLayer {
  52487. /**
  52488. * Effect Name of the layer.
  52489. */
  52490. static readonly EffectName: string;
  52491. /**
  52492. * The default blur kernel size used for the glow.
  52493. */
  52494. static DefaultBlurKernelSize: number;
  52495. /**
  52496. * The default texture size ratio used for the glow.
  52497. */
  52498. static DefaultTextureRatio: number;
  52499. /**
  52500. * Sets the kernel size of the blur.
  52501. */
  52502. /**
  52503. * Gets the kernel size of the blur.
  52504. */
  52505. blurKernelSize: number;
  52506. /**
  52507. * Sets the glow intensity.
  52508. */
  52509. /**
  52510. * Gets the glow intensity.
  52511. */
  52512. intensity: number;
  52513. private _options;
  52514. private _intensity;
  52515. private _horizontalBlurPostprocess1;
  52516. private _verticalBlurPostprocess1;
  52517. private _horizontalBlurPostprocess2;
  52518. private _verticalBlurPostprocess2;
  52519. private _blurTexture1;
  52520. private _blurTexture2;
  52521. private _postProcesses1;
  52522. private _postProcesses2;
  52523. private _includedOnlyMeshes;
  52524. private _excludedMeshes;
  52525. private _meshesUsingTheirOwnMaterials;
  52526. /**
  52527. * Callback used to let the user override the color selection on a per mesh basis
  52528. */
  52529. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52530. /**
  52531. * Callback used to let the user override the texture selection on a per mesh basis
  52532. */
  52533. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52534. /**
  52535. * Instantiates a new glow Layer and references it to the scene.
  52536. * @param name The name of the layer
  52537. * @param scene The scene to use the layer in
  52538. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52539. */
  52540. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52541. /**
  52542. * Get the effect name of the layer.
  52543. * @return The effect name
  52544. */
  52545. getEffectName(): string;
  52546. /**
  52547. * Create the merge effect. This is the shader use to blit the information back
  52548. * to the main canvas at the end of the scene rendering.
  52549. */
  52550. protected _createMergeEffect(): Effect;
  52551. /**
  52552. * Creates the render target textures and post processes used in the glow layer.
  52553. */
  52554. protected _createTextureAndPostProcesses(): void;
  52555. /**
  52556. * Checks for the readiness of the element composing the layer.
  52557. * @param subMesh the mesh to check for
  52558. * @param useInstances specify wether or not to use instances to render the mesh
  52559. * @param emissiveTexture the associated emissive texture used to generate the glow
  52560. * @return true if ready otherwise, false
  52561. */
  52562. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52563. /**
  52564. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52565. */
  52566. needStencil(): boolean;
  52567. /**
  52568. * Returns true if the mesh can be rendered, otherwise false.
  52569. * @param mesh The mesh to render
  52570. * @param material The material used on the mesh
  52571. * @returns true if it can be rendered otherwise false
  52572. */
  52573. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52574. /**
  52575. * Implementation specific of rendering the generating effect on the main canvas.
  52576. * @param effect The effect used to render through
  52577. */
  52578. protected _internalRender(effect: Effect): void;
  52579. /**
  52580. * Sets the required values for both the emissive texture and and the main color.
  52581. */
  52582. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52583. /**
  52584. * Returns true if the mesh should render, otherwise false.
  52585. * @param mesh The mesh to render
  52586. * @returns true if it should render otherwise false
  52587. */
  52588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52589. /**
  52590. * Adds specific effects defines.
  52591. * @param defines The defines to add specifics to.
  52592. */
  52593. protected _addCustomEffectDefines(defines: string[]): void;
  52594. /**
  52595. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52596. * @param mesh The mesh to exclude from the glow layer
  52597. */
  52598. addExcludedMesh(mesh: Mesh): void;
  52599. /**
  52600. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52601. * @param mesh The mesh to remove
  52602. */
  52603. removeExcludedMesh(mesh: Mesh): void;
  52604. /**
  52605. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52606. * @param mesh The mesh to include in the glow layer
  52607. */
  52608. addIncludedOnlyMesh(mesh: Mesh): void;
  52609. /**
  52610. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52611. * @param mesh The mesh to remove
  52612. */
  52613. removeIncludedOnlyMesh(mesh: Mesh): void;
  52614. /**
  52615. * Determine if a given mesh will be used in the glow layer
  52616. * @param mesh The mesh to test
  52617. * @returns true if the mesh will be highlighted by the current glow layer
  52618. */
  52619. hasMesh(mesh: AbstractMesh): boolean;
  52620. /**
  52621. * Defines wether the current material of the mesh should be use to render the effect.
  52622. * @param mesh defines the current mesh to render
  52623. */
  52624. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52625. /**
  52626. * Add a mesh to be rendered through its own material and not with emissive only.
  52627. * @param mesh The mesh for which we need to use its material
  52628. */
  52629. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52630. /**
  52631. * Remove a mesh from being rendered through its own material and not with emissive only.
  52632. * @param mesh The mesh for which we need to not use its material
  52633. */
  52634. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52635. /**
  52636. * Free any resources and references associated to a mesh.
  52637. * Internal use
  52638. * @param mesh The mesh to free.
  52639. * @hidden
  52640. */
  52641. _disposeMesh(mesh: Mesh): void;
  52642. /**
  52643. * Gets the class name of the effect layer
  52644. * @returns the string with the class name of the effect layer
  52645. */
  52646. getClassName(): string;
  52647. /**
  52648. * Serializes this glow layer
  52649. * @returns a serialized glow layer object
  52650. */
  52651. serialize(): any;
  52652. /**
  52653. * Creates a Glow Layer from parsed glow layer data
  52654. * @param parsedGlowLayer defines glow layer data
  52655. * @param scene defines the current scene
  52656. * @param rootUrl defines the root URL containing the glow layer information
  52657. * @returns a parsed Glow Layer
  52658. */
  52659. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52660. }
  52661. }
  52662. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52663. /** @hidden */
  52664. export var glowBlurPostProcessPixelShader: {
  52665. name: string;
  52666. shader: string;
  52667. };
  52668. }
  52669. declare module "babylonjs/Layers/highlightLayer" {
  52670. import { Observable } from "babylonjs/Misc/observable";
  52671. import { Nullable } from "babylonjs/types";
  52672. import { Camera } from "babylonjs/Cameras/camera";
  52673. import { Scene } from "babylonjs/scene";
  52674. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52676. import { Mesh } from "babylonjs/Meshes/mesh";
  52677. import { Effect } from "babylonjs/Materials/effect";
  52678. import { Material } from "babylonjs/Materials/material";
  52679. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52680. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52681. import "babylonjs/Shaders/glowMapMerge.fragment";
  52682. import "babylonjs/Shaders/glowMapMerge.vertex";
  52683. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52684. module "babylonjs/abstractScene" {
  52685. interface AbstractScene {
  52686. /**
  52687. * Return a the first highlight layer of the scene with a given name.
  52688. * @param name The name of the highlight layer to look for.
  52689. * @return The highlight layer if found otherwise null.
  52690. */
  52691. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52692. }
  52693. }
  52694. /**
  52695. * Highlight layer options. This helps customizing the behaviour
  52696. * of the highlight layer.
  52697. */
  52698. export interface IHighlightLayerOptions {
  52699. /**
  52700. * Multiplication factor apply to the canvas size to compute the render target size
  52701. * used to generated the glowing objects (the smaller the faster).
  52702. */
  52703. mainTextureRatio: number;
  52704. /**
  52705. * Enforces a fixed size texture to ensure resize independant blur.
  52706. */
  52707. mainTextureFixedSize?: number;
  52708. /**
  52709. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52710. * of the picture to blur (the smaller the faster).
  52711. */
  52712. blurTextureSizeRatio: number;
  52713. /**
  52714. * How big in texel of the blur texture is the vertical blur.
  52715. */
  52716. blurVerticalSize: number;
  52717. /**
  52718. * How big in texel of the blur texture is the horizontal blur.
  52719. */
  52720. blurHorizontalSize: number;
  52721. /**
  52722. * Alpha blending mode used to apply the blur. Default is combine.
  52723. */
  52724. alphaBlendingMode: number;
  52725. /**
  52726. * The camera attached to the layer.
  52727. */
  52728. camera: Nullable<Camera>;
  52729. /**
  52730. * Should we display highlight as a solid stroke?
  52731. */
  52732. isStroke?: boolean;
  52733. /**
  52734. * The rendering group to draw the layer in.
  52735. */
  52736. renderingGroupId: number;
  52737. }
  52738. /**
  52739. * The highlight layer Helps adding a glow effect around a mesh.
  52740. *
  52741. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52742. * glowy meshes to your scene.
  52743. *
  52744. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52745. */
  52746. export class HighlightLayer extends EffectLayer {
  52747. name: string;
  52748. /**
  52749. * Effect Name of the highlight layer.
  52750. */
  52751. static readonly EffectName: string;
  52752. /**
  52753. * The neutral color used during the preparation of the glow effect.
  52754. * This is black by default as the blend operation is a blend operation.
  52755. */
  52756. static NeutralColor: Color4;
  52757. /**
  52758. * Stencil value used for glowing meshes.
  52759. */
  52760. static GlowingMeshStencilReference: number;
  52761. /**
  52762. * Stencil value used for the other meshes in the scene.
  52763. */
  52764. static NormalMeshStencilReference: number;
  52765. /**
  52766. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52767. */
  52768. innerGlow: boolean;
  52769. /**
  52770. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52771. */
  52772. outerGlow: boolean;
  52773. /**
  52774. * Specifies the horizontal size of the blur.
  52775. */
  52776. /**
  52777. * Gets the horizontal size of the blur.
  52778. */
  52779. blurHorizontalSize: number;
  52780. /**
  52781. * Specifies the vertical size of the blur.
  52782. */
  52783. /**
  52784. * Gets the vertical size of the blur.
  52785. */
  52786. blurVerticalSize: number;
  52787. /**
  52788. * An event triggered when the highlight layer is being blurred.
  52789. */
  52790. onBeforeBlurObservable: Observable<HighlightLayer>;
  52791. /**
  52792. * An event triggered when the highlight layer has been blurred.
  52793. */
  52794. onAfterBlurObservable: Observable<HighlightLayer>;
  52795. private _instanceGlowingMeshStencilReference;
  52796. private _options;
  52797. private _downSamplePostprocess;
  52798. private _horizontalBlurPostprocess;
  52799. private _verticalBlurPostprocess;
  52800. private _blurTexture;
  52801. private _meshes;
  52802. private _excludedMeshes;
  52803. /**
  52804. * Instantiates a new highlight Layer and references it to the scene..
  52805. * @param name The name of the layer
  52806. * @param scene The scene to use the layer in
  52807. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52808. */
  52809. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52810. /**
  52811. * Get the effect name of the layer.
  52812. * @return The effect name
  52813. */
  52814. getEffectName(): string;
  52815. /**
  52816. * Create the merge effect. This is the shader use to blit the information back
  52817. * to the main canvas at the end of the scene rendering.
  52818. */
  52819. protected _createMergeEffect(): Effect;
  52820. /**
  52821. * Creates the render target textures and post processes used in the highlight layer.
  52822. */
  52823. protected _createTextureAndPostProcesses(): void;
  52824. /**
  52825. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52826. */
  52827. needStencil(): boolean;
  52828. /**
  52829. * Checks for the readiness of the element composing the layer.
  52830. * @param subMesh the mesh to check for
  52831. * @param useInstances specify wether or not to use instances to render the mesh
  52832. * @param emissiveTexture the associated emissive texture used to generate the glow
  52833. * @return true if ready otherwise, false
  52834. */
  52835. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52836. /**
  52837. * Implementation specific of rendering the generating effect on the main canvas.
  52838. * @param effect The effect used to render through
  52839. */
  52840. protected _internalRender(effect: Effect): void;
  52841. /**
  52842. * Returns true if the layer contains information to display, otherwise false.
  52843. */
  52844. shouldRender(): boolean;
  52845. /**
  52846. * Returns true if the mesh should render, otherwise false.
  52847. * @param mesh The mesh to render
  52848. * @returns true if it should render otherwise false
  52849. */
  52850. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52851. /**
  52852. * Sets the required values for both the emissive texture and and the main color.
  52853. */
  52854. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52855. /**
  52856. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52857. * @param mesh The mesh to exclude from the highlight layer
  52858. */
  52859. addExcludedMesh(mesh: Mesh): void;
  52860. /**
  52861. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52862. * @param mesh The mesh to highlight
  52863. */
  52864. removeExcludedMesh(mesh: Mesh): void;
  52865. /**
  52866. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52867. * @param mesh mesh to test
  52868. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52869. */
  52870. hasMesh(mesh: AbstractMesh): boolean;
  52871. /**
  52872. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52873. * @param mesh The mesh to highlight
  52874. * @param color The color of the highlight
  52875. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52876. */
  52877. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52878. /**
  52879. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52880. * @param mesh The mesh to highlight
  52881. */
  52882. removeMesh(mesh: Mesh): void;
  52883. /**
  52884. * Force the stencil to the normal expected value for none glowing parts
  52885. */
  52886. private _defaultStencilReference;
  52887. /**
  52888. * Free any resources and references associated to a mesh.
  52889. * Internal use
  52890. * @param mesh The mesh to free.
  52891. * @hidden
  52892. */
  52893. _disposeMesh(mesh: Mesh): void;
  52894. /**
  52895. * Dispose the highlight layer and free resources.
  52896. */
  52897. dispose(): void;
  52898. /**
  52899. * Gets the class name of the effect layer
  52900. * @returns the string with the class name of the effect layer
  52901. */
  52902. getClassName(): string;
  52903. /**
  52904. * Serializes this Highlight layer
  52905. * @returns a serialized Highlight layer object
  52906. */
  52907. serialize(): any;
  52908. /**
  52909. * Creates a Highlight layer from parsed Highlight layer data
  52910. * @param parsedHightlightLayer defines the Highlight layer data
  52911. * @param scene defines the current scene
  52912. * @param rootUrl defines the root URL containing the Highlight layer information
  52913. * @returns a parsed Highlight layer
  52914. */
  52915. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52916. }
  52917. }
  52918. declare module "babylonjs/Layers/layerSceneComponent" {
  52919. import { Scene } from "babylonjs/scene";
  52920. import { ISceneComponent } from "babylonjs/sceneComponent";
  52921. import { Layer } from "babylonjs/Layers/layer";
  52922. import { AbstractScene } from "babylonjs/abstractScene";
  52923. module "babylonjs/abstractScene" {
  52924. interface AbstractScene {
  52925. /**
  52926. * The list of layers (background and foreground) of the scene
  52927. */
  52928. layers: Array<Layer>;
  52929. }
  52930. }
  52931. /**
  52932. * Defines the layer scene component responsible to manage any layers
  52933. * in a given scene.
  52934. */
  52935. export class LayerSceneComponent implements ISceneComponent {
  52936. /**
  52937. * The component name helpfull to identify the component in the list of scene components.
  52938. */
  52939. readonly name: string;
  52940. /**
  52941. * The scene the component belongs to.
  52942. */
  52943. scene: Scene;
  52944. private _engine;
  52945. /**
  52946. * Creates a new instance of the component for the given scene
  52947. * @param scene Defines the scene to register the component in
  52948. */
  52949. constructor(scene: Scene);
  52950. /**
  52951. * Registers the component in a given scene
  52952. */
  52953. register(): void;
  52954. /**
  52955. * Rebuilds the elements related to this component in case of
  52956. * context lost for instance.
  52957. */
  52958. rebuild(): void;
  52959. /**
  52960. * Disposes the component and the associated ressources.
  52961. */
  52962. dispose(): void;
  52963. private _draw;
  52964. private _drawCameraPredicate;
  52965. private _drawCameraBackground;
  52966. private _drawCameraForeground;
  52967. private _drawRenderTargetPredicate;
  52968. private _drawRenderTargetBackground;
  52969. private _drawRenderTargetForeground;
  52970. /**
  52971. * Adds all the elements from the container to the scene
  52972. * @param container the container holding the elements
  52973. */
  52974. addFromContainer(container: AbstractScene): void;
  52975. /**
  52976. * Removes all the elements in the container from the scene
  52977. * @param container contains the elements to remove
  52978. * @param dispose if the removed element should be disposed (default: false)
  52979. */
  52980. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52981. }
  52982. }
  52983. declare module "babylonjs/Shaders/layer.fragment" {
  52984. /** @hidden */
  52985. export var layerPixelShader: {
  52986. name: string;
  52987. shader: string;
  52988. };
  52989. }
  52990. declare module "babylonjs/Shaders/layer.vertex" {
  52991. /** @hidden */
  52992. export var layerVertexShader: {
  52993. name: string;
  52994. shader: string;
  52995. };
  52996. }
  52997. declare module "babylonjs/Layers/layer" {
  52998. import { Observable } from "babylonjs/Misc/observable";
  52999. import { Nullable } from "babylonjs/types";
  53000. import { Scene } from "babylonjs/scene";
  53001. import { Vector2 } from "babylonjs/Maths/math.vector";
  53002. import { Color4 } from "babylonjs/Maths/math.color";
  53003. import { Texture } from "babylonjs/Materials/Textures/texture";
  53004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53005. import "babylonjs/Shaders/layer.fragment";
  53006. import "babylonjs/Shaders/layer.vertex";
  53007. /**
  53008. * This represents a full screen 2d layer.
  53009. * This can be useful to display a picture in the background of your scene for instance.
  53010. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53011. */
  53012. export class Layer {
  53013. /**
  53014. * Define the name of the layer.
  53015. */
  53016. name: string;
  53017. /**
  53018. * Define the texture the layer should display.
  53019. */
  53020. texture: Nullable<Texture>;
  53021. /**
  53022. * Is the layer in background or foreground.
  53023. */
  53024. isBackground: boolean;
  53025. /**
  53026. * Define the color of the layer (instead of texture).
  53027. */
  53028. color: Color4;
  53029. /**
  53030. * Define the scale of the layer in order to zoom in out of the texture.
  53031. */
  53032. scale: Vector2;
  53033. /**
  53034. * Define an offset for the layer in order to shift the texture.
  53035. */
  53036. offset: Vector2;
  53037. /**
  53038. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53039. */
  53040. alphaBlendingMode: number;
  53041. /**
  53042. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53043. * Alpha test will not mix with the background color in case of transparency.
  53044. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53045. */
  53046. alphaTest: boolean;
  53047. /**
  53048. * Define a mask to restrict the layer to only some of the scene cameras.
  53049. */
  53050. layerMask: number;
  53051. /**
  53052. * Define the list of render target the layer is visible into.
  53053. */
  53054. renderTargetTextures: RenderTargetTexture[];
  53055. /**
  53056. * Define if the layer is only used in renderTarget or if it also
  53057. * renders in the main frame buffer of the canvas.
  53058. */
  53059. renderOnlyInRenderTargetTextures: boolean;
  53060. private _scene;
  53061. private _vertexBuffers;
  53062. private _indexBuffer;
  53063. private _effect;
  53064. private _alphaTestEffect;
  53065. /**
  53066. * An event triggered when the layer is disposed.
  53067. */
  53068. onDisposeObservable: Observable<Layer>;
  53069. private _onDisposeObserver;
  53070. /**
  53071. * Back compatibility with callback before the onDisposeObservable existed.
  53072. * The set callback will be triggered when the layer has been disposed.
  53073. */
  53074. onDispose: () => void;
  53075. /**
  53076. * An event triggered before rendering the scene
  53077. */
  53078. onBeforeRenderObservable: Observable<Layer>;
  53079. private _onBeforeRenderObserver;
  53080. /**
  53081. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53082. * The set callback will be triggered just before rendering the layer.
  53083. */
  53084. onBeforeRender: () => void;
  53085. /**
  53086. * An event triggered after rendering the scene
  53087. */
  53088. onAfterRenderObservable: Observable<Layer>;
  53089. private _onAfterRenderObserver;
  53090. /**
  53091. * Back compatibility with callback before the onAfterRenderObservable existed.
  53092. * The set callback will be triggered just after rendering the layer.
  53093. */
  53094. onAfterRender: () => void;
  53095. /**
  53096. * Instantiates a new layer.
  53097. * This represents a full screen 2d layer.
  53098. * This can be useful to display a picture in the background of your scene for instance.
  53099. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53100. * @param name Define the name of the layer in the scene
  53101. * @param imgUrl Define the url of the texture to display in the layer
  53102. * @param scene Define the scene the layer belongs to
  53103. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53104. * @param color Defines a color for the layer
  53105. */
  53106. constructor(
  53107. /**
  53108. * Define the name of the layer.
  53109. */
  53110. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53111. private _createIndexBuffer;
  53112. /** @hidden */
  53113. _rebuild(): void;
  53114. /**
  53115. * Renders the layer in the scene.
  53116. */
  53117. render(): void;
  53118. /**
  53119. * Disposes and releases the associated ressources.
  53120. */
  53121. dispose(): void;
  53122. }
  53123. }
  53124. declare module "babylonjs/Layers/index" {
  53125. export * from "babylonjs/Layers/effectLayer";
  53126. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53127. export * from "babylonjs/Layers/glowLayer";
  53128. export * from "babylonjs/Layers/highlightLayer";
  53129. export * from "babylonjs/Layers/layer";
  53130. export * from "babylonjs/Layers/layerSceneComponent";
  53131. }
  53132. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53133. /** @hidden */
  53134. export var lensFlarePixelShader: {
  53135. name: string;
  53136. shader: string;
  53137. };
  53138. }
  53139. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53140. /** @hidden */
  53141. export var lensFlareVertexShader: {
  53142. name: string;
  53143. shader: string;
  53144. };
  53145. }
  53146. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53147. import { Scene } from "babylonjs/scene";
  53148. import { Vector3 } from "babylonjs/Maths/math.vector";
  53149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53150. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53151. import "babylonjs/Shaders/lensFlare.fragment";
  53152. import "babylonjs/Shaders/lensFlare.vertex";
  53153. import { Viewport } from "babylonjs/Maths/math.viewport";
  53154. /**
  53155. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53156. * It is usually composed of several `lensFlare`.
  53157. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53158. */
  53159. export class LensFlareSystem {
  53160. /**
  53161. * Define the name of the lens flare system
  53162. */
  53163. name: string;
  53164. /**
  53165. * List of lens flares used in this system.
  53166. */
  53167. lensFlares: LensFlare[];
  53168. /**
  53169. * Define a limit from the border the lens flare can be visible.
  53170. */
  53171. borderLimit: number;
  53172. /**
  53173. * Define a viewport border we do not want to see the lens flare in.
  53174. */
  53175. viewportBorder: number;
  53176. /**
  53177. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53178. */
  53179. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53180. /**
  53181. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53182. */
  53183. layerMask: number;
  53184. /**
  53185. * Define the id of the lens flare system in the scene.
  53186. * (equal to name by default)
  53187. */
  53188. id: string;
  53189. private _scene;
  53190. private _emitter;
  53191. private _vertexBuffers;
  53192. private _indexBuffer;
  53193. private _effect;
  53194. private _positionX;
  53195. private _positionY;
  53196. private _isEnabled;
  53197. /** @hidden */
  53198. static _SceneComponentInitialization: (scene: Scene) => void;
  53199. /**
  53200. * Instantiates a lens flare system.
  53201. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53202. * It is usually composed of several `lensFlare`.
  53203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53204. * @param name Define the name of the lens flare system in the scene
  53205. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53206. * @param scene Define the scene the lens flare system belongs to
  53207. */
  53208. constructor(
  53209. /**
  53210. * Define the name of the lens flare system
  53211. */
  53212. name: string, emitter: any, scene: Scene);
  53213. /**
  53214. * Define if the lens flare system is enabled.
  53215. */
  53216. isEnabled: boolean;
  53217. /**
  53218. * Get the scene the effects belongs to.
  53219. * @returns the scene holding the lens flare system
  53220. */
  53221. getScene(): Scene;
  53222. /**
  53223. * Get the emitter of the lens flare system.
  53224. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53225. * @returns the emitter of the lens flare system
  53226. */
  53227. getEmitter(): any;
  53228. /**
  53229. * Set the emitter of the lens flare system.
  53230. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53231. * @param newEmitter Define the new emitter of the system
  53232. */
  53233. setEmitter(newEmitter: any): void;
  53234. /**
  53235. * Get the lens flare system emitter position.
  53236. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53237. * @returns the position
  53238. */
  53239. getEmitterPosition(): Vector3;
  53240. /**
  53241. * @hidden
  53242. */
  53243. computeEffectivePosition(globalViewport: Viewport): boolean;
  53244. /** @hidden */
  53245. _isVisible(): boolean;
  53246. /**
  53247. * @hidden
  53248. */
  53249. render(): boolean;
  53250. /**
  53251. * Dispose and release the lens flare with its associated resources.
  53252. */
  53253. dispose(): void;
  53254. /**
  53255. * Parse a lens flare system from a JSON repressentation
  53256. * @param parsedLensFlareSystem Define the JSON to parse
  53257. * @param scene Define the scene the parsed system should be instantiated in
  53258. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53259. * @returns the parsed system
  53260. */
  53261. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53262. /**
  53263. * Serialize the current Lens Flare System into a JSON representation.
  53264. * @returns the serialized JSON
  53265. */
  53266. serialize(): any;
  53267. }
  53268. }
  53269. declare module "babylonjs/LensFlares/lensFlare" {
  53270. import { Nullable } from "babylonjs/types";
  53271. import { Color3 } from "babylonjs/Maths/math.color";
  53272. import { Texture } from "babylonjs/Materials/Textures/texture";
  53273. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53274. /**
  53275. * This represents one of the lens effect in a `lensFlareSystem`.
  53276. * It controls one of the indiviual texture used in the effect.
  53277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53278. */
  53279. export class LensFlare {
  53280. /**
  53281. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53282. */
  53283. size: number;
  53284. /**
  53285. * 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.
  53286. */
  53287. position: number;
  53288. /**
  53289. * Define the lens color.
  53290. */
  53291. color: Color3;
  53292. /**
  53293. * Define the lens texture.
  53294. */
  53295. texture: Nullable<Texture>;
  53296. /**
  53297. * Define the alpha mode to render this particular lens.
  53298. */
  53299. alphaMode: number;
  53300. private _system;
  53301. /**
  53302. * Creates a new Lens Flare.
  53303. * This represents one of the lens effect in a `lensFlareSystem`.
  53304. * It controls one of the indiviual texture used in the effect.
  53305. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53306. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53307. * @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.
  53308. * @param color Define the lens color
  53309. * @param imgUrl Define the lens texture url
  53310. * @param system Define the `lensFlareSystem` this flare is part of
  53311. * @returns The newly created Lens Flare
  53312. */
  53313. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53314. /**
  53315. * Instantiates a new Lens Flare.
  53316. * This represents one of the lens effect in a `lensFlareSystem`.
  53317. * It controls one of the indiviual texture used in the effect.
  53318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53319. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53320. * @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.
  53321. * @param color Define the lens color
  53322. * @param imgUrl Define the lens texture url
  53323. * @param system Define the `lensFlareSystem` this flare is part of
  53324. */
  53325. constructor(
  53326. /**
  53327. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53328. */
  53329. size: number,
  53330. /**
  53331. * 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.
  53332. */
  53333. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53334. /**
  53335. * Dispose and release the lens flare with its associated resources.
  53336. */
  53337. dispose(): void;
  53338. }
  53339. }
  53340. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53341. import { Nullable } from "babylonjs/types";
  53342. import { Scene } from "babylonjs/scene";
  53343. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53344. import { AbstractScene } from "babylonjs/abstractScene";
  53345. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53346. module "babylonjs/abstractScene" {
  53347. interface AbstractScene {
  53348. /**
  53349. * The list of lens flare system added to the scene
  53350. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53351. */
  53352. lensFlareSystems: Array<LensFlareSystem>;
  53353. /**
  53354. * Removes the given lens flare system from this scene.
  53355. * @param toRemove The lens flare system to remove
  53356. * @returns The index of the removed lens flare system
  53357. */
  53358. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53359. /**
  53360. * Adds the given lens flare system to this scene
  53361. * @param newLensFlareSystem The lens flare system to add
  53362. */
  53363. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53364. /**
  53365. * Gets a lens flare system using its name
  53366. * @param name defines the name to look for
  53367. * @returns the lens flare system or null if not found
  53368. */
  53369. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53370. /**
  53371. * Gets a lens flare system using its id
  53372. * @param id defines the id to look for
  53373. * @returns the lens flare system or null if not found
  53374. */
  53375. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53376. }
  53377. }
  53378. /**
  53379. * Defines the lens flare scene component responsible to manage any lens flares
  53380. * in a given scene.
  53381. */
  53382. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53383. /**
  53384. * The component name helpfull to identify the component in the list of scene components.
  53385. */
  53386. readonly name: string;
  53387. /**
  53388. * The scene the component belongs to.
  53389. */
  53390. scene: Scene;
  53391. /**
  53392. * Creates a new instance of the component for the given scene
  53393. * @param scene Defines the scene to register the component in
  53394. */
  53395. constructor(scene: Scene);
  53396. /**
  53397. * Registers the component in a given scene
  53398. */
  53399. register(): void;
  53400. /**
  53401. * Rebuilds the elements related to this component in case of
  53402. * context lost for instance.
  53403. */
  53404. rebuild(): void;
  53405. /**
  53406. * Adds all the elements from the container to the scene
  53407. * @param container the container holding the elements
  53408. */
  53409. addFromContainer(container: AbstractScene): void;
  53410. /**
  53411. * Removes all the elements in the container from the scene
  53412. * @param container contains the elements to remove
  53413. * @param dispose if the removed element should be disposed (default: false)
  53414. */
  53415. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53416. /**
  53417. * Serializes the component data to the specified json object
  53418. * @param serializationObject The object to serialize to
  53419. */
  53420. serialize(serializationObject: any): void;
  53421. /**
  53422. * Disposes the component and the associated ressources.
  53423. */
  53424. dispose(): void;
  53425. private _draw;
  53426. }
  53427. }
  53428. declare module "babylonjs/LensFlares/index" {
  53429. export * from "babylonjs/LensFlares/lensFlare";
  53430. export * from "babylonjs/LensFlares/lensFlareSystem";
  53431. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53432. }
  53433. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53434. import { Scene } from "babylonjs/scene";
  53435. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53436. import { AbstractScene } from "babylonjs/abstractScene";
  53437. /**
  53438. * Defines the shadow generator component responsible to manage any shadow generators
  53439. * in a given scene.
  53440. */
  53441. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53442. /**
  53443. * The component name helpfull to identify the component in the list of scene components.
  53444. */
  53445. readonly name: string;
  53446. /**
  53447. * The scene the component belongs to.
  53448. */
  53449. scene: Scene;
  53450. /**
  53451. * Creates a new instance of the component for the given scene
  53452. * @param scene Defines the scene to register the component in
  53453. */
  53454. constructor(scene: Scene);
  53455. /**
  53456. * Registers the component in a given scene
  53457. */
  53458. register(): void;
  53459. /**
  53460. * Rebuilds the elements related to this component in case of
  53461. * context lost for instance.
  53462. */
  53463. rebuild(): void;
  53464. /**
  53465. * Serializes the component data to the specified json object
  53466. * @param serializationObject The object to serialize to
  53467. */
  53468. serialize(serializationObject: any): void;
  53469. /**
  53470. * Adds all the elements from the container to the scene
  53471. * @param container the container holding the elements
  53472. */
  53473. addFromContainer(container: AbstractScene): void;
  53474. /**
  53475. * Removes all the elements in the container from the scene
  53476. * @param container contains the elements to remove
  53477. * @param dispose if the removed element should be disposed (default: false)
  53478. */
  53479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53480. /**
  53481. * Rebuilds the elements related to this component in case of
  53482. * context lost for instance.
  53483. */
  53484. dispose(): void;
  53485. private _gatherRenderTargets;
  53486. }
  53487. }
  53488. declare module "babylonjs/Lights/Shadows/index" {
  53489. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53490. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53491. }
  53492. declare module "babylonjs/Lights/pointLight" {
  53493. import { Scene } from "babylonjs/scene";
  53494. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53496. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53497. import { Effect } from "babylonjs/Materials/effect";
  53498. /**
  53499. * A point light is a light defined by an unique point in world space.
  53500. * The light is emitted in every direction from this point.
  53501. * A good example of a point light is a standard light bulb.
  53502. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53503. */
  53504. export class PointLight extends ShadowLight {
  53505. private _shadowAngle;
  53506. /**
  53507. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53508. * This specifies what angle the shadow will use to be created.
  53509. *
  53510. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53511. */
  53512. /**
  53513. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53514. * This specifies what angle the shadow will use to be created.
  53515. *
  53516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53517. */
  53518. shadowAngle: number;
  53519. /**
  53520. * Gets the direction if it has been set.
  53521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53522. */
  53523. /**
  53524. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53525. */
  53526. direction: Vector3;
  53527. /**
  53528. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53529. * A PointLight emits the light in every direction.
  53530. * It can cast shadows.
  53531. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53532. * ```javascript
  53533. * var pointLight = new PointLight("pl", camera.position, scene);
  53534. * ```
  53535. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53536. * @param name The light friendly name
  53537. * @param position The position of the point light in the scene
  53538. * @param scene The scene the lights belongs to
  53539. */
  53540. constructor(name: string, position: Vector3, scene: Scene);
  53541. /**
  53542. * Returns the string "PointLight"
  53543. * @returns the class name
  53544. */
  53545. getClassName(): string;
  53546. /**
  53547. * Returns the integer 0.
  53548. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53549. */
  53550. getTypeID(): number;
  53551. /**
  53552. * Specifies wether or not the shadowmap should be a cube texture.
  53553. * @returns true if the shadowmap needs to be a cube texture.
  53554. */
  53555. needCube(): boolean;
  53556. /**
  53557. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53558. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53559. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53560. */
  53561. getShadowDirection(faceIndex?: number): Vector3;
  53562. /**
  53563. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53564. * - fov = PI / 2
  53565. * - aspect ratio : 1.0
  53566. * - z-near and far equal to the active camera minZ and maxZ.
  53567. * Returns the PointLight.
  53568. */
  53569. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53570. protected _buildUniformLayout(): void;
  53571. /**
  53572. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53573. * @param effect The effect to update
  53574. * @param lightIndex The index of the light in the effect to update
  53575. * @returns The point light
  53576. */
  53577. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53578. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53579. /**
  53580. * Prepares the list of defines specific to the light type.
  53581. * @param defines the list of defines
  53582. * @param lightIndex defines the index of the light for the effect
  53583. */
  53584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53585. }
  53586. }
  53587. declare module "babylonjs/Lights/index" {
  53588. export * from "babylonjs/Lights/light";
  53589. export * from "babylonjs/Lights/shadowLight";
  53590. export * from "babylonjs/Lights/Shadows/index";
  53591. export * from "babylonjs/Lights/directionalLight";
  53592. export * from "babylonjs/Lights/hemisphericLight";
  53593. export * from "babylonjs/Lights/pointLight";
  53594. export * from "babylonjs/Lights/spotLight";
  53595. }
  53596. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53597. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53598. /**
  53599. * Header information of HDR texture files.
  53600. */
  53601. export interface HDRInfo {
  53602. /**
  53603. * The height of the texture in pixels.
  53604. */
  53605. height: number;
  53606. /**
  53607. * The width of the texture in pixels.
  53608. */
  53609. width: number;
  53610. /**
  53611. * The index of the beginning of the data in the binary file.
  53612. */
  53613. dataPosition: number;
  53614. }
  53615. /**
  53616. * This groups tools to convert HDR texture to native colors array.
  53617. */
  53618. export class HDRTools {
  53619. private static Ldexp;
  53620. private static Rgbe2float;
  53621. private static readStringLine;
  53622. /**
  53623. * Reads header information from an RGBE texture stored in a native array.
  53624. * More information on this format are available here:
  53625. * https://en.wikipedia.org/wiki/RGBE_image_format
  53626. *
  53627. * @param uint8array The binary file stored in native array.
  53628. * @return The header information.
  53629. */
  53630. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53631. /**
  53632. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53633. * This RGBE texture needs to store the information as a panorama.
  53634. *
  53635. * More information on this format are available here:
  53636. * https://en.wikipedia.org/wiki/RGBE_image_format
  53637. *
  53638. * @param buffer The binary file stored in an array buffer.
  53639. * @param size The expected size of the extracted cubemap.
  53640. * @return The Cube Map information.
  53641. */
  53642. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53643. /**
  53644. * Returns the pixels data extracted from an RGBE texture.
  53645. * This pixels will be stored left to right up to down in the R G B order in one array.
  53646. *
  53647. * More information on this format are available here:
  53648. * https://en.wikipedia.org/wiki/RGBE_image_format
  53649. *
  53650. * @param uint8array The binary file stored in an array buffer.
  53651. * @param hdrInfo The header information of the file.
  53652. * @return The pixels data in RGB right to left up to down order.
  53653. */
  53654. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53655. private static RGBE_ReadPixels_RLE;
  53656. }
  53657. }
  53658. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53659. import { Nullable } from "babylonjs/types";
  53660. import { Scene } from "babylonjs/scene";
  53661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53663. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53664. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53665. /**
  53666. * This represents a texture coming from an HDR input.
  53667. *
  53668. * The only supported format is currently panorama picture stored in RGBE format.
  53669. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53670. */
  53671. export class HDRCubeTexture extends BaseTexture {
  53672. private static _facesMapping;
  53673. private _generateHarmonics;
  53674. private _noMipmap;
  53675. private _textureMatrix;
  53676. private _size;
  53677. private _onLoad;
  53678. private _onError;
  53679. /**
  53680. * The texture URL.
  53681. */
  53682. url: string;
  53683. /**
  53684. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53685. */
  53686. coordinatesMode: number;
  53687. protected _isBlocking: boolean;
  53688. /**
  53689. * Sets wether or not the texture is blocking during loading.
  53690. */
  53691. /**
  53692. * Gets wether or not the texture is blocking during loading.
  53693. */
  53694. isBlocking: boolean;
  53695. protected _rotationY: number;
  53696. /**
  53697. * Sets texture matrix rotation angle around Y axis in radians.
  53698. */
  53699. /**
  53700. * Gets texture matrix rotation angle around Y axis radians.
  53701. */
  53702. rotationY: number;
  53703. /**
  53704. * Gets or sets the center of the bounding box associated with the cube texture
  53705. * It must define where the camera used to render the texture was set
  53706. */
  53707. boundingBoxPosition: Vector3;
  53708. private _boundingBoxSize;
  53709. /**
  53710. * Gets or sets the size of the bounding box associated with the cube texture
  53711. * When defined, the cubemap will switch to local mode
  53712. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53713. * @example https://www.babylonjs-playground.com/#RNASML
  53714. */
  53715. boundingBoxSize: Vector3;
  53716. /**
  53717. * Instantiates an HDRTexture from the following parameters.
  53718. *
  53719. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53720. * @param scene The scene the texture will be used in
  53721. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53722. * @param noMipmap Forces to not generate the mipmap if true
  53723. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53724. * @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)
  53725. * @param reserved Reserved flag for internal use.
  53726. */
  53727. 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>);
  53728. /**
  53729. * Get the current class name of the texture useful for serialization or dynamic coding.
  53730. * @returns "HDRCubeTexture"
  53731. */
  53732. getClassName(): string;
  53733. /**
  53734. * Occurs when the file is raw .hdr file.
  53735. */
  53736. private loadTexture;
  53737. clone(): HDRCubeTexture;
  53738. delayLoad(): void;
  53739. /**
  53740. * Get the texture reflection matrix used to rotate/transform the reflection.
  53741. * @returns the reflection matrix
  53742. */
  53743. getReflectionTextureMatrix(): Matrix;
  53744. /**
  53745. * Set the texture reflection matrix used to rotate/transform the reflection.
  53746. * @param value Define the reflection matrix to set
  53747. */
  53748. setReflectionTextureMatrix(value: Matrix): void;
  53749. /**
  53750. * Parses a JSON representation of an HDR Texture in order to create the texture
  53751. * @param parsedTexture Define the JSON representation
  53752. * @param scene Define the scene the texture should be created in
  53753. * @param rootUrl Define the root url in case we need to load relative dependencies
  53754. * @returns the newly created texture after parsing
  53755. */
  53756. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53757. serialize(): any;
  53758. }
  53759. }
  53760. declare module "babylonjs/Physics/physicsEngine" {
  53761. import { Nullable } from "babylonjs/types";
  53762. import { Vector3 } from "babylonjs/Maths/math.vector";
  53763. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53764. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53765. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53766. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53767. /**
  53768. * Class used to control physics engine
  53769. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53770. */
  53771. export class PhysicsEngine implements IPhysicsEngine {
  53772. private _physicsPlugin;
  53773. /**
  53774. * Global value used to control the smallest number supported by the simulation
  53775. */
  53776. static Epsilon: number;
  53777. private _impostors;
  53778. private _joints;
  53779. /**
  53780. * Gets the gravity vector used by the simulation
  53781. */
  53782. gravity: Vector3;
  53783. /**
  53784. * Factory used to create the default physics plugin.
  53785. * @returns The default physics plugin
  53786. */
  53787. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53788. /**
  53789. * Creates a new Physics Engine
  53790. * @param gravity defines the gravity vector used by the simulation
  53791. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53792. */
  53793. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53794. /**
  53795. * Sets the gravity vector used by the simulation
  53796. * @param gravity defines the gravity vector to use
  53797. */
  53798. setGravity(gravity: Vector3): void;
  53799. /**
  53800. * Set the time step of the physics engine.
  53801. * Default is 1/60.
  53802. * To slow it down, enter 1/600 for example.
  53803. * To speed it up, 1/30
  53804. * @param newTimeStep defines the new timestep to apply to this world.
  53805. */
  53806. setTimeStep(newTimeStep?: number): void;
  53807. /**
  53808. * Get the time step of the physics engine.
  53809. * @returns the current time step
  53810. */
  53811. getTimeStep(): number;
  53812. /**
  53813. * Release all resources
  53814. */
  53815. dispose(): void;
  53816. /**
  53817. * Gets the name of the current physics plugin
  53818. * @returns the name of the plugin
  53819. */
  53820. getPhysicsPluginName(): string;
  53821. /**
  53822. * Adding a new impostor for the impostor tracking.
  53823. * This will be done by the impostor itself.
  53824. * @param impostor the impostor to add
  53825. */
  53826. addImpostor(impostor: PhysicsImpostor): void;
  53827. /**
  53828. * Remove an impostor from the engine.
  53829. * This impostor and its mesh will not longer be updated by the physics engine.
  53830. * @param impostor the impostor to remove
  53831. */
  53832. removeImpostor(impostor: PhysicsImpostor): void;
  53833. /**
  53834. * Add a joint to the physics engine
  53835. * @param mainImpostor defines the main impostor to which the joint is added.
  53836. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53837. * @param joint defines the joint that will connect both impostors.
  53838. */
  53839. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53840. /**
  53841. * Removes a joint from the simulation
  53842. * @param mainImpostor defines the impostor used with the joint
  53843. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53844. * @param joint defines the joint to remove
  53845. */
  53846. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53847. /**
  53848. * Called by the scene. No need to call it.
  53849. * @param delta defines the timespam between frames
  53850. */
  53851. _step(delta: number): void;
  53852. /**
  53853. * Gets the current plugin used to run the simulation
  53854. * @returns current plugin
  53855. */
  53856. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53857. /**
  53858. * Gets the list of physic impostors
  53859. * @returns an array of PhysicsImpostor
  53860. */
  53861. getImpostors(): Array<PhysicsImpostor>;
  53862. /**
  53863. * Gets the impostor for a physics enabled object
  53864. * @param object defines the object impersonated by the impostor
  53865. * @returns the PhysicsImpostor or null if not found
  53866. */
  53867. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53868. /**
  53869. * Gets the impostor for a physics body object
  53870. * @param body defines physics body used by the impostor
  53871. * @returns the PhysicsImpostor or null if not found
  53872. */
  53873. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53874. /**
  53875. * Does a raycast in the physics world
  53876. * @param from when should the ray start?
  53877. * @param to when should the ray end?
  53878. * @returns PhysicsRaycastResult
  53879. */
  53880. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53881. }
  53882. }
  53883. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53884. import { Nullable } from "babylonjs/types";
  53885. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53887. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53888. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53889. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53890. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53891. /** @hidden */
  53892. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53893. private _useDeltaForWorldStep;
  53894. world: any;
  53895. name: string;
  53896. private _physicsMaterials;
  53897. private _fixedTimeStep;
  53898. private _cannonRaycastResult;
  53899. private _raycastResult;
  53900. private _physicsBodysToRemoveAfterStep;
  53901. BJSCANNON: any;
  53902. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53903. setGravity(gravity: Vector3): void;
  53904. setTimeStep(timeStep: number): void;
  53905. getTimeStep(): number;
  53906. executeStep(delta: number): void;
  53907. private _removeMarkedPhysicsBodiesFromWorld;
  53908. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53909. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53910. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53911. private _processChildMeshes;
  53912. removePhysicsBody(impostor: PhysicsImpostor): void;
  53913. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53914. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53915. private _addMaterial;
  53916. private _checkWithEpsilon;
  53917. private _createShape;
  53918. private _createHeightmap;
  53919. private _minus90X;
  53920. private _plus90X;
  53921. private _tmpPosition;
  53922. private _tmpDeltaPosition;
  53923. private _tmpUnityRotation;
  53924. private _updatePhysicsBodyTransformation;
  53925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53927. isSupported(): boolean;
  53928. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53929. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53930. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53931. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53932. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53933. getBodyMass(impostor: PhysicsImpostor): number;
  53934. getBodyFriction(impostor: PhysicsImpostor): number;
  53935. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53936. getBodyRestitution(impostor: PhysicsImpostor): number;
  53937. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53938. sleepBody(impostor: PhysicsImpostor): void;
  53939. wakeUpBody(impostor: PhysicsImpostor): void;
  53940. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53941. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53942. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53943. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53944. getRadius(impostor: PhysicsImpostor): number;
  53945. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53946. dispose(): void;
  53947. private _extendNamespace;
  53948. /**
  53949. * Does a raycast in the physics world
  53950. * @param from when should the ray start?
  53951. * @param to when should the ray end?
  53952. * @returns PhysicsRaycastResult
  53953. */
  53954. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53955. }
  53956. }
  53957. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53958. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53959. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53960. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53962. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53963. import { Nullable } from "babylonjs/types";
  53964. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53965. /** @hidden */
  53966. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53967. world: any;
  53968. name: string;
  53969. BJSOIMO: any;
  53970. private _raycastResult;
  53971. constructor(iterations?: number, oimoInjection?: any);
  53972. setGravity(gravity: Vector3): void;
  53973. setTimeStep(timeStep: number): void;
  53974. getTimeStep(): number;
  53975. private _tmpImpostorsArray;
  53976. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53977. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53979. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53980. private _tmpPositionVector;
  53981. removePhysicsBody(impostor: PhysicsImpostor): void;
  53982. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53983. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53984. isSupported(): boolean;
  53985. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53986. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53987. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53988. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53989. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53990. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53992. getBodyMass(impostor: PhysicsImpostor): number;
  53993. getBodyFriction(impostor: PhysicsImpostor): number;
  53994. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53995. getBodyRestitution(impostor: PhysicsImpostor): number;
  53996. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53997. sleepBody(impostor: PhysicsImpostor): void;
  53998. wakeUpBody(impostor: PhysicsImpostor): void;
  53999. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54000. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54002. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54003. getRadius(impostor: PhysicsImpostor): number;
  54004. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54005. dispose(): void;
  54006. /**
  54007. * Does a raycast in the physics world
  54008. * @param from when should the ray start?
  54009. * @param to when should the ray end?
  54010. * @returns PhysicsRaycastResult
  54011. */
  54012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54013. }
  54014. }
  54015. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54016. import { Nullable } from "babylonjs/types";
  54017. import { Scene } from "babylonjs/scene";
  54018. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54019. import { Color4 } from "babylonjs/Maths/math.color";
  54020. import { Mesh } from "babylonjs/Meshes/mesh";
  54021. /**
  54022. * Class containing static functions to help procedurally build meshes
  54023. */
  54024. export class RibbonBuilder {
  54025. /**
  54026. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54027. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54028. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54029. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54030. * * 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
  54031. * * 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
  54032. * * 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
  54033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54036. * * 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
  54037. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54038. * * 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
  54039. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54041. * @param name defines the name of the mesh
  54042. * @param options defines the options used to create the mesh
  54043. * @param scene defines the hosting scene
  54044. * @returns the ribbon mesh
  54045. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54046. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54047. */
  54048. static CreateRibbon(name: string, options: {
  54049. pathArray: Vector3[][];
  54050. closeArray?: boolean;
  54051. closePath?: boolean;
  54052. offset?: number;
  54053. updatable?: boolean;
  54054. sideOrientation?: number;
  54055. frontUVs?: Vector4;
  54056. backUVs?: Vector4;
  54057. instance?: Mesh;
  54058. invertUV?: boolean;
  54059. uvs?: Vector2[];
  54060. colors?: Color4[];
  54061. }, scene?: Nullable<Scene>): Mesh;
  54062. }
  54063. }
  54064. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54065. import { Nullable } from "babylonjs/types";
  54066. import { Scene } from "babylonjs/scene";
  54067. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54068. import { Mesh } from "babylonjs/Meshes/mesh";
  54069. /**
  54070. * Class containing static functions to help procedurally build meshes
  54071. */
  54072. export class ShapeBuilder {
  54073. /**
  54074. * 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.
  54075. * * 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.
  54076. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54077. * * 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.
  54078. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54079. * * 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
  54080. * * 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
  54081. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54086. * @param name defines the name of the mesh
  54087. * @param options defines the options used to create the mesh
  54088. * @param scene defines the hosting scene
  54089. * @returns the extruded shape mesh
  54090. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54092. */
  54093. static ExtrudeShape(name: string, options: {
  54094. shape: Vector3[];
  54095. path: Vector3[];
  54096. scale?: number;
  54097. rotation?: number;
  54098. cap?: number;
  54099. updatable?: boolean;
  54100. sideOrientation?: number;
  54101. frontUVs?: Vector4;
  54102. backUVs?: Vector4;
  54103. instance?: Mesh;
  54104. invertUV?: boolean;
  54105. }, scene?: Nullable<Scene>): Mesh;
  54106. /**
  54107. * Creates an custom extruded shape mesh.
  54108. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54109. * * 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.
  54110. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54111. * * 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
  54112. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54113. * * 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
  54114. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54115. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54116. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54117. * * 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
  54118. * * 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
  54119. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54122. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54124. * @param name defines the name of the mesh
  54125. * @param options defines the options used to create the mesh
  54126. * @param scene defines the hosting scene
  54127. * @returns the custom extruded shape mesh
  54128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54129. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54131. */
  54132. static ExtrudeShapeCustom(name: string, options: {
  54133. shape: Vector3[];
  54134. path: Vector3[];
  54135. scaleFunction?: any;
  54136. rotationFunction?: any;
  54137. ribbonCloseArray?: boolean;
  54138. ribbonClosePath?: boolean;
  54139. cap?: number;
  54140. updatable?: boolean;
  54141. sideOrientation?: number;
  54142. frontUVs?: Vector4;
  54143. backUVs?: Vector4;
  54144. instance?: Mesh;
  54145. invertUV?: boolean;
  54146. }, scene?: Nullable<Scene>): Mesh;
  54147. private static _ExtrudeShapeGeneric;
  54148. }
  54149. }
  54150. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54151. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54152. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54153. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54154. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54155. import { Nullable } from "babylonjs/types";
  54156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54157. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54158. /**
  54159. * AmmoJS Physics plugin
  54160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54161. * @see https://github.com/kripken/ammo.js/
  54162. */
  54163. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54164. private _useDeltaForWorldStep;
  54165. /**
  54166. * Reference to the Ammo library
  54167. */
  54168. bjsAMMO: any;
  54169. /**
  54170. * Created ammoJS world which physics bodies are added to
  54171. */
  54172. world: any;
  54173. /**
  54174. * Name of the plugin
  54175. */
  54176. name: string;
  54177. private _timeStep;
  54178. private _fixedTimeStep;
  54179. private _maxSteps;
  54180. private _tmpQuaternion;
  54181. private _tmpAmmoTransform;
  54182. private _tmpAmmoQuaternion;
  54183. private _tmpAmmoConcreteContactResultCallback;
  54184. private _collisionConfiguration;
  54185. private _dispatcher;
  54186. private _overlappingPairCache;
  54187. private _solver;
  54188. private _softBodySolver;
  54189. private _tmpAmmoVectorA;
  54190. private _tmpAmmoVectorB;
  54191. private _tmpAmmoVectorC;
  54192. private _tmpAmmoVectorD;
  54193. private _tmpContactCallbackResult;
  54194. private _tmpAmmoVectorRCA;
  54195. private _tmpAmmoVectorRCB;
  54196. private _raycastResult;
  54197. private static readonly DISABLE_COLLISION_FLAG;
  54198. private static readonly KINEMATIC_FLAG;
  54199. private static readonly DISABLE_DEACTIVATION_FLAG;
  54200. /**
  54201. * Initializes the ammoJS plugin
  54202. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54203. * @param ammoInjection can be used to inject your own ammo reference
  54204. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54205. */
  54206. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54207. /**
  54208. * Sets the gravity of the physics world (m/(s^2))
  54209. * @param gravity Gravity to set
  54210. */
  54211. setGravity(gravity: Vector3): void;
  54212. /**
  54213. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54214. * @param timeStep timestep to use in seconds
  54215. */
  54216. setTimeStep(timeStep: number): void;
  54217. /**
  54218. * 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)
  54219. * @param fixedTimeStep fixedTimeStep to use in seconds
  54220. */
  54221. setFixedTimeStep(fixedTimeStep: number): void;
  54222. /**
  54223. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54224. * @param maxSteps the maximum number of steps by the physics engine per frame
  54225. */
  54226. setMaxSteps(maxSteps: number): void;
  54227. /**
  54228. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54229. * @returns the current timestep in seconds
  54230. */
  54231. getTimeStep(): number;
  54232. private _isImpostorInContact;
  54233. private _isImpostorPairInContact;
  54234. private _stepSimulation;
  54235. /**
  54236. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54237. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54238. * After the step the babylon meshes are set to the position of the physics imposters
  54239. * @param delta amount of time to step forward
  54240. * @param impostors array of imposters to update before/after the step
  54241. */
  54242. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54243. /**
  54244. * Update babylon mesh to match physics world object
  54245. * @param impostor imposter to match
  54246. */
  54247. private _afterSoftStep;
  54248. /**
  54249. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54250. * @param impostor imposter to match
  54251. */
  54252. private _ropeStep;
  54253. /**
  54254. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54255. * @param impostor imposter to match
  54256. */
  54257. private _softbodyOrClothStep;
  54258. private _tmpVector;
  54259. private _tmpMatrix;
  54260. /**
  54261. * Applies an impulse on the imposter
  54262. * @param impostor imposter to apply impulse to
  54263. * @param force amount of force to be applied to the imposter
  54264. * @param contactPoint the location to apply the impulse on the imposter
  54265. */
  54266. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54267. /**
  54268. * Applies a force on the imposter
  54269. * @param impostor imposter to apply force
  54270. * @param force amount of force to be applied to the imposter
  54271. * @param contactPoint the location to apply the force on the imposter
  54272. */
  54273. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54274. /**
  54275. * Creates a physics body using the plugin
  54276. * @param impostor the imposter to create the physics body on
  54277. */
  54278. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54279. /**
  54280. * Removes the physics body from the imposter and disposes of the body's memory
  54281. * @param impostor imposter to remove the physics body from
  54282. */
  54283. removePhysicsBody(impostor: PhysicsImpostor): void;
  54284. /**
  54285. * Generates a joint
  54286. * @param impostorJoint the imposter joint to create the joint with
  54287. */
  54288. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54289. /**
  54290. * Removes a joint
  54291. * @param impostorJoint the imposter joint to remove the joint from
  54292. */
  54293. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54294. private _addMeshVerts;
  54295. /**
  54296. * Initialise the soft body vertices to match its object's (mesh) vertices
  54297. * Softbody vertices (nodes) are in world space and to match this
  54298. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54299. * @param impostor to create the softbody for
  54300. */
  54301. private _softVertexData;
  54302. /**
  54303. * Create an impostor's soft body
  54304. * @param impostor to create the softbody for
  54305. */
  54306. private _createSoftbody;
  54307. /**
  54308. * Create cloth for an impostor
  54309. * @param impostor to create the softbody for
  54310. */
  54311. private _createCloth;
  54312. /**
  54313. * Create rope for an impostor
  54314. * @param impostor to create the softbody for
  54315. */
  54316. private _createRope;
  54317. private _addHullVerts;
  54318. private _createShape;
  54319. /**
  54320. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54321. * @param impostor imposter containing the physics body and babylon object
  54322. */
  54323. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54324. /**
  54325. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54326. * @param impostor imposter containing the physics body and babylon object
  54327. * @param newPosition new position
  54328. * @param newRotation new rotation
  54329. */
  54330. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54331. /**
  54332. * If this plugin is supported
  54333. * @returns true if its supported
  54334. */
  54335. isSupported(): boolean;
  54336. /**
  54337. * Sets the linear velocity of the physics body
  54338. * @param impostor imposter to set the velocity on
  54339. * @param velocity velocity to set
  54340. */
  54341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54342. /**
  54343. * Sets the angular velocity of the physics body
  54344. * @param impostor imposter to set the velocity on
  54345. * @param velocity velocity to set
  54346. */
  54347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54348. /**
  54349. * gets the linear velocity
  54350. * @param impostor imposter to get linear velocity from
  54351. * @returns linear velocity
  54352. */
  54353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54354. /**
  54355. * gets the angular velocity
  54356. * @param impostor imposter to get angular velocity from
  54357. * @returns angular velocity
  54358. */
  54359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54360. /**
  54361. * Sets the mass of physics body
  54362. * @param impostor imposter to set the mass on
  54363. * @param mass mass to set
  54364. */
  54365. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54366. /**
  54367. * Gets the mass of the physics body
  54368. * @param impostor imposter to get the mass from
  54369. * @returns mass
  54370. */
  54371. getBodyMass(impostor: PhysicsImpostor): number;
  54372. /**
  54373. * Gets friction of the impostor
  54374. * @param impostor impostor to get friction from
  54375. * @returns friction value
  54376. */
  54377. getBodyFriction(impostor: PhysicsImpostor): number;
  54378. /**
  54379. * Sets friction of the impostor
  54380. * @param impostor impostor to set friction on
  54381. * @param friction friction value
  54382. */
  54383. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54384. /**
  54385. * Gets restitution of the impostor
  54386. * @param impostor impostor to get restitution from
  54387. * @returns restitution value
  54388. */
  54389. getBodyRestitution(impostor: PhysicsImpostor): number;
  54390. /**
  54391. * Sets resitution of the impostor
  54392. * @param impostor impostor to set resitution on
  54393. * @param restitution resitution value
  54394. */
  54395. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54396. /**
  54397. * Gets pressure inside the impostor
  54398. * @param impostor impostor to get pressure from
  54399. * @returns pressure value
  54400. */
  54401. getBodyPressure(impostor: PhysicsImpostor): number;
  54402. /**
  54403. * Sets pressure inside a soft body impostor
  54404. * Cloth and rope must remain 0 pressure
  54405. * @param impostor impostor to set pressure on
  54406. * @param pressure pressure value
  54407. */
  54408. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54409. /**
  54410. * Gets stiffness of the impostor
  54411. * @param impostor impostor to get stiffness from
  54412. * @returns pressure value
  54413. */
  54414. getBodyStiffness(impostor: PhysicsImpostor): number;
  54415. /**
  54416. * Sets stiffness of the impostor
  54417. * @param impostor impostor to set stiffness on
  54418. * @param stiffness stiffness value from 0 to 1
  54419. */
  54420. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54421. /**
  54422. * Gets velocityIterations of the impostor
  54423. * @param impostor impostor to get velocity iterations from
  54424. * @returns velocityIterations value
  54425. */
  54426. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54427. /**
  54428. * Sets velocityIterations of the impostor
  54429. * @param impostor impostor to set velocity iterations on
  54430. * @param velocityIterations velocityIterations value
  54431. */
  54432. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54433. /**
  54434. * Gets positionIterations of the impostor
  54435. * @param impostor impostor to get position iterations from
  54436. * @returns positionIterations value
  54437. */
  54438. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54439. /**
  54440. * Sets positionIterations of the impostor
  54441. * @param impostor impostor to set position on
  54442. * @param positionIterations positionIterations value
  54443. */
  54444. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54445. /**
  54446. * Append an anchor to a cloth object
  54447. * @param impostor is the cloth impostor to add anchor to
  54448. * @param otherImpostor is the rigid impostor to anchor to
  54449. * @param width ratio across width from 0 to 1
  54450. * @param height ratio up height from 0 to 1
  54451. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54452. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54453. */
  54454. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54455. /**
  54456. * Append an hook to a rope object
  54457. * @param impostor is the rope impostor to add hook to
  54458. * @param otherImpostor is the rigid impostor to hook to
  54459. * @param length ratio along the rope from 0 to 1
  54460. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54461. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54462. */
  54463. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54464. /**
  54465. * Sleeps the physics body and stops it from being active
  54466. * @param impostor impostor to sleep
  54467. */
  54468. sleepBody(impostor: PhysicsImpostor): void;
  54469. /**
  54470. * Activates the physics body
  54471. * @param impostor impostor to activate
  54472. */
  54473. wakeUpBody(impostor: PhysicsImpostor): void;
  54474. /**
  54475. * Updates the distance parameters of the joint
  54476. * @param joint joint to update
  54477. * @param maxDistance maximum distance of the joint
  54478. * @param minDistance minimum distance of the joint
  54479. */
  54480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54481. /**
  54482. * Sets a motor on the joint
  54483. * @param joint joint to set motor on
  54484. * @param speed speed of the motor
  54485. * @param maxForce maximum force of the motor
  54486. * @param motorIndex index of the motor
  54487. */
  54488. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54489. /**
  54490. * Sets the motors limit
  54491. * @param joint joint to set limit on
  54492. * @param upperLimit upper limit
  54493. * @param lowerLimit lower limit
  54494. */
  54495. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54496. /**
  54497. * Syncs the position and rotation of a mesh with the impostor
  54498. * @param mesh mesh to sync
  54499. * @param impostor impostor to update the mesh with
  54500. */
  54501. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54502. /**
  54503. * Gets the radius of the impostor
  54504. * @param impostor impostor to get radius from
  54505. * @returns the radius
  54506. */
  54507. getRadius(impostor: PhysicsImpostor): number;
  54508. /**
  54509. * Gets the box size of the impostor
  54510. * @param impostor impostor to get box size from
  54511. * @param result the resulting box size
  54512. */
  54513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54514. /**
  54515. * Disposes of the impostor
  54516. */
  54517. dispose(): void;
  54518. /**
  54519. * Does a raycast in the physics world
  54520. * @param from when should the ray start?
  54521. * @param to when should the ray end?
  54522. * @returns PhysicsRaycastResult
  54523. */
  54524. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54525. }
  54526. }
  54527. declare module "babylonjs/Probes/reflectionProbe" {
  54528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54529. import { Vector3 } from "babylonjs/Maths/math.vector";
  54530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54531. import { Nullable } from "babylonjs/types";
  54532. import { Scene } from "babylonjs/scene";
  54533. module "babylonjs/abstractScene" {
  54534. interface AbstractScene {
  54535. /**
  54536. * The list of reflection probes added to the scene
  54537. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54538. */
  54539. reflectionProbes: Array<ReflectionProbe>;
  54540. /**
  54541. * Removes the given reflection probe from this scene.
  54542. * @param toRemove The reflection probe to remove
  54543. * @returns The index of the removed reflection probe
  54544. */
  54545. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54546. /**
  54547. * Adds the given reflection probe to this scene.
  54548. * @param newReflectionProbe The reflection probe to add
  54549. */
  54550. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54551. }
  54552. }
  54553. /**
  54554. * Class used to generate realtime reflection / refraction cube textures
  54555. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54556. */
  54557. export class ReflectionProbe {
  54558. /** defines the name of the probe */
  54559. name: string;
  54560. private _scene;
  54561. private _renderTargetTexture;
  54562. private _projectionMatrix;
  54563. private _viewMatrix;
  54564. private _target;
  54565. private _add;
  54566. private _attachedMesh;
  54567. private _invertYAxis;
  54568. /** Gets or sets probe position (center of the cube map) */
  54569. position: Vector3;
  54570. /**
  54571. * Creates a new reflection probe
  54572. * @param name defines the name of the probe
  54573. * @param size defines the texture resolution (for each face)
  54574. * @param scene defines the hosting scene
  54575. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54576. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54577. */
  54578. constructor(
  54579. /** defines the name of the probe */
  54580. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54581. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54582. samples: number;
  54583. /** Gets or sets the refresh rate to use (on every frame by default) */
  54584. refreshRate: number;
  54585. /**
  54586. * Gets the hosting scene
  54587. * @returns a Scene
  54588. */
  54589. getScene(): Scene;
  54590. /** Gets the internal CubeTexture used to render to */
  54591. readonly cubeTexture: RenderTargetTexture;
  54592. /** Gets the list of meshes to render */
  54593. readonly renderList: Nullable<AbstractMesh[]>;
  54594. /**
  54595. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54596. * @param mesh defines the mesh to attach to
  54597. */
  54598. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54599. /**
  54600. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54601. * @param renderingGroupId The rendering group id corresponding to its index
  54602. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54603. */
  54604. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54605. /**
  54606. * Clean all associated resources
  54607. */
  54608. dispose(): void;
  54609. /**
  54610. * Converts the reflection probe information to a readable string for debug purpose.
  54611. * @param fullDetails Supports for multiple levels of logging within scene loading
  54612. * @returns the human readable reflection probe info
  54613. */
  54614. toString(fullDetails?: boolean): string;
  54615. /**
  54616. * Get the class name of the relfection probe.
  54617. * @returns "ReflectionProbe"
  54618. */
  54619. getClassName(): string;
  54620. /**
  54621. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54622. * @returns The JSON representation of the texture
  54623. */
  54624. serialize(): any;
  54625. /**
  54626. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54627. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54628. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54629. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54630. * @returns The parsed reflection probe if successful
  54631. */
  54632. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54633. }
  54634. }
  54635. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54636. /** @hidden */
  54637. export var _BabylonLoaderRegistered: boolean;
  54638. /**
  54639. * Helps setting up some configuration for the babylon file loader.
  54640. */
  54641. export class BabylonFileLoaderConfiguration {
  54642. /**
  54643. * The loader does not allow injecting custom physix engine into the plugins.
  54644. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54645. * So you could set this variable to your engine import to make it work.
  54646. */
  54647. static LoaderInjectedPhysicsEngine: any;
  54648. }
  54649. }
  54650. declare module "babylonjs/Loading/Plugins/index" {
  54651. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54652. }
  54653. declare module "babylonjs/Loading/index" {
  54654. export * from "babylonjs/Loading/loadingScreen";
  54655. export * from "babylonjs/Loading/Plugins/index";
  54656. export * from "babylonjs/Loading/sceneLoader";
  54657. export * from "babylonjs/Loading/sceneLoaderFlags";
  54658. }
  54659. declare module "babylonjs/Materials/Background/index" {
  54660. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54661. }
  54662. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54663. import { Scene } from "babylonjs/scene";
  54664. import { Color3 } from "babylonjs/Maths/math.color";
  54665. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54667. /**
  54668. * The Physically based simple base material of BJS.
  54669. *
  54670. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54671. * It is used as the base class for both the specGloss and metalRough conventions.
  54672. */
  54673. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54674. /**
  54675. * Number of Simultaneous lights allowed on the material.
  54676. */
  54677. maxSimultaneousLights: number;
  54678. /**
  54679. * If sets to true, disables all the lights affecting the material.
  54680. */
  54681. disableLighting: boolean;
  54682. /**
  54683. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54684. */
  54685. environmentTexture: BaseTexture;
  54686. /**
  54687. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54688. */
  54689. invertNormalMapX: boolean;
  54690. /**
  54691. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54692. */
  54693. invertNormalMapY: boolean;
  54694. /**
  54695. * Normal map used in the model.
  54696. */
  54697. normalTexture: BaseTexture;
  54698. /**
  54699. * Emissivie color used to self-illuminate the model.
  54700. */
  54701. emissiveColor: Color3;
  54702. /**
  54703. * Emissivie texture used to self-illuminate the model.
  54704. */
  54705. emissiveTexture: BaseTexture;
  54706. /**
  54707. * Occlusion Channel Strenght.
  54708. */
  54709. occlusionStrength: number;
  54710. /**
  54711. * Occlusion Texture of the material (adding extra occlusion effects).
  54712. */
  54713. occlusionTexture: BaseTexture;
  54714. /**
  54715. * Defines the alpha limits in alpha test mode.
  54716. */
  54717. alphaCutOff: number;
  54718. /**
  54719. * Gets the current double sided mode.
  54720. */
  54721. /**
  54722. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54723. */
  54724. doubleSided: boolean;
  54725. /**
  54726. * Stores the pre-calculated light information of a mesh in a texture.
  54727. */
  54728. lightmapTexture: BaseTexture;
  54729. /**
  54730. * If true, the light map contains occlusion information instead of lighting info.
  54731. */
  54732. useLightmapAsShadowmap: boolean;
  54733. /**
  54734. * Instantiates a new PBRMaterial instance.
  54735. *
  54736. * @param name The material name
  54737. * @param scene The scene the material will be use in.
  54738. */
  54739. constructor(name: string, scene: Scene);
  54740. getClassName(): string;
  54741. }
  54742. }
  54743. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54744. import { Scene } from "babylonjs/scene";
  54745. import { Color3 } from "babylonjs/Maths/math.color";
  54746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54747. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54748. /**
  54749. * The PBR material of BJS following the metal roughness convention.
  54750. *
  54751. * This fits to the PBR convention in the GLTF definition:
  54752. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54753. */
  54754. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54755. /**
  54756. * The base color has two different interpretations depending on the value of metalness.
  54757. * When the material is a metal, the base color is the specific measured reflectance value
  54758. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54759. * of the material.
  54760. */
  54761. baseColor: Color3;
  54762. /**
  54763. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54764. * well as opacity information in the alpha channel.
  54765. */
  54766. baseTexture: BaseTexture;
  54767. /**
  54768. * Specifies the metallic scalar value of the material.
  54769. * Can also be used to scale the metalness values of the metallic texture.
  54770. */
  54771. metallic: number;
  54772. /**
  54773. * Specifies the roughness scalar value of the material.
  54774. * Can also be used to scale the roughness values of the metallic texture.
  54775. */
  54776. roughness: number;
  54777. /**
  54778. * Texture containing both the metallic value in the B channel and the
  54779. * roughness value in the G channel to keep better precision.
  54780. */
  54781. metallicRoughnessTexture: BaseTexture;
  54782. /**
  54783. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54784. *
  54785. * @param name The material name
  54786. * @param scene The scene the material will be use in.
  54787. */
  54788. constructor(name: string, scene: Scene);
  54789. /**
  54790. * Return the currrent class name of the material.
  54791. */
  54792. getClassName(): string;
  54793. /**
  54794. * Makes a duplicate of the current material.
  54795. * @param name - name to use for the new material.
  54796. */
  54797. clone(name: string): PBRMetallicRoughnessMaterial;
  54798. /**
  54799. * Serialize the material to a parsable JSON object.
  54800. */
  54801. serialize(): any;
  54802. /**
  54803. * Parses a JSON object correponding to the serialize function.
  54804. */
  54805. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54806. }
  54807. }
  54808. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54809. import { Scene } from "babylonjs/scene";
  54810. import { Color3 } from "babylonjs/Maths/math.color";
  54811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54812. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54813. /**
  54814. * The PBR material of BJS following the specular glossiness convention.
  54815. *
  54816. * This fits to the PBR convention in the GLTF definition:
  54817. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54818. */
  54819. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54820. /**
  54821. * Specifies the diffuse color of the material.
  54822. */
  54823. diffuseColor: Color3;
  54824. /**
  54825. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54826. * channel.
  54827. */
  54828. diffuseTexture: BaseTexture;
  54829. /**
  54830. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54831. */
  54832. specularColor: Color3;
  54833. /**
  54834. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54835. */
  54836. glossiness: number;
  54837. /**
  54838. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54839. */
  54840. specularGlossinessTexture: BaseTexture;
  54841. /**
  54842. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54843. *
  54844. * @param name The material name
  54845. * @param scene The scene the material will be use in.
  54846. */
  54847. constructor(name: string, scene: Scene);
  54848. /**
  54849. * Return the currrent class name of the material.
  54850. */
  54851. getClassName(): string;
  54852. /**
  54853. * Makes a duplicate of the current material.
  54854. * @param name - name to use for the new material.
  54855. */
  54856. clone(name: string): PBRSpecularGlossinessMaterial;
  54857. /**
  54858. * Serialize the material to a parsable JSON object.
  54859. */
  54860. serialize(): any;
  54861. /**
  54862. * Parses a JSON object correponding to the serialize function.
  54863. */
  54864. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54865. }
  54866. }
  54867. declare module "babylonjs/Materials/PBR/index" {
  54868. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54869. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54870. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54871. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54872. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54873. }
  54874. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54875. import { Nullable } from "babylonjs/types";
  54876. import { Scene } from "babylonjs/scene";
  54877. import { Matrix } from "babylonjs/Maths/math.vector";
  54878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54879. /**
  54880. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54881. * It can help converting any input color in a desired output one. This can then be used to create effects
  54882. * from sepia, black and white to sixties or futuristic rendering...
  54883. *
  54884. * The only supported format is currently 3dl.
  54885. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54886. */
  54887. export class ColorGradingTexture extends BaseTexture {
  54888. /**
  54889. * The current texture matrix. (will always be identity in color grading texture)
  54890. */
  54891. private _textureMatrix;
  54892. /**
  54893. * The texture URL.
  54894. */
  54895. url: string;
  54896. /**
  54897. * Empty line regex stored for GC.
  54898. */
  54899. private static _noneEmptyLineRegex;
  54900. private _engine;
  54901. /**
  54902. * Instantiates a ColorGradingTexture from the following parameters.
  54903. *
  54904. * @param url The location of the color gradind data (currently only supporting 3dl)
  54905. * @param scene The scene the texture will be used in
  54906. */
  54907. constructor(url: string, scene: Scene);
  54908. /**
  54909. * Returns the texture matrix used in most of the material.
  54910. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54911. */
  54912. getTextureMatrix(): Matrix;
  54913. /**
  54914. * Occurs when the file being loaded is a .3dl LUT file.
  54915. */
  54916. private load3dlTexture;
  54917. /**
  54918. * Starts the loading process of the texture.
  54919. */
  54920. private loadTexture;
  54921. /**
  54922. * Clones the color gradind texture.
  54923. */
  54924. clone(): ColorGradingTexture;
  54925. /**
  54926. * Called during delayed load for textures.
  54927. */
  54928. delayLoad(): void;
  54929. /**
  54930. * Parses a color grading texture serialized by Babylon.
  54931. * @param parsedTexture The texture information being parsedTexture
  54932. * @param scene The scene to load the texture in
  54933. * @param rootUrl The root url of the data assets to load
  54934. * @return A color gradind texture
  54935. */
  54936. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54937. /**
  54938. * Serializes the LUT texture to json format.
  54939. */
  54940. serialize(): any;
  54941. }
  54942. }
  54943. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54945. import { Scene } from "babylonjs/scene";
  54946. import { Nullable } from "babylonjs/types";
  54947. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54948. /**
  54949. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54950. */
  54951. export class EquiRectangularCubeTexture extends BaseTexture {
  54952. /** The six faces of the cube. */
  54953. private static _FacesMapping;
  54954. private _noMipmap;
  54955. private _onLoad;
  54956. private _onError;
  54957. /** The size of the cubemap. */
  54958. private _size;
  54959. /** The buffer of the image. */
  54960. private _buffer;
  54961. /** The width of the input image. */
  54962. private _width;
  54963. /** The height of the input image. */
  54964. private _height;
  54965. /** The URL to the image. */
  54966. url: string;
  54967. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54968. coordinatesMode: number;
  54969. /**
  54970. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54971. * @param url The location of the image
  54972. * @param scene The scene the texture will be used in
  54973. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54974. * @param noMipmap Forces to not generate the mipmap if true
  54975. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54976. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54977. * @param onLoad — defines a callback called when texture is loaded
  54978. * @param onError — defines a callback called if there is an error
  54979. */
  54980. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54981. /**
  54982. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54983. */
  54984. private loadImage;
  54985. /**
  54986. * Convert the image buffer into a cubemap and create a CubeTexture.
  54987. */
  54988. private loadTexture;
  54989. /**
  54990. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54991. * @param buffer The ArrayBuffer that should be converted.
  54992. * @returns The buffer as Float32Array.
  54993. */
  54994. private getFloat32ArrayFromArrayBuffer;
  54995. /**
  54996. * Get the current class name of the texture useful for serialization or dynamic coding.
  54997. * @returns "EquiRectangularCubeTexture"
  54998. */
  54999. getClassName(): string;
  55000. /**
  55001. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55002. * @returns A clone of the current EquiRectangularCubeTexture.
  55003. */
  55004. clone(): EquiRectangularCubeTexture;
  55005. }
  55006. }
  55007. declare module "babylonjs/Misc/tga" {
  55008. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55009. /**
  55010. * Based on jsTGALoader - Javascript loader for TGA file
  55011. * By Vincent Thibault
  55012. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55013. */
  55014. export class TGATools {
  55015. private static _TYPE_INDEXED;
  55016. private static _TYPE_RGB;
  55017. private static _TYPE_GREY;
  55018. private static _TYPE_RLE_INDEXED;
  55019. private static _TYPE_RLE_RGB;
  55020. private static _TYPE_RLE_GREY;
  55021. private static _ORIGIN_MASK;
  55022. private static _ORIGIN_SHIFT;
  55023. private static _ORIGIN_BL;
  55024. private static _ORIGIN_BR;
  55025. private static _ORIGIN_UL;
  55026. private static _ORIGIN_UR;
  55027. /**
  55028. * Gets the header of a TGA file
  55029. * @param data defines the TGA data
  55030. * @returns the header
  55031. */
  55032. static GetTGAHeader(data: Uint8Array): any;
  55033. /**
  55034. * Uploads TGA content to a Babylon Texture
  55035. * @hidden
  55036. */
  55037. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55038. /** @hidden */
  55039. 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;
  55040. /** @hidden */
  55041. 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;
  55042. /** @hidden */
  55043. 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;
  55044. /** @hidden */
  55045. 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;
  55046. /** @hidden */
  55047. 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;
  55048. /** @hidden */
  55049. 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;
  55050. }
  55051. }
  55052. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55053. import { Nullable } from "babylonjs/types";
  55054. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55055. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55056. /**
  55057. * Implementation of the TGA Texture Loader.
  55058. * @hidden
  55059. */
  55060. export class _TGATextureLoader implements IInternalTextureLoader {
  55061. /**
  55062. * Defines wether the loader supports cascade loading the different faces.
  55063. */
  55064. readonly supportCascades: boolean;
  55065. /**
  55066. * This returns if the loader support the current file information.
  55067. * @param extension defines the file extension of the file being loaded
  55068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55069. * @param fallback defines the fallback internal texture if any
  55070. * @param isBase64 defines whether the texture is encoded as a base64
  55071. * @param isBuffer defines whether the texture data are stored as a buffer
  55072. * @returns true if the loader can load the specified file
  55073. */
  55074. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55075. /**
  55076. * Transform the url before loading if required.
  55077. * @param rootUrl the url of the texture
  55078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55079. * @returns the transformed texture
  55080. */
  55081. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55082. /**
  55083. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55084. * @param rootUrl the url of the texture
  55085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55086. * @returns the fallback texture
  55087. */
  55088. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55089. /**
  55090. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55091. * @param data contains the texture data
  55092. * @param texture defines the BabylonJS internal texture
  55093. * @param createPolynomials will be true if polynomials have been requested
  55094. * @param onLoad defines the callback to trigger once the texture is ready
  55095. * @param onError defines the callback to trigger in case of error
  55096. */
  55097. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55098. /**
  55099. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55100. * @param data contains the texture data
  55101. * @param texture defines the BabylonJS internal texture
  55102. * @param callback defines the method to call once ready to upload
  55103. */
  55104. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55105. }
  55106. }
  55107. declare module "babylonjs/Misc/basis" {
  55108. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55109. /**
  55110. * Info about the .basis files
  55111. */
  55112. class BasisFileInfo {
  55113. /**
  55114. * If the file has alpha
  55115. */
  55116. hasAlpha: boolean;
  55117. /**
  55118. * Info about each image of the basis file
  55119. */
  55120. images: Array<{
  55121. levels: Array<{
  55122. width: number;
  55123. height: number;
  55124. transcodedPixels: ArrayBufferView;
  55125. }>;
  55126. }>;
  55127. }
  55128. /**
  55129. * Result of transcoding a basis file
  55130. */
  55131. class TranscodeResult {
  55132. /**
  55133. * Info about the .basis file
  55134. */
  55135. fileInfo: BasisFileInfo;
  55136. /**
  55137. * Format to use when loading the file
  55138. */
  55139. format: number;
  55140. }
  55141. /**
  55142. * Configuration options for the Basis transcoder
  55143. */
  55144. export class BasisTranscodeConfiguration {
  55145. /**
  55146. * Supported compression formats used to determine the supported output format of the transcoder
  55147. */
  55148. supportedCompressionFormats?: {
  55149. /**
  55150. * etc1 compression format
  55151. */
  55152. etc1?: boolean;
  55153. /**
  55154. * s3tc compression format
  55155. */
  55156. s3tc?: boolean;
  55157. /**
  55158. * pvrtc compression format
  55159. */
  55160. pvrtc?: boolean;
  55161. /**
  55162. * etc2 compression format
  55163. */
  55164. etc2?: boolean;
  55165. };
  55166. /**
  55167. * If mipmap levels should be loaded for transcoded images (Default: true)
  55168. */
  55169. loadMipmapLevels?: boolean;
  55170. /**
  55171. * Index of a single image to load (Default: all images)
  55172. */
  55173. loadSingleImage?: number;
  55174. }
  55175. /**
  55176. * Used to load .Basis files
  55177. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55178. */
  55179. export class BasisTools {
  55180. private static _IgnoreSupportedFormats;
  55181. /**
  55182. * URL to use when loading the basis transcoder
  55183. */
  55184. static JSModuleURL: string;
  55185. /**
  55186. * URL to use when loading the wasm module for the transcoder
  55187. */
  55188. static WasmModuleURL: string;
  55189. /**
  55190. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55191. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55192. * @returns internal format corresponding to the Basis format
  55193. */
  55194. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55195. private static _WorkerPromise;
  55196. private static _Worker;
  55197. private static _actionId;
  55198. private static _CreateWorkerAsync;
  55199. /**
  55200. * Transcodes a loaded image file to compressed pixel data
  55201. * @param imageData image data to transcode
  55202. * @param config configuration options for the transcoding
  55203. * @returns a promise resulting in the transcoded image
  55204. */
  55205. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55206. /**
  55207. * Loads a texture from the transcode result
  55208. * @param texture texture load to
  55209. * @param transcodeResult the result of transcoding the basis file to load from
  55210. */
  55211. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55212. }
  55213. }
  55214. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55215. import { Nullable } from "babylonjs/types";
  55216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55218. /**
  55219. * Loader for .basis file format
  55220. */
  55221. export class _BasisTextureLoader implements IInternalTextureLoader {
  55222. /**
  55223. * Defines whether the loader supports cascade loading the different faces.
  55224. */
  55225. readonly supportCascades: boolean;
  55226. /**
  55227. * This returns if the loader support the current file information.
  55228. * @param extension defines the file extension of the file being loaded
  55229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55230. * @param fallback defines the fallback internal texture if any
  55231. * @param isBase64 defines whether the texture is encoded as a base64
  55232. * @param isBuffer defines whether the texture data are stored as a buffer
  55233. * @returns true if the loader can load the specified file
  55234. */
  55235. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55236. /**
  55237. * Transform the url before loading if required.
  55238. * @param rootUrl the url of the texture
  55239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55240. * @returns the transformed texture
  55241. */
  55242. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55243. /**
  55244. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55245. * @param rootUrl the url of the texture
  55246. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55247. * @returns the fallback texture
  55248. */
  55249. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55250. /**
  55251. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55252. * @param data contains the texture data
  55253. * @param texture defines the BabylonJS internal texture
  55254. * @param createPolynomials will be true if polynomials have been requested
  55255. * @param onLoad defines the callback to trigger once the texture is ready
  55256. * @param onError defines the callback to trigger in case of error
  55257. */
  55258. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55259. /**
  55260. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55261. * @param data contains the texture data
  55262. * @param texture defines the BabylonJS internal texture
  55263. * @param callback defines the method to call once ready to upload
  55264. */
  55265. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55266. }
  55267. }
  55268. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55269. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55270. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55271. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55272. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55273. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55274. }
  55275. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55276. import { Scene } from "babylonjs/scene";
  55277. import { Texture } from "babylonjs/Materials/Textures/texture";
  55278. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55279. /**
  55280. * 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.
  55281. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55283. */
  55284. export class CustomProceduralTexture extends ProceduralTexture {
  55285. private _animate;
  55286. private _time;
  55287. private _config;
  55288. private _texturePath;
  55289. /**
  55290. * Instantiates a new Custom Procedural Texture.
  55291. * 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.
  55292. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55293. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55294. * @param name Define the name of the texture
  55295. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55296. * @param size Define the size of the texture to create
  55297. * @param scene Define the scene the texture belongs to
  55298. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55299. * @param generateMipMaps Define if the texture should creates mip maps or not
  55300. */
  55301. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55302. private _loadJson;
  55303. /**
  55304. * Is the texture ready to be used ? (rendered at least once)
  55305. * @returns true if ready, otherwise, false.
  55306. */
  55307. isReady(): boolean;
  55308. /**
  55309. * Render the texture to its associated render target.
  55310. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55311. */
  55312. render(useCameraPostProcess?: boolean): void;
  55313. /**
  55314. * Update the list of dependant textures samplers in the shader.
  55315. */
  55316. updateTextures(): void;
  55317. /**
  55318. * Update the uniform values of the procedural texture in the shader.
  55319. */
  55320. updateShaderUniforms(): void;
  55321. /**
  55322. * Define if the texture animates or not.
  55323. */
  55324. animate: boolean;
  55325. }
  55326. }
  55327. declare module "babylonjs/Shaders/noise.fragment" {
  55328. /** @hidden */
  55329. export var noisePixelShader: {
  55330. name: string;
  55331. shader: string;
  55332. };
  55333. }
  55334. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55335. import { Nullable } from "babylonjs/types";
  55336. import { Scene } from "babylonjs/scene";
  55337. import { Texture } from "babylonjs/Materials/Textures/texture";
  55338. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55339. import "babylonjs/Shaders/noise.fragment";
  55340. /**
  55341. * Class used to generate noise procedural textures
  55342. */
  55343. export class NoiseProceduralTexture extends ProceduralTexture {
  55344. private _time;
  55345. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55346. brightness: number;
  55347. /** Defines the number of octaves to process */
  55348. octaves: number;
  55349. /** Defines the level of persistence (0.8 by default) */
  55350. persistence: number;
  55351. /** Gets or sets animation speed factor (default is 1) */
  55352. animationSpeedFactor: number;
  55353. /**
  55354. * Creates a new NoiseProceduralTexture
  55355. * @param name defines the name fo the texture
  55356. * @param size defines the size of the texture (default is 256)
  55357. * @param scene defines the hosting scene
  55358. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55359. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55360. */
  55361. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55362. private _updateShaderUniforms;
  55363. protected _getDefines(): string;
  55364. /** Generate the current state of the procedural texture */
  55365. render(useCameraPostProcess?: boolean): void;
  55366. /**
  55367. * Serializes this noise procedural texture
  55368. * @returns a serialized noise procedural texture object
  55369. */
  55370. serialize(): any;
  55371. /**
  55372. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55373. * @param parsedTexture defines parsed texture data
  55374. * @param scene defines the current scene
  55375. * @param rootUrl defines the root URL containing noise procedural texture information
  55376. * @returns a parsed NoiseProceduralTexture
  55377. */
  55378. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55379. }
  55380. }
  55381. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55382. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55383. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55384. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55385. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55386. }
  55387. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55388. import { Nullable } from "babylonjs/types";
  55389. import { Scene } from "babylonjs/scene";
  55390. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55391. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55392. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55393. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55394. /**
  55395. * Raw cube texture where the raw buffers are passed in
  55396. */
  55397. export class RawCubeTexture extends CubeTexture {
  55398. /**
  55399. * Creates a cube texture where the raw buffers are passed in.
  55400. * @param scene defines the scene the texture is attached to
  55401. * @param data defines the array of data to use to create each face
  55402. * @param size defines the size of the textures
  55403. * @param format defines the format of the data
  55404. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55405. * @param generateMipMaps defines if the engine should generate the mip levels
  55406. * @param invertY defines if data must be stored with Y axis inverted
  55407. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55408. * @param compression defines the compression used (null by default)
  55409. */
  55410. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55411. /**
  55412. * Updates the raw cube texture.
  55413. * @param data defines the data to store
  55414. * @param format defines the data format
  55415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55416. * @param invertY defines if data must be stored with Y axis inverted
  55417. * @param compression defines the compression used (null by default)
  55418. * @param level defines which level of the texture to update
  55419. */
  55420. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55421. /**
  55422. * Updates a raw cube texture with RGBD encoded data.
  55423. * @param data defines the array of data [mipmap][face] to use to create each face
  55424. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55425. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55426. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55427. * @returns a promsie that resolves when the operation is complete
  55428. */
  55429. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55430. /**
  55431. * Clones the raw cube texture.
  55432. * @return a new cube texture
  55433. */
  55434. clone(): CubeTexture;
  55435. /** @hidden */
  55436. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55437. }
  55438. }
  55439. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55440. import { Scene } from "babylonjs/scene";
  55441. import { Texture } from "babylonjs/Materials/Textures/texture";
  55442. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55443. /**
  55444. * Class used to store 3D textures containing user data
  55445. */
  55446. export class RawTexture3D extends Texture {
  55447. /** Gets or sets the texture format to use */
  55448. format: number;
  55449. private _engine;
  55450. /**
  55451. * Create a new RawTexture3D
  55452. * @param data defines the data of the texture
  55453. * @param width defines the width of the texture
  55454. * @param height defines the height of the texture
  55455. * @param depth defines the depth of the texture
  55456. * @param format defines the texture format to use
  55457. * @param scene defines the hosting scene
  55458. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55459. * @param invertY defines if texture must be stored with Y axis inverted
  55460. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55461. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55462. */
  55463. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55464. /** Gets or sets the texture format to use */
  55465. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55466. /**
  55467. * Update the texture with new data
  55468. * @param data defines the data to store in the texture
  55469. */
  55470. update(data: ArrayBufferView): void;
  55471. }
  55472. }
  55473. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55474. import { Scene } from "babylonjs/scene";
  55475. import { Texture } from "babylonjs/Materials/Textures/texture";
  55476. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55477. /**
  55478. * Class used to store 2D array textures containing user data
  55479. */
  55480. export class RawTexture2DArray extends Texture {
  55481. /** Gets or sets the texture format to use */
  55482. format: number;
  55483. private _engine;
  55484. /**
  55485. * Create a new RawTexture2DArray
  55486. * @param data defines the data of the texture
  55487. * @param width defines the width of the texture
  55488. * @param height defines the height of the texture
  55489. * @param depth defines the number of layers of the texture
  55490. * @param format defines the texture format to use
  55491. * @param scene defines the hosting scene
  55492. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55493. * @param invertY defines if texture must be stored with Y axis inverted
  55494. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55495. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55496. */
  55497. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55498. /** Gets or sets the texture format to use */
  55499. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55500. /**
  55501. * Update the texture with new data
  55502. * @param data defines the data to store in the texture
  55503. */
  55504. update(data: ArrayBufferView): void;
  55505. }
  55506. }
  55507. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55508. import { Scene } from "babylonjs/scene";
  55509. import { Plane } from "babylonjs/Maths/math.plane";
  55510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55511. /**
  55512. * Creates a refraction texture used by refraction channel of the standard material.
  55513. * It is like a mirror but to see through a material.
  55514. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55515. */
  55516. export class RefractionTexture extends RenderTargetTexture {
  55517. /**
  55518. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55519. * 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.
  55520. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55521. */
  55522. refractionPlane: Plane;
  55523. /**
  55524. * Define how deep under the surface we should see.
  55525. */
  55526. depth: number;
  55527. /**
  55528. * Creates a refraction texture used by refraction channel of the standard material.
  55529. * It is like a mirror but to see through a material.
  55530. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55531. * @param name Define the texture name
  55532. * @param size Define the size of the underlying texture
  55533. * @param scene Define the scene the refraction belongs to
  55534. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55535. */
  55536. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55537. /**
  55538. * Clone the refraction texture.
  55539. * @returns the cloned texture
  55540. */
  55541. clone(): RefractionTexture;
  55542. /**
  55543. * Serialize the texture to a JSON representation you could use in Parse later on
  55544. * @returns the serialized JSON representation
  55545. */
  55546. serialize(): any;
  55547. }
  55548. }
  55549. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55550. import { Nullable } from "babylonjs/types";
  55551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55552. import { Matrix } from "babylonjs/Maths/math.vector";
  55553. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55554. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55555. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55556. import { Scene } from "babylonjs/scene";
  55557. /**
  55558. * Defines the options related to the creation of an HtmlElementTexture
  55559. */
  55560. export interface IHtmlElementTextureOptions {
  55561. /**
  55562. * Defines wether mip maps should be created or not.
  55563. */
  55564. generateMipMaps?: boolean;
  55565. /**
  55566. * Defines the sampling mode of the texture.
  55567. */
  55568. samplingMode?: number;
  55569. /**
  55570. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55571. */
  55572. engine: Nullable<ThinEngine>;
  55573. /**
  55574. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55575. */
  55576. scene: Nullable<Scene>;
  55577. }
  55578. /**
  55579. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55580. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55581. * is automatically managed.
  55582. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55583. * in your application.
  55584. *
  55585. * As the update is not automatic, you need to call them manually.
  55586. */
  55587. export class HtmlElementTexture extends BaseTexture {
  55588. /**
  55589. * The texture URL.
  55590. */
  55591. element: HTMLVideoElement | HTMLCanvasElement;
  55592. private static readonly DefaultOptions;
  55593. private _textureMatrix;
  55594. private _engine;
  55595. private _isVideo;
  55596. private _generateMipMaps;
  55597. private _samplingMode;
  55598. /**
  55599. * Instantiates a HtmlElementTexture from the following parameters.
  55600. *
  55601. * @param name Defines the name of the texture
  55602. * @param element Defines the video or canvas the texture is filled with
  55603. * @param options Defines the other none mandatory texture creation options
  55604. */
  55605. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55606. private _createInternalTexture;
  55607. /**
  55608. * Returns the texture matrix used in most of the material.
  55609. */
  55610. getTextureMatrix(): Matrix;
  55611. /**
  55612. * Updates the content of the texture.
  55613. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55614. */
  55615. update(invertY?: Nullable<boolean>): void;
  55616. }
  55617. }
  55618. declare module "babylonjs/Materials/Textures/index" {
  55619. export * from "babylonjs/Materials/Textures/baseTexture";
  55620. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55621. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55622. export * from "babylonjs/Materials/Textures/cubeTexture";
  55623. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55624. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55625. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55626. export * from "babylonjs/Materials/Textures/internalTexture";
  55627. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55628. export * from "babylonjs/Materials/Textures/Loaders/index";
  55629. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55630. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55631. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55632. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55633. export * from "babylonjs/Materials/Textures/rawTexture";
  55634. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55635. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55636. export * from "babylonjs/Materials/Textures/refractionTexture";
  55637. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55638. export * from "babylonjs/Materials/Textures/texture";
  55639. export * from "babylonjs/Materials/Textures/videoTexture";
  55640. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55641. }
  55642. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55643. /**
  55644. * Enum used to define the target of a block
  55645. */
  55646. export enum NodeMaterialBlockTargets {
  55647. /** Vertex shader */
  55648. Vertex = 1,
  55649. /** Fragment shader */
  55650. Fragment = 2,
  55651. /** Neutral */
  55652. Neutral = 4,
  55653. /** Vertex and Fragment */
  55654. VertexAndFragment = 3
  55655. }
  55656. }
  55657. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55658. /**
  55659. * Defines the kind of connection point for node based material
  55660. */
  55661. export enum NodeMaterialBlockConnectionPointTypes {
  55662. /** Float */
  55663. Float = 1,
  55664. /** Int */
  55665. Int = 2,
  55666. /** Vector2 */
  55667. Vector2 = 4,
  55668. /** Vector3 */
  55669. Vector3 = 8,
  55670. /** Vector4 */
  55671. Vector4 = 16,
  55672. /** Color3 */
  55673. Color3 = 32,
  55674. /** Color4 */
  55675. Color4 = 64,
  55676. /** Matrix */
  55677. Matrix = 128,
  55678. /** Detect type based on connection */
  55679. AutoDetect = 1024,
  55680. /** Output type that will be defined by input type */
  55681. BasedOnInput = 2048
  55682. }
  55683. }
  55684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55685. /**
  55686. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55687. */
  55688. export enum NodeMaterialBlockConnectionPointMode {
  55689. /** Value is an uniform */
  55690. Uniform = 0,
  55691. /** Value is a mesh attribute */
  55692. Attribute = 1,
  55693. /** Value is a varying between vertex and fragment shaders */
  55694. Varying = 2,
  55695. /** Mode is undefined */
  55696. Undefined = 3
  55697. }
  55698. }
  55699. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55700. /**
  55701. * Enum used to define system values e.g. values automatically provided by the system
  55702. */
  55703. export enum NodeMaterialSystemValues {
  55704. /** World */
  55705. World = 1,
  55706. /** View */
  55707. View = 2,
  55708. /** Projection */
  55709. Projection = 3,
  55710. /** ViewProjection */
  55711. ViewProjection = 4,
  55712. /** WorldView */
  55713. WorldView = 5,
  55714. /** WorldViewProjection */
  55715. WorldViewProjection = 6,
  55716. /** CameraPosition */
  55717. CameraPosition = 7,
  55718. /** Fog Color */
  55719. FogColor = 8,
  55720. /** Delta time */
  55721. DeltaTime = 9
  55722. }
  55723. }
  55724. declare module "babylonjs/Materials/Node/Enums/index" {
  55725. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55726. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55727. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55728. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55729. }
  55730. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55732. /**
  55733. * Root class for all node material optimizers
  55734. */
  55735. export class NodeMaterialOptimizer {
  55736. /**
  55737. * Function used to optimize a NodeMaterial graph
  55738. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55739. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55740. */
  55741. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55742. }
  55743. }
  55744. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55748. import { Scene } from "babylonjs/scene";
  55749. /**
  55750. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55751. */
  55752. export class TransformBlock extends NodeMaterialBlock {
  55753. /**
  55754. * Defines the value to use to complement W value to transform it to a Vector4
  55755. */
  55756. complementW: number;
  55757. /**
  55758. * Defines the value to use to complement z value to transform it to a Vector4
  55759. */
  55760. complementZ: number;
  55761. /**
  55762. * Creates a new TransformBlock
  55763. * @param name defines the block name
  55764. */
  55765. constructor(name: string);
  55766. /**
  55767. * Gets the current class name
  55768. * @returns the class name
  55769. */
  55770. getClassName(): string;
  55771. /**
  55772. * Gets the vector input
  55773. */
  55774. readonly vector: NodeMaterialConnectionPoint;
  55775. /**
  55776. * Gets the output component
  55777. */
  55778. readonly output: NodeMaterialConnectionPoint;
  55779. /**
  55780. * Gets the matrix transform input
  55781. */
  55782. readonly transform: NodeMaterialConnectionPoint;
  55783. protected _buildBlock(state: NodeMaterialBuildState): this;
  55784. serialize(): any;
  55785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55786. protected _dumpPropertiesCode(): string;
  55787. }
  55788. }
  55789. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55793. /**
  55794. * Block used to output the vertex position
  55795. */
  55796. export class VertexOutputBlock extends NodeMaterialBlock {
  55797. /**
  55798. * Creates a new VertexOutputBlock
  55799. * @param name defines the block name
  55800. */
  55801. constructor(name: string);
  55802. /**
  55803. * Gets the current class name
  55804. * @returns the class name
  55805. */
  55806. getClassName(): string;
  55807. /**
  55808. * Gets the vector input component
  55809. */
  55810. readonly vector: NodeMaterialConnectionPoint;
  55811. protected _buildBlock(state: NodeMaterialBuildState): this;
  55812. }
  55813. }
  55814. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55818. /**
  55819. * Block used to output the final color
  55820. */
  55821. export class FragmentOutputBlock extends NodeMaterialBlock {
  55822. /**
  55823. * Create a new FragmentOutputBlock
  55824. * @param name defines the block name
  55825. */
  55826. constructor(name: string);
  55827. /**
  55828. * Gets the current class name
  55829. * @returns the class name
  55830. */
  55831. getClassName(): string;
  55832. /**
  55833. * Gets the rgba input component
  55834. */
  55835. readonly rgba: NodeMaterialConnectionPoint;
  55836. /**
  55837. * Gets the rgb input component
  55838. */
  55839. readonly rgb: NodeMaterialConnectionPoint;
  55840. /**
  55841. * Gets the a input component
  55842. */
  55843. readonly a: NodeMaterialConnectionPoint;
  55844. protected _buildBlock(state: NodeMaterialBuildState): this;
  55845. }
  55846. }
  55847. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55849. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55853. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55854. import { Effect } from "babylonjs/Materials/effect";
  55855. import { Mesh } from "babylonjs/Meshes/mesh";
  55856. import { Nullable } from "babylonjs/types";
  55857. import { Scene } from "babylonjs/scene";
  55858. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55859. /**
  55860. * Block used to read a reflection texture from a sampler
  55861. */
  55862. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55863. private _define3DName;
  55864. private _defineCubicName;
  55865. private _defineExplicitName;
  55866. private _defineProjectionName;
  55867. private _defineLocalCubicName;
  55868. private _defineSphericalName;
  55869. private _definePlanarName;
  55870. private _defineEquirectangularName;
  55871. private _defineMirroredEquirectangularFixedName;
  55872. private _defineEquirectangularFixedName;
  55873. private _defineSkyboxName;
  55874. private _cubeSamplerName;
  55875. private _2DSamplerName;
  55876. private _positionUVWName;
  55877. private _directionWName;
  55878. private _reflectionCoordsName;
  55879. private _reflection2DCoordsName;
  55880. private _reflectionColorName;
  55881. private _reflectionMatrixName;
  55882. /**
  55883. * Gets or sets the texture associated with the node
  55884. */
  55885. texture: Nullable<BaseTexture>;
  55886. /**
  55887. * Create a new TextureBlock
  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 world position input component
  55898. */
  55899. readonly position: NodeMaterialConnectionPoint;
  55900. /**
  55901. * Gets the world position input component
  55902. */
  55903. readonly worldPosition: NodeMaterialConnectionPoint;
  55904. /**
  55905. * Gets the world normal input component
  55906. */
  55907. readonly worldNormal: NodeMaterialConnectionPoint;
  55908. /**
  55909. * Gets the world input component
  55910. */
  55911. readonly world: NodeMaterialConnectionPoint;
  55912. /**
  55913. * Gets the camera (or eye) position component
  55914. */
  55915. readonly cameraPosition: NodeMaterialConnectionPoint;
  55916. /**
  55917. * Gets the view input component
  55918. */
  55919. readonly view: NodeMaterialConnectionPoint;
  55920. /**
  55921. * Gets the rgb output component
  55922. */
  55923. readonly rgb: NodeMaterialConnectionPoint;
  55924. /**
  55925. * Gets the r output component
  55926. */
  55927. readonly r: NodeMaterialConnectionPoint;
  55928. /**
  55929. * Gets the g output component
  55930. */
  55931. readonly g: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the b output component
  55934. */
  55935. readonly b: NodeMaterialConnectionPoint;
  55936. autoConfigure(material: NodeMaterial): void;
  55937. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55938. isReady(): boolean;
  55939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55940. private _injectVertexCode;
  55941. private _writeOutput;
  55942. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55943. protected _dumpPropertiesCode(): string;
  55944. serialize(): any;
  55945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55946. }
  55947. }
  55948. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55950. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55951. import { Scene } from "babylonjs/scene";
  55952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55953. import { Matrix } from "babylonjs/Maths/math.vector";
  55954. import { Mesh } from "babylonjs/Meshes/mesh";
  55955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55956. import { Observable } from "babylonjs/Misc/observable";
  55957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55958. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55959. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55960. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55961. import { Nullable } from "babylonjs/types";
  55962. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55963. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55964. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55965. /**
  55966. * Interface used to configure the node material editor
  55967. */
  55968. export interface INodeMaterialEditorOptions {
  55969. /** Define the URl to load node editor script */
  55970. editorURL?: string;
  55971. }
  55972. /** @hidden */
  55973. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55974. /** BONES */
  55975. NUM_BONE_INFLUENCERS: number;
  55976. BonesPerMesh: number;
  55977. BONETEXTURE: boolean;
  55978. /** MORPH TARGETS */
  55979. MORPHTARGETS: boolean;
  55980. MORPHTARGETS_NORMAL: boolean;
  55981. MORPHTARGETS_TANGENT: boolean;
  55982. MORPHTARGETS_UV: boolean;
  55983. NUM_MORPH_INFLUENCERS: number;
  55984. /** IMAGE PROCESSING */
  55985. IMAGEPROCESSING: boolean;
  55986. VIGNETTE: boolean;
  55987. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55988. VIGNETTEBLENDMODEOPAQUE: boolean;
  55989. TONEMAPPING: boolean;
  55990. TONEMAPPING_ACES: boolean;
  55991. CONTRAST: boolean;
  55992. EXPOSURE: boolean;
  55993. COLORCURVES: boolean;
  55994. COLORGRADING: boolean;
  55995. COLORGRADING3D: boolean;
  55996. SAMPLER3DGREENDEPTH: boolean;
  55997. SAMPLER3DBGRMAP: boolean;
  55998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55999. /** MISC. */
  56000. BUMPDIRECTUV: number;
  56001. constructor();
  56002. setValue(name: string, value: boolean): void;
  56003. }
  56004. /**
  56005. * Class used to configure NodeMaterial
  56006. */
  56007. export interface INodeMaterialOptions {
  56008. /**
  56009. * Defines if blocks should emit comments
  56010. */
  56011. emitComments: boolean;
  56012. }
  56013. /**
  56014. * Class used to create a node based material built by assembling shader blocks
  56015. */
  56016. export class NodeMaterial extends PushMaterial {
  56017. private static _BuildIdGenerator;
  56018. private _options;
  56019. private _vertexCompilationState;
  56020. private _fragmentCompilationState;
  56021. private _sharedData;
  56022. private _buildId;
  56023. private _buildWasSuccessful;
  56024. private _cachedWorldViewMatrix;
  56025. private _cachedWorldViewProjectionMatrix;
  56026. private _optimizers;
  56027. private _animationFrame;
  56028. /** Define the URl to load node editor script */
  56029. static EditorURL: string;
  56030. private BJSNODEMATERIALEDITOR;
  56031. /** Get the inspector from bundle or global */
  56032. private _getGlobalNodeMaterialEditor;
  56033. /**
  56034. * 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)
  56035. */
  56036. ignoreAlpha: boolean;
  56037. /**
  56038. * Defines the maximum number of lights that can be used in the material
  56039. */
  56040. maxSimultaneousLights: number;
  56041. /**
  56042. * Observable raised when the material is built
  56043. */
  56044. onBuildObservable: Observable<NodeMaterial>;
  56045. /**
  56046. * Gets or sets the root nodes of the material vertex shader
  56047. */
  56048. _vertexOutputNodes: NodeMaterialBlock[];
  56049. /**
  56050. * Gets or sets the root nodes of the material fragment (pixel) shader
  56051. */
  56052. _fragmentOutputNodes: NodeMaterialBlock[];
  56053. /** Gets or sets options to control the node material overall behavior */
  56054. options: INodeMaterialOptions;
  56055. /**
  56056. * Default configuration related to image processing available in the standard Material.
  56057. */
  56058. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56059. /**
  56060. * Gets the image processing configuration used either in this material.
  56061. */
  56062. /**
  56063. * Sets the Default image processing configuration used either in the this material.
  56064. *
  56065. * If sets to null, the scene one is in use.
  56066. */
  56067. imageProcessingConfiguration: ImageProcessingConfiguration;
  56068. /**
  56069. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56070. */
  56071. attachedBlocks: NodeMaterialBlock[];
  56072. /**
  56073. * Create a new node based material
  56074. * @param name defines the material name
  56075. * @param scene defines the hosting scene
  56076. * @param options defines creation option
  56077. */
  56078. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56079. /**
  56080. * Gets the current class name of the material e.g. "NodeMaterial"
  56081. * @returns the class name
  56082. */
  56083. getClassName(): string;
  56084. /**
  56085. * Keep track of the image processing observer to allow dispose and replace.
  56086. */
  56087. private _imageProcessingObserver;
  56088. /**
  56089. * Attaches a new image processing configuration to the Standard Material.
  56090. * @param configuration
  56091. */
  56092. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56093. /**
  56094. * Get a block by its name
  56095. * @param name defines the name of the block to retrieve
  56096. * @returns the required block or null if not found
  56097. */
  56098. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56099. /**
  56100. * Get a block by its name
  56101. * @param predicate defines the predicate used to find the good candidate
  56102. * @returns the required block or null if not found
  56103. */
  56104. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56105. /**
  56106. * Get an input block by its name
  56107. * @param predicate defines the predicate used to find the good candidate
  56108. * @returns the required input block or null if not found
  56109. */
  56110. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56111. /**
  56112. * Gets the list of input blocks attached to this material
  56113. * @returns an array of InputBlocks
  56114. */
  56115. getInputBlocks(): InputBlock[];
  56116. /**
  56117. * Adds a new optimizer to the list of optimizers
  56118. * @param optimizer defines the optimizers to add
  56119. * @returns the current material
  56120. */
  56121. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56122. /**
  56123. * Remove an optimizer from the list of optimizers
  56124. * @param optimizer defines the optimizers to remove
  56125. * @returns the current material
  56126. */
  56127. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56128. /**
  56129. * Add a new block to the list of output nodes
  56130. * @param node defines the node to add
  56131. * @returns the current material
  56132. */
  56133. addOutputNode(node: NodeMaterialBlock): this;
  56134. /**
  56135. * Remove a block from the list of root nodes
  56136. * @param node defines the node to remove
  56137. * @returns the current material
  56138. */
  56139. removeOutputNode(node: NodeMaterialBlock): this;
  56140. private _addVertexOutputNode;
  56141. private _removeVertexOutputNode;
  56142. private _addFragmentOutputNode;
  56143. private _removeFragmentOutputNode;
  56144. /**
  56145. * Specifies if the material will require alpha blending
  56146. * @returns a boolean specifying if alpha blending is needed
  56147. */
  56148. needAlphaBlending(): boolean;
  56149. /**
  56150. * Specifies if this material should be rendered in alpha test mode
  56151. * @returns a boolean specifying if an alpha test is needed.
  56152. */
  56153. needAlphaTesting(): boolean;
  56154. private _initializeBlock;
  56155. private _resetDualBlocks;
  56156. /**
  56157. * Build the material and generates the inner effect
  56158. * @param verbose defines if the build should log activity
  56159. */
  56160. build(verbose?: boolean): void;
  56161. /**
  56162. * Runs an otpimization phase to try to improve the shader code
  56163. */
  56164. optimize(): void;
  56165. private _prepareDefinesForAttributes;
  56166. /**
  56167. * Get if the submesh is ready to be used and all its information available.
  56168. * Child classes can use it to update shaders
  56169. * @param mesh defines the mesh to check
  56170. * @param subMesh defines which submesh to check
  56171. * @param useInstances specifies that instances should be used
  56172. * @returns a boolean indicating that the submesh is ready or not
  56173. */
  56174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56175. /**
  56176. * Get a string representing the shaders built by the current node graph
  56177. */
  56178. readonly compiledShaders: string;
  56179. /**
  56180. * Binds the world matrix to the material
  56181. * @param world defines the world transformation matrix
  56182. */
  56183. bindOnlyWorldMatrix(world: Matrix): void;
  56184. /**
  56185. * Binds the submesh to this material by preparing the effect and shader to draw
  56186. * @param world defines the world transformation matrix
  56187. * @param mesh defines the mesh containing the submesh
  56188. * @param subMesh defines the submesh to bind the material to
  56189. */
  56190. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56191. /**
  56192. * Gets the active textures from the material
  56193. * @returns an array of textures
  56194. */
  56195. getActiveTextures(): BaseTexture[];
  56196. /**
  56197. * Gets the list of texture blocks
  56198. * @returns an array of texture blocks
  56199. */
  56200. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56201. /**
  56202. * Specifies if the material uses a texture
  56203. * @param texture defines the texture to check against the material
  56204. * @returns a boolean specifying if the material uses the texture
  56205. */
  56206. hasTexture(texture: BaseTexture): boolean;
  56207. /**
  56208. * Disposes the material
  56209. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56210. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56211. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56212. */
  56213. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56214. /** Creates the node editor window. */
  56215. private _createNodeEditor;
  56216. /**
  56217. * Launch the node material editor
  56218. * @param config Define the configuration of the editor
  56219. * @return a promise fulfilled when the node editor is visible
  56220. */
  56221. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56222. /**
  56223. * Clear the current material
  56224. */
  56225. clear(): void;
  56226. /**
  56227. * Clear the current material and set it to a default state
  56228. */
  56229. setToDefault(): void;
  56230. /**
  56231. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56232. * @param url defines the url to load from
  56233. * @returns a promise that will fullfil when the material is fully loaded
  56234. */
  56235. loadAsync(url: string): Promise<void>;
  56236. private _gatherBlocks;
  56237. /**
  56238. * Generate a string containing the code declaration required to create an equivalent of this material
  56239. * @returns a string
  56240. */
  56241. generateCode(): string;
  56242. /**
  56243. * Serializes this material in a JSON representation
  56244. * @returns the serialized material object
  56245. */
  56246. serialize(): any;
  56247. private _restoreConnections;
  56248. /**
  56249. * Clear the current graph and load a new one from a serialization object
  56250. * @param source defines the JSON representation of the material
  56251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56252. */
  56253. loadFromSerialization(source: any, rootUrl?: string): void;
  56254. /**
  56255. * Creates a node material from parsed material data
  56256. * @param source defines the JSON representation of the material
  56257. * @param scene defines the hosting scene
  56258. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56259. * @returns a new node material
  56260. */
  56261. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56262. /**
  56263. * Creates a new node material set to default basic configuration
  56264. * @param name defines the name of the material
  56265. * @param scene defines the hosting scene
  56266. * @returns a new NodeMaterial
  56267. */
  56268. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56269. }
  56270. }
  56271. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56274. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56277. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56278. import { Effect } from "babylonjs/Materials/effect";
  56279. import { Mesh } from "babylonjs/Meshes/mesh";
  56280. import { Nullable } from "babylonjs/types";
  56281. import { Texture } from "babylonjs/Materials/Textures/texture";
  56282. import { Scene } from "babylonjs/scene";
  56283. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56284. /**
  56285. * Block used to read a texture from a sampler
  56286. */
  56287. export class TextureBlock extends NodeMaterialBlock {
  56288. private _defineName;
  56289. private _linearDefineName;
  56290. private _samplerName;
  56291. private _transformedUVName;
  56292. private _textureTransformName;
  56293. private _textureInfoName;
  56294. private _mainUVName;
  56295. private _mainUVDefineName;
  56296. /**
  56297. * Gets or sets the texture associated with the node
  56298. */
  56299. texture: Nullable<Texture>;
  56300. /**
  56301. * Create a new TextureBlock
  56302. * @param name defines the block name
  56303. */
  56304. constructor(name: string);
  56305. /**
  56306. * Gets the current class name
  56307. * @returns the class name
  56308. */
  56309. getClassName(): string;
  56310. /**
  56311. * Gets the uv input component
  56312. */
  56313. readonly uv: NodeMaterialConnectionPoint;
  56314. /**
  56315. * Gets the rgba output component
  56316. */
  56317. readonly rgba: NodeMaterialConnectionPoint;
  56318. /**
  56319. * Gets the rgb output component
  56320. */
  56321. readonly rgb: NodeMaterialConnectionPoint;
  56322. /**
  56323. * Gets the r output component
  56324. */
  56325. readonly r: NodeMaterialConnectionPoint;
  56326. /**
  56327. * Gets the g output component
  56328. */
  56329. readonly g: NodeMaterialConnectionPoint;
  56330. /**
  56331. * Gets the b output component
  56332. */
  56333. readonly b: NodeMaterialConnectionPoint;
  56334. /**
  56335. * Gets the a output component
  56336. */
  56337. readonly a: NodeMaterialConnectionPoint;
  56338. readonly target: NodeMaterialBlockTargets;
  56339. autoConfigure(material: NodeMaterial): void;
  56340. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56342. isReady(): boolean;
  56343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56344. private readonly _isMixed;
  56345. private _injectVertexCode;
  56346. private _writeOutput;
  56347. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56348. protected _dumpPropertiesCode(): string;
  56349. serialize(): any;
  56350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56351. }
  56352. }
  56353. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56356. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56357. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56358. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56359. import { Scene } from "babylonjs/scene";
  56360. /**
  56361. * Class used to store shared data between 2 NodeMaterialBuildState
  56362. */
  56363. export class NodeMaterialBuildStateSharedData {
  56364. /**
  56365. * Gets the list of emitted varyings
  56366. */
  56367. temps: string[];
  56368. /**
  56369. * Gets the list of emitted varyings
  56370. */
  56371. varyings: string[];
  56372. /**
  56373. * Gets the varying declaration string
  56374. */
  56375. varyingDeclaration: string;
  56376. /**
  56377. * Input blocks
  56378. */
  56379. inputBlocks: InputBlock[];
  56380. /**
  56381. * Input blocks
  56382. */
  56383. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56384. /**
  56385. * Bindable blocks (Blocks that need to set data to the effect)
  56386. */
  56387. bindableBlocks: NodeMaterialBlock[];
  56388. /**
  56389. * List of blocks that can provide a compilation fallback
  56390. */
  56391. blocksWithFallbacks: NodeMaterialBlock[];
  56392. /**
  56393. * List of blocks that can provide a define update
  56394. */
  56395. blocksWithDefines: NodeMaterialBlock[];
  56396. /**
  56397. * List of blocks that can provide a repeatable content
  56398. */
  56399. repeatableContentBlocks: NodeMaterialBlock[];
  56400. /**
  56401. * List of blocks that can provide a dynamic list of uniforms
  56402. */
  56403. dynamicUniformBlocks: NodeMaterialBlock[];
  56404. /**
  56405. * List of blocks that can block the isReady function for the material
  56406. */
  56407. blockingBlocks: NodeMaterialBlock[];
  56408. /**
  56409. * Gets the list of animated inputs
  56410. */
  56411. animatedInputs: InputBlock[];
  56412. /**
  56413. * Build Id used to avoid multiple recompilations
  56414. */
  56415. buildId: number;
  56416. /** List of emitted variables */
  56417. variableNames: {
  56418. [key: string]: number;
  56419. };
  56420. /** List of emitted defines */
  56421. defineNames: {
  56422. [key: string]: number;
  56423. };
  56424. /** Should emit comments? */
  56425. emitComments: boolean;
  56426. /** Emit build activity */
  56427. verbose: boolean;
  56428. /** Gets or sets the hosting scene */
  56429. scene: Scene;
  56430. /**
  56431. * Gets the compilation hints emitted at compilation time
  56432. */
  56433. hints: {
  56434. needWorldViewMatrix: boolean;
  56435. needWorldViewProjectionMatrix: boolean;
  56436. needAlphaBlending: boolean;
  56437. needAlphaTesting: boolean;
  56438. };
  56439. /**
  56440. * List of compilation checks
  56441. */
  56442. checks: {
  56443. emitVertex: boolean;
  56444. emitFragment: boolean;
  56445. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56446. };
  56447. /** Creates a new shared data */
  56448. constructor();
  56449. /**
  56450. * Emits console errors and exceptions if there is a failing check
  56451. */
  56452. emitErrors(): void;
  56453. }
  56454. }
  56455. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56456. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56457. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56458. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56459. /**
  56460. * Class used to store node based material build state
  56461. */
  56462. export class NodeMaterialBuildState {
  56463. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56464. supportUniformBuffers: boolean;
  56465. /**
  56466. * Gets the list of emitted attributes
  56467. */
  56468. attributes: string[];
  56469. /**
  56470. * Gets the list of emitted uniforms
  56471. */
  56472. uniforms: string[];
  56473. /**
  56474. * Gets the list of emitted constants
  56475. */
  56476. constants: string[];
  56477. /**
  56478. * Gets the list of emitted samplers
  56479. */
  56480. samplers: string[];
  56481. /**
  56482. * Gets the list of emitted functions
  56483. */
  56484. functions: {
  56485. [key: string]: string;
  56486. };
  56487. /**
  56488. * Gets the list of emitted extensions
  56489. */
  56490. extensions: {
  56491. [key: string]: string;
  56492. };
  56493. /**
  56494. * Gets the target of the compilation state
  56495. */
  56496. target: NodeMaterialBlockTargets;
  56497. /**
  56498. * Gets the list of emitted counters
  56499. */
  56500. counters: {
  56501. [key: string]: number;
  56502. };
  56503. /**
  56504. * Shared data between multiple NodeMaterialBuildState instances
  56505. */
  56506. sharedData: NodeMaterialBuildStateSharedData;
  56507. /** @hidden */
  56508. _vertexState: NodeMaterialBuildState;
  56509. /** @hidden */
  56510. _attributeDeclaration: string;
  56511. /** @hidden */
  56512. _uniformDeclaration: string;
  56513. /** @hidden */
  56514. _constantDeclaration: string;
  56515. /** @hidden */
  56516. _samplerDeclaration: string;
  56517. /** @hidden */
  56518. _varyingTransfer: string;
  56519. private _repeatableContentAnchorIndex;
  56520. /** @hidden */
  56521. _builtCompilationString: string;
  56522. /**
  56523. * Gets the emitted compilation strings
  56524. */
  56525. compilationString: string;
  56526. /**
  56527. * Finalize the compilation strings
  56528. * @param state defines the current compilation state
  56529. */
  56530. finalize(state: NodeMaterialBuildState): void;
  56531. /** @hidden */
  56532. readonly _repeatableContentAnchor: string;
  56533. /** @hidden */
  56534. _getFreeVariableName(prefix: string): string;
  56535. /** @hidden */
  56536. _getFreeDefineName(prefix: string): string;
  56537. /** @hidden */
  56538. _excludeVariableName(name: string): void;
  56539. /** @hidden */
  56540. _emit2DSampler(name: string): void;
  56541. /** @hidden */
  56542. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56543. /** @hidden */
  56544. _emitExtension(name: string, extension: string): void;
  56545. /** @hidden */
  56546. _emitFunction(name: string, code: string, comments: string): void;
  56547. /** @hidden */
  56548. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56549. replaceStrings?: {
  56550. search: RegExp;
  56551. replace: string;
  56552. }[];
  56553. repeatKey?: string;
  56554. }): string;
  56555. /** @hidden */
  56556. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56557. repeatKey?: string;
  56558. removeAttributes?: boolean;
  56559. removeUniforms?: boolean;
  56560. removeVaryings?: boolean;
  56561. removeIfDef?: boolean;
  56562. replaceStrings?: {
  56563. search: RegExp;
  56564. replace: string;
  56565. }[];
  56566. }, storeKey?: string): void;
  56567. /** @hidden */
  56568. _registerTempVariable(name: string): boolean;
  56569. /** @hidden */
  56570. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56571. /** @hidden */
  56572. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56573. /** @hidden */
  56574. _emitFloat(value: number): string;
  56575. }
  56576. }
  56577. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56578. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56580. import { Nullable } from "babylonjs/types";
  56581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56582. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56583. import { Effect } from "babylonjs/Materials/effect";
  56584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56585. import { Mesh } from "babylonjs/Meshes/mesh";
  56586. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56587. import { Scene } from "babylonjs/scene";
  56588. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56589. /**
  56590. * Defines a block that can be used inside a node based material
  56591. */
  56592. export class NodeMaterialBlock {
  56593. private _buildId;
  56594. private _buildTarget;
  56595. private _target;
  56596. private _isFinalMerger;
  56597. private _isInput;
  56598. /** @hidden */
  56599. _codeVariableName: string;
  56600. /** @hidden */
  56601. _inputs: NodeMaterialConnectionPoint[];
  56602. /** @hidden */
  56603. _outputs: NodeMaterialConnectionPoint[];
  56604. /** @hidden */
  56605. _preparationId: number;
  56606. /**
  56607. * Gets or sets the name of the block
  56608. */
  56609. name: string;
  56610. /**
  56611. * Gets or sets the unique id of the node
  56612. */
  56613. uniqueId: number;
  56614. /**
  56615. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56616. */
  56617. readonly isFinalMerger: boolean;
  56618. /**
  56619. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56620. */
  56621. readonly isInput: boolean;
  56622. /**
  56623. * Gets or sets the build Id
  56624. */
  56625. buildId: number;
  56626. /**
  56627. * Gets or sets the target of the block
  56628. */
  56629. target: NodeMaterialBlockTargets;
  56630. /**
  56631. * Gets the list of input points
  56632. */
  56633. readonly inputs: NodeMaterialConnectionPoint[];
  56634. /** Gets the list of output points */
  56635. readonly outputs: NodeMaterialConnectionPoint[];
  56636. /**
  56637. * Find an input by its name
  56638. * @param name defines the name of the input to look for
  56639. * @returns the input or null if not found
  56640. */
  56641. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56642. /**
  56643. * Find an output by its name
  56644. * @param name defines the name of the outputto look for
  56645. * @returns the output or null if not found
  56646. */
  56647. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56648. /**
  56649. * Creates a new NodeMaterialBlock
  56650. * @param name defines the block name
  56651. * @param target defines the target of that block (Vertex by default)
  56652. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56653. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56654. */
  56655. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56656. /**
  56657. * Initialize the block and prepare the context for build
  56658. * @param state defines the state that will be used for the build
  56659. */
  56660. initialize(state: NodeMaterialBuildState): void;
  56661. /**
  56662. * Bind data to effect. Will only be called for blocks with isBindable === true
  56663. * @param effect defines the effect to bind data to
  56664. * @param nodeMaterial defines the hosting NodeMaterial
  56665. * @param mesh defines the mesh that will be rendered
  56666. */
  56667. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56668. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56669. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56670. protected _writeFloat(value: number): string;
  56671. /**
  56672. * Gets the current class name e.g. "NodeMaterialBlock"
  56673. * @returns the class name
  56674. */
  56675. getClassName(): string;
  56676. /**
  56677. * Register a new input. Must be called inside a block constructor
  56678. * @param name defines the connection point name
  56679. * @param type defines the connection point type
  56680. * @param isOptional defines a boolean indicating that this input can be omitted
  56681. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56682. * @returns the current block
  56683. */
  56684. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56685. /**
  56686. * Register a new output. Must be called inside a block constructor
  56687. * @param name defines the connection point name
  56688. * @param type defines the connection point type
  56689. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56690. * @returns the current block
  56691. */
  56692. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56693. /**
  56694. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56695. * @param forOutput defines an optional connection point to check compatibility with
  56696. * @returns the first available input or null
  56697. */
  56698. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56699. /**
  56700. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56701. * @param forBlock defines an optional block to check compatibility with
  56702. * @returns the first available input or null
  56703. */
  56704. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56705. /**
  56706. * Gets the sibling of the given output
  56707. * @param current defines the current output
  56708. * @returns the next output in the list or null
  56709. */
  56710. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56711. /**
  56712. * Connect current block with another block
  56713. * @param other defines the block to connect with
  56714. * @param options define the various options to help pick the right connections
  56715. * @returns the current block
  56716. */
  56717. connectTo(other: NodeMaterialBlock, options?: {
  56718. input?: string;
  56719. output?: string;
  56720. outputSwizzle?: string;
  56721. }): this | undefined;
  56722. protected _buildBlock(state: NodeMaterialBuildState): void;
  56723. /**
  56724. * Add uniforms, samplers and uniform buffers at compilation time
  56725. * @param state defines the state to update
  56726. * @param nodeMaterial defines the node material requesting the update
  56727. * @param defines defines the material defines to update
  56728. * @param uniformBuffers defines the list of uniform buffer names
  56729. */
  56730. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56731. /**
  56732. * Add potential fallbacks if shader compilation fails
  56733. * @param mesh defines the mesh to be rendered
  56734. * @param fallbacks defines the current prioritized list of fallbacks
  56735. */
  56736. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56737. /**
  56738. * Initialize defines for shader compilation
  56739. * @param mesh defines the mesh to be rendered
  56740. * @param nodeMaterial defines the node material requesting the update
  56741. * @param defines defines the material defines to update
  56742. * @param useInstances specifies that instances should be used
  56743. */
  56744. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56745. /**
  56746. * Update defines for shader compilation
  56747. * @param mesh defines the mesh to be rendered
  56748. * @param nodeMaterial defines the node material requesting the update
  56749. * @param defines defines the material defines to update
  56750. * @param useInstances specifies that instances should be used
  56751. */
  56752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56753. /**
  56754. * Lets the block try to connect some inputs automatically
  56755. * @param material defines the hosting NodeMaterial
  56756. */
  56757. autoConfigure(material: NodeMaterial): void;
  56758. /**
  56759. * Function called when a block is declared as repeatable content generator
  56760. * @param vertexShaderState defines the current compilation state for the vertex shader
  56761. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56762. * @param mesh defines the mesh to be rendered
  56763. * @param defines defines the material defines to update
  56764. */
  56765. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56766. /**
  56767. * Checks if the block is ready
  56768. * @param mesh defines the mesh to be rendered
  56769. * @param nodeMaterial defines the node material requesting the update
  56770. * @param defines defines the material defines to update
  56771. * @param useInstances specifies that instances should be used
  56772. * @returns true if the block is ready
  56773. */
  56774. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56775. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56776. private _processBuild;
  56777. /**
  56778. * Compile the current node and generate the shader code
  56779. * @param state defines the current compilation state (uniforms, samplers, current string)
  56780. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56781. * @returns true if already built
  56782. */
  56783. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56784. protected _inputRename(name: string): string;
  56785. protected _outputRename(name: string): string;
  56786. protected _dumpPropertiesCode(): string;
  56787. /** @hidden */
  56788. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56789. /** @hidden */
  56790. _dumpCodeForOutputConnections(): string;
  56791. /**
  56792. * Clone the current block to a new identical block
  56793. * @param scene defines the hosting scene
  56794. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56795. * @returns a copy of the current block
  56796. */
  56797. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56798. /**
  56799. * Serializes this block in a JSON representation
  56800. * @returns the serialized block object
  56801. */
  56802. serialize(): any;
  56803. /** @hidden */
  56804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56805. /**
  56806. * Release resources
  56807. */
  56808. dispose(): void;
  56809. }
  56810. }
  56811. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56812. /**
  56813. * Enum defining the type of animations supported by InputBlock
  56814. */
  56815. export enum AnimatedInputBlockTypes {
  56816. /** No animation */
  56817. None = 0,
  56818. /** Time based animation. Will only work for floats */
  56819. Time = 1
  56820. }
  56821. }
  56822. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56824. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56825. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56826. import { Nullable } from "babylonjs/types";
  56827. import { Effect } from "babylonjs/Materials/effect";
  56828. import { Matrix } from "babylonjs/Maths/math.vector";
  56829. import { Scene } from "babylonjs/scene";
  56830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56832. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56833. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56834. /**
  56835. * Block used to expose an input value
  56836. */
  56837. export class InputBlock extends NodeMaterialBlock {
  56838. private _mode;
  56839. private _associatedVariableName;
  56840. private _storedValue;
  56841. private _valueCallback;
  56842. private _type;
  56843. private _animationType;
  56844. /** Gets or set a value used to limit the range of float values */
  56845. min: number;
  56846. /** Gets or set a value used to limit the range of float values */
  56847. max: number;
  56848. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56849. matrixMode: number;
  56850. /** @hidden */
  56851. _systemValue: Nullable<NodeMaterialSystemValues>;
  56852. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56853. visibleInInspector: boolean;
  56854. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56855. isConstant: boolean;
  56856. /**
  56857. * Gets or sets the connection point type (default is float)
  56858. */
  56859. readonly type: NodeMaterialBlockConnectionPointTypes;
  56860. /**
  56861. * Creates a new InputBlock
  56862. * @param name defines the block name
  56863. * @param target defines the target of that block (Vertex by default)
  56864. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56865. */
  56866. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56867. /**
  56868. * Gets the output component
  56869. */
  56870. readonly output: NodeMaterialConnectionPoint;
  56871. /**
  56872. * Set the source of this connection point to a vertex attribute
  56873. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56874. * @returns the current connection point
  56875. */
  56876. setAsAttribute(attributeName?: string): InputBlock;
  56877. /**
  56878. * Set the source of this connection point to a system value
  56879. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56880. * @returns the current connection point
  56881. */
  56882. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56883. /**
  56884. * Gets or sets the value of that point.
  56885. * Please note that this value will be ignored if valueCallback is defined
  56886. */
  56887. value: any;
  56888. /**
  56889. * Gets or sets a callback used to get the value of that point.
  56890. * Please note that setting this value will force the connection point to ignore the value property
  56891. */
  56892. valueCallback: () => any;
  56893. /**
  56894. * Gets or sets the associated variable name in the shader
  56895. */
  56896. associatedVariableName: string;
  56897. /** Gets or sets the type of animation applied to the input */
  56898. animationType: AnimatedInputBlockTypes;
  56899. /**
  56900. * Gets a boolean indicating that this connection point not defined yet
  56901. */
  56902. readonly isUndefined: boolean;
  56903. /**
  56904. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56905. * In this case the connection point name must be the name of the uniform to use.
  56906. * Can only be set on inputs
  56907. */
  56908. isUniform: boolean;
  56909. /**
  56910. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56911. * In this case the connection point name must be the name of the attribute to use
  56912. * Can only be set on inputs
  56913. */
  56914. isAttribute: boolean;
  56915. /**
  56916. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56917. * Can only be set on exit points
  56918. */
  56919. isVarying: boolean;
  56920. /**
  56921. * Gets a boolean indicating that the current connection point is a system value
  56922. */
  56923. readonly isSystemValue: boolean;
  56924. /**
  56925. * Gets or sets the current well known value or null if not defined as a system value
  56926. */
  56927. systemValue: Nullable<NodeMaterialSystemValues>;
  56928. /**
  56929. * Gets the current class name
  56930. * @returns the class name
  56931. */
  56932. getClassName(): string;
  56933. /**
  56934. * Animate the input if animationType !== None
  56935. * @param scene defines the rendering scene
  56936. */
  56937. animate(scene: Scene): void;
  56938. private _emitDefine;
  56939. initialize(state: NodeMaterialBuildState): void;
  56940. /**
  56941. * Set the input block to its default value (based on its type)
  56942. */
  56943. setDefaultValue(): void;
  56944. private _emitConstant;
  56945. private _emit;
  56946. /** @hidden */
  56947. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56948. /** @hidden */
  56949. _transmit(effect: Effect, scene: Scene): void;
  56950. protected _buildBlock(state: NodeMaterialBuildState): void;
  56951. protected _dumpPropertiesCode(): string;
  56952. serialize(): any;
  56953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56954. }
  56955. }
  56956. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56957. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56958. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56959. import { Nullable } from "babylonjs/types";
  56960. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56961. import { Observable } from "babylonjs/Misc/observable";
  56962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56963. /**
  56964. * Defines a connection point for a block
  56965. */
  56966. export class NodeMaterialConnectionPoint {
  56967. /** @hidden */
  56968. _ownerBlock: NodeMaterialBlock;
  56969. /** @hidden */
  56970. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56971. private _endpoints;
  56972. private _associatedVariableName;
  56973. /** @hidden */
  56974. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56975. /** @hidden */
  56976. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56977. private _type;
  56978. /** @hidden */
  56979. _enforceAssociatedVariableName: boolean;
  56980. /**
  56981. * Gets or sets the additional types supported by this connection point
  56982. */
  56983. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56984. /**
  56985. * Gets or sets the additional types excluded by this connection point
  56986. */
  56987. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56988. /**
  56989. * Observable triggered when this point is connected
  56990. */
  56991. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56992. /**
  56993. * Gets or sets the associated variable name in the shader
  56994. */
  56995. associatedVariableName: string;
  56996. /**
  56997. * Gets or sets the connection point type (default is float)
  56998. */
  56999. type: NodeMaterialBlockConnectionPointTypes;
  57000. /**
  57001. * Gets or sets the connection point name
  57002. */
  57003. name: string;
  57004. /**
  57005. * Gets or sets a boolean indicating that this connection point can be omitted
  57006. */
  57007. isOptional: boolean;
  57008. /**
  57009. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57010. */
  57011. define: string;
  57012. /** @hidden */
  57013. _prioritizeVertex: boolean;
  57014. private _target;
  57015. /** Gets or sets the target of that connection point */
  57016. target: NodeMaterialBlockTargets;
  57017. /**
  57018. * Gets a boolean indicating that the current point is connected
  57019. */
  57020. readonly isConnected: boolean;
  57021. /**
  57022. * Gets a boolean indicating that the current point is connected to an input block
  57023. */
  57024. readonly isConnectedToInputBlock: boolean;
  57025. /**
  57026. * Gets a the connected input block (if any)
  57027. */
  57028. readonly connectInputBlock: Nullable<InputBlock>;
  57029. /** Get the other side of the connection (if any) */
  57030. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57031. /** Get the block that owns this connection point */
  57032. readonly ownerBlock: NodeMaterialBlock;
  57033. /** Get the block connected on the other side of this connection (if any) */
  57034. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57035. /** Get the block connected on the endpoints of this connection (if any) */
  57036. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57037. /** Gets the list of connected endpoints */
  57038. readonly endpoints: NodeMaterialConnectionPoint[];
  57039. /** Gets a boolean indicating if that output point is connected to at least one input */
  57040. readonly hasEndpoints: boolean;
  57041. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57042. readonly isConnectedInVertexShader: boolean;
  57043. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57044. readonly isConnectedInFragmentShader: boolean;
  57045. /**
  57046. * Creates a new connection point
  57047. * @param name defines the connection point name
  57048. * @param ownerBlock defines the block hosting this connection point
  57049. */
  57050. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57051. /**
  57052. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57053. * @returns the class name
  57054. */
  57055. getClassName(): string;
  57056. /**
  57057. * Gets an boolean indicating if the current point can be connected to another point
  57058. * @param connectionPoint defines the other connection point
  57059. * @returns true if the connection is possible
  57060. */
  57061. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57062. /**
  57063. * Connect this point to another connection point
  57064. * @param connectionPoint defines the other connection point
  57065. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57066. * @returns the current connection point
  57067. */
  57068. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57069. /**
  57070. * Disconnect this point from one of his endpoint
  57071. * @param endpoint defines the other connection point
  57072. * @returns the current connection point
  57073. */
  57074. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57075. /**
  57076. * Serializes this point in a JSON representation
  57077. * @returns the serialized point object
  57078. */
  57079. serialize(): any;
  57080. /**
  57081. * Release resources
  57082. */
  57083. dispose(): void;
  57084. }
  57085. }
  57086. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57090. import { Mesh } from "babylonjs/Meshes/mesh";
  57091. import { Effect } from "babylonjs/Materials/effect";
  57092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57093. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57094. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57095. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57096. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57097. /**
  57098. * Block used to add support for vertex skinning (bones)
  57099. */
  57100. export class BonesBlock extends NodeMaterialBlock {
  57101. /**
  57102. * Creates a new BonesBlock
  57103. * @param name defines the block name
  57104. */
  57105. constructor(name: string);
  57106. /**
  57107. * Initialize the block and prepare the context for build
  57108. * @param state defines the state that will be used for the build
  57109. */
  57110. initialize(state: NodeMaterialBuildState): void;
  57111. /**
  57112. * Gets the current class name
  57113. * @returns the class name
  57114. */
  57115. getClassName(): string;
  57116. /**
  57117. * Gets the matrix indices input component
  57118. */
  57119. readonly matricesIndices: NodeMaterialConnectionPoint;
  57120. /**
  57121. * Gets the matrix weights input component
  57122. */
  57123. readonly matricesWeights: NodeMaterialConnectionPoint;
  57124. /**
  57125. * Gets the extra matrix indices input component
  57126. */
  57127. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57128. /**
  57129. * Gets the extra matrix weights input component
  57130. */
  57131. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57132. /**
  57133. * Gets the world input component
  57134. */
  57135. readonly world: NodeMaterialConnectionPoint;
  57136. /**
  57137. * Gets the output component
  57138. */
  57139. readonly output: NodeMaterialConnectionPoint;
  57140. autoConfigure(material: NodeMaterial): void;
  57141. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57144. protected _buildBlock(state: NodeMaterialBuildState): this;
  57145. }
  57146. }
  57147. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57152. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57153. /**
  57154. * Block used to add support for instances
  57155. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57156. */
  57157. export class InstancesBlock extends NodeMaterialBlock {
  57158. /**
  57159. * Creates a new InstancesBlock
  57160. * @param name defines the block name
  57161. */
  57162. constructor(name: string);
  57163. /**
  57164. * Gets the current class name
  57165. * @returns the class name
  57166. */
  57167. getClassName(): string;
  57168. /**
  57169. * Gets the first world row input component
  57170. */
  57171. readonly world0: NodeMaterialConnectionPoint;
  57172. /**
  57173. * Gets the second world row input component
  57174. */
  57175. readonly world1: NodeMaterialConnectionPoint;
  57176. /**
  57177. * Gets the third world row input component
  57178. */
  57179. readonly world2: NodeMaterialConnectionPoint;
  57180. /**
  57181. * Gets the forth world row input component
  57182. */
  57183. readonly world3: NodeMaterialConnectionPoint;
  57184. /**
  57185. * Gets the world input component
  57186. */
  57187. readonly world: NodeMaterialConnectionPoint;
  57188. /**
  57189. * Gets the output component
  57190. */
  57191. readonly output: NodeMaterialConnectionPoint;
  57192. autoConfigure(material: NodeMaterial): void;
  57193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57194. protected _buildBlock(state: NodeMaterialBuildState): this;
  57195. }
  57196. }
  57197. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57202. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57203. import { Effect } from "babylonjs/Materials/effect";
  57204. import { Mesh } from "babylonjs/Meshes/mesh";
  57205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57207. /**
  57208. * Block used to add morph targets support to vertex shader
  57209. */
  57210. export class MorphTargetsBlock extends NodeMaterialBlock {
  57211. private _repeatableContentAnchor;
  57212. private _repeatebleContentGenerated;
  57213. /**
  57214. * Create a new MorphTargetsBlock
  57215. * @param name defines the block name
  57216. */
  57217. constructor(name: string);
  57218. /**
  57219. * Gets the current class name
  57220. * @returns the class name
  57221. */
  57222. getClassName(): string;
  57223. /**
  57224. * Gets the position input component
  57225. */
  57226. readonly position: NodeMaterialConnectionPoint;
  57227. /**
  57228. * Gets the normal input component
  57229. */
  57230. readonly normal: NodeMaterialConnectionPoint;
  57231. /**
  57232. * Gets the tangent input component
  57233. */
  57234. readonly tangent: NodeMaterialConnectionPoint;
  57235. /**
  57236. * Gets the tangent input component
  57237. */
  57238. readonly uv: NodeMaterialConnectionPoint;
  57239. /**
  57240. * Gets the position output component
  57241. */
  57242. readonly positionOutput: NodeMaterialConnectionPoint;
  57243. /**
  57244. * Gets the normal output component
  57245. */
  57246. readonly normalOutput: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the tangent output component
  57249. */
  57250. readonly tangentOutput: NodeMaterialConnectionPoint;
  57251. /**
  57252. * Gets the tangent output component
  57253. */
  57254. readonly uvOutput: NodeMaterialConnectionPoint;
  57255. initialize(state: NodeMaterialBuildState): void;
  57256. autoConfigure(material: NodeMaterial): void;
  57257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57258. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57259. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57260. protected _buildBlock(state: NodeMaterialBuildState): this;
  57261. }
  57262. }
  57263. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57267. import { Nullable } from "babylonjs/types";
  57268. import { Scene } from "babylonjs/scene";
  57269. import { Effect } from "babylonjs/Materials/effect";
  57270. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57271. import { Mesh } from "babylonjs/Meshes/mesh";
  57272. import { Light } from "babylonjs/Lights/light";
  57273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57274. /**
  57275. * Block used to get data information from a light
  57276. */
  57277. export class LightInformationBlock extends NodeMaterialBlock {
  57278. private _lightDataUniformName;
  57279. private _lightColorUniformName;
  57280. private _lightTypeDefineName;
  57281. /**
  57282. * Gets or sets the light associated with this block
  57283. */
  57284. light: Nullable<Light>;
  57285. /**
  57286. * Creates a new LightInformationBlock
  57287. * @param name defines the block name
  57288. */
  57289. constructor(name: string);
  57290. /**
  57291. * Gets the current class name
  57292. * @returns the class name
  57293. */
  57294. getClassName(): string;
  57295. /**
  57296. * Gets the world position input component
  57297. */
  57298. readonly worldPosition: NodeMaterialConnectionPoint;
  57299. /**
  57300. * Gets the direction output component
  57301. */
  57302. readonly direction: NodeMaterialConnectionPoint;
  57303. /**
  57304. * Gets the direction output component
  57305. */
  57306. readonly color: NodeMaterialConnectionPoint;
  57307. /**
  57308. * Gets the direction output component
  57309. */
  57310. readonly intensity: NodeMaterialConnectionPoint;
  57311. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57313. protected _buildBlock(state: NodeMaterialBuildState): this;
  57314. serialize(): any;
  57315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57316. }
  57317. }
  57318. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57319. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57320. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57321. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57322. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57323. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57324. }
  57325. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57330. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57331. import { Effect } from "babylonjs/Materials/effect";
  57332. import { Mesh } from "babylonjs/Meshes/mesh";
  57333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57334. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57335. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57336. /**
  57337. * Block used to add image processing support to fragment shader
  57338. */
  57339. export class ImageProcessingBlock extends NodeMaterialBlock {
  57340. /**
  57341. * Create a new ImageProcessingBlock
  57342. * @param name defines the block name
  57343. */
  57344. constructor(name: string);
  57345. /**
  57346. * Gets the current class name
  57347. * @returns the class name
  57348. */
  57349. getClassName(): string;
  57350. /**
  57351. * Gets the color input component
  57352. */
  57353. readonly color: NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the output component
  57356. */
  57357. readonly output: NodeMaterialConnectionPoint;
  57358. /**
  57359. * Initialize the block and prepare the context for build
  57360. * @param state defines the state that will be used for the build
  57361. */
  57362. initialize(state: NodeMaterialBuildState): void;
  57363. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57365. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57366. protected _buildBlock(state: NodeMaterialBuildState): this;
  57367. }
  57368. }
  57369. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57375. import { Effect } from "babylonjs/Materials/effect";
  57376. import { Mesh } from "babylonjs/Meshes/mesh";
  57377. import { Scene } from "babylonjs/scene";
  57378. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57379. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57380. /**
  57381. * Block used to pertub normals based on a normal map
  57382. */
  57383. export class PerturbNormalBlock extends NodeMaterialBlock {
  57384. private _tangentSpaceParameterName;
  57385. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57386. invertX: boolean;
  57387. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57388. invertY: boolean;
  57389. /**
  57390. * Create a new PerturbNormalBlock
  57391. * @param name defines the block name
  57392. */
  57393. constructor(name: string);
  57394. /**
  57395. * Gets the current class name
  57396. * @returns the class name
  57397. */
  57398. getClassName(): string;
  57399. /**
  57400. * Gets the world position input component
  57401. */
  57402. readonly worldPosition: NodeMaterialConnectionPoint;
  57403. /**
  57404. * Gets the world normal input component
  57405. */
  57406. readonly worldNormal: NodeMaterialConnectionPoint;
  57407. /**
  57408. * Gets the uv input component
  57409. */
  57410. readonly uv: NodeMaterialConnectionPoint;
  57411. /**
  57412. * Gets the normal map color input component
  57413. */
  57414. readonly normalMapColor: NodeMaterialConnectionPoint;
  57415. /**
  57416. * Gets the strength input component
  57417. */
  57418. readonly strength: NodeMaterialConnectionPoint;
  57419. /**
  57420. * Gets the output component
  57421. */
  57422. readonly output: NodeMaterialConnectionPoint;
  57423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57424. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57425. autoConfigure(material: NodeMaterial): void;
  57426. protected _buildBlock(state: NodeMaterialBuildState): this;
  57427. protected _dumpPropertiesCode(): string;
  57428. serialize(): any;
  57429. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57430. }
  57431. }
  57432. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57436. /**
  57437. * Block used to discard a pixel if a value is smaller than a cutoff
  57438. */
  57439. export class DiscardBlock extends NodeMaterialBlock {
  57440. /**
  57441. * Create a new DiscardBlock
  57442. * @param name defines the block name
  57443. */
  57444. constructor(name: string);
  57445. /**
  57446. * Gets the current class name
  57447. * @returns the class name
  57448. */
  57449. getClassName(): string;
  57450. /**
  57451. * Gets the color input component
  57452. */
  57453. readonly value: NodeMaterialConnectionPoint;
  57454. /**
  57455. * Gets the cutoff input component
  57456. */
  57457. readonly cutoff: NodeMaterialConnectionPoint;
  57458. protected _buildBlock(state: NodeMaterialBuildState): this;
  57459. }
  57460. }
  57461. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57462. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57463. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57464. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57465. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57466. }
  57467. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57470. import { Mesh } from "babylonjs/Meshes/mesh";
  57471. import { Effect } from "babylonjs/Materials/effect";
  57472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57474. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57475. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57476. /**
  57477. * Block used to add support for scene fog
  57478. */
  57479. export class FogBlock extends NodeMaterialBlock {
  57480. private _fogDistanceName;
  57481. private _fogParameters;
  57482. /**
  57483. * Create a new FogBlock
  57484. * @param name defines the block name
  57485. */
  57486. constructor(name: string);
  57487. /**
  57488. * Gets the current class name
  57489. * @returns the class name
  57490. */
  57491. getClassName(): string;
  57492. /**
  57493. * Gets the world position input component
  57494. */
  57495. readonly worldPosition: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the view input component
  57498. */
  57499. readonly view: NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the color input component
  57502. */
  57503. readonly input: NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the fog color input component
  57506. */
  57507. readonly fogColor: NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the output component
  57510. */
  57511. readonly output: NodeMaterialConnectionPoint;
  57512. autoConfigure(material: NodeMaterial): void;
  57513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57515. protected _buildBlock(state: NodeMaterialBuildState): this;
  57516. }
  57517. }
  57518. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57523. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57524. import { Effect } from "babylonjs/Materials/effect";
  57525. import { Mesh } from "babylonjs/Meshes/mesh";
  57526. import { Light } from "babylonjs/Lights/light";
  57527. import { Nullable } from "babylonjs/types";
  57528. import { Scene } from "babylonjs/scene";
  57529. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57530. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57531. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57533. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57534. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57535. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57536. /**
  57537. * Block used to add light in the fragment shader
  57538. */
  57539. export class LightBlock extends NodeMaterialBlock {
  57540. private _lightId;
  57541. /**
  57542. * Gets or sets the light associated with this block
  57543. */
  57544. light: Nullable<Light>;
  57545. /**
  57546. * Create a new LightBlock
  57547. * @param name defines the block name
  57548. */
  57549. constructor(name: string);
  57550. /**
  57551. * Gets the current class name
  57552. * @returns the class name
  57553. */
  57554. getClassName(): string;
  57555. /**
  57556. * Gets the world position input component
  57557. */
  57558. readonly worldPosition: NodeMaterialConnectionPoint;
  57559. /**
  57560. * Gets the world normal input component
  57561. */
  57562. readonly worldNormal: NodeMaterialConnectionPoint;
  57563. /**
  57564. * Gets the camera (or eye) position component
  57565. */
  57566. readonly cameraPosition: NodeMaterialConnectionPoint;
  57567. /**
  57568. * Gets the glossiness component
  57569. */
  57570. readonly glossiness: NodeMaterialConnectionPoint;
  57571. /**
  57572. * Gets the glossinness power component
  57573. */
  57574. readonly glossPower: NodeMaterialConnectionPoint;
  57575. /**
  57576. * Gets the diffuse color component
  57577. */
  57578. readonly diffuseColor: NodeMaterialConnectionPoint;
  57579. /**
  57580. * Gets the specular color component
  57581. */
  57582. readonly specularColor: NodeMaterialConnectionPoint;
  57583. /**
  57584. * Gets the diffuse output component
  57585. */
  57586. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57587. /**
  57588. * Gets the specular output component
  57589. */
  57590. readonly specularOutput: NodeMaterialConnectionPoint;
  57591. autoConfigure(material: NodeMaterial): void;
  57592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57593. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57595. private _injectVertexCode;
  57596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57597. serialize(): any;
  57598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57599. }
  57600. }
  57601. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57602. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57603. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57604. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57605. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57606. }
  57607. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57608. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57609. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57610. }
  57611. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57615. /**
  57616. * Block used to multiply 2 values
  57617. */
  57618. export class MultiplyBlock extends NodeMaterialBlock {
  57619. /**
  57620. * Creates a new MultiplyBlock
  57621. * @param name defines the block name
  57622. */
  57623. constructor(name: string);
  57624. /**
  57625. * Gets the current class name
  57626. * @returns the class name
  57627. */
  57628. getClassName(): string;
  57629. /**
  57630. * Gets the left operand input component
  57631. */
  57632. readonly left: NodeMaterialConnectionPoint;
  57633. /**
  57634. * Gets the right operand input component
  57635. */
  57636. readonly right: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the output component
  57639. */
  57640. readonly output: NodeMaterialConnectionPoint;
  57641. protected _buildBlock(state: NodeMaterialBuildState): this;
  57642. }
  57643. }
  57644. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57648. /**
  57649. * Block used to add 2 vectors
  57650. */
  57651. export class AddBlock extends NodeMaterialBlock {
  57652. /**
  57653. * Creates a new AddBlock
  57654. * @param name defines the block name
  57655. */
  57656. constructor(name: string);
  57657. /**
  57658. * Gets the current class name
  57659. * @returns the class name
  57660. */
  57661. getClassName(): string;
  57662. /**
  57663. * Gets the left operand input component
  57664. */
  57665. readonly left: NodeMaterialConnectionPoint;
  57666. /**
  57667. * Gets the right operand input component
  57668. */
  57669. readonly right: NodeMaterialConnectionPoint;
  57670. /**
  57671. * Gets the output component
  57672. */
  57673. readonly output: NodeMaterialConnectionPoint;
  57674. protected _buildBlock(state: NodeMaterialBuildState): this;
  57675. }
  57676. }
  57677. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57681. /**
  57682. * Block used to scale a vector by a float
  57683. */
  57684. export class ScaleBlock extends NodeMaterialBlock {
  57685. /**
  57686. * Creates a new ScaleBlock
  57687. * @param name defines the block name
  57688. */
  57689. constructor(name: string);
  57690. /**
  57691. * Gets the current class name
  57692. * @returns the class name
  57693. */
  57694. getClassName(): string;
  57695. /**
  57696. * Gets the input component
  57697. */
  57698. readonly input: NodeMaterialConnectionPoint;
  57699. /**
  57700. * Gets the factor input component
  57701. */
  57702. readonly factor: NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the output component
  57705. */
  57706. readonly output: NodeMaterialConnectionPoint;
  57707. protected _buildBlock(state: NodeMaterialBuildState): this;
  57708. }
  57709. }
  57710. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57714. import { Scene } from "babylonjs/scene";
  57715. /**
  57716. * Block used to clamp a float
  57717. */
  57718. export class ClampBlock extends NodeMaterialBlock {
  57719. /** Gets or sets the minimum range */
  57720. minimum: number;
  57721. /** Gets or sets the maximum range */
  57722. maximum: number;
  57723. /**
  57724. * Creates a new ClampBlock
  57725. * @param name defines the block name
  57726. */
  57727. constructor(name: string);
  57728. /**
  57729. * Gets the current class name
  57730. * @returns the class name
  57731. */
  57732. getClassName(): string;
  57733. /**
  57734. * Gets the value input component
  57735. */
  57736. readonly value: NodeMaterialConnectionPoint;
  57737. /**
  57738. * Gets the output component
  57739. */
  57740. readonly output: NodeMaterialConnectionPoint;
  57741. protected _buildBlock(state: NodeMaterialBuildState): this;
  57742. protected _dumpPropertiesCode(): string;
  57743. serialize(): any;
  57744. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57745. }
  57746. }
  57747. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57751. /**
  57752. * Block used to apply a cross product between 2 vectors
  57753. */
  57754. export class CrossBlock extends NodeMaterialBlock {
  57755. /**
  57756. * Creates a new CrossBlock
  57757. * @param name defines the block name
  57758. */
  57759. constructor(name: string);
  57760. /**
  57761. * Gets the current class name
  57762. * @returns the class name
  57763. */
  57764. getClassName(): string;
  57765. /**
  57766. * Gets the left operand input component
  57767. */
  57768. readonly left: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the right operand input component
  57771. */
  57772. readonly right: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the output component
  57775. */
  57776. readonly output: NodeMaterialConnectionPoint;
  57777. protected _buildBlock(state: NodeMaterialBuildState): this;
  57778. }
  57779. }
  57780. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57784. /**
  57785. * Block used to apply a dot product between 2 vectors
  57786. */
  57787. export class DotBlock extends NodeMaterialBlock {
  57788. /**
  57789. * Creates a new DotBlock
  57790. * @param name defines the block name
  57791. */
  57792. constructor(name: string);
  57793. /**
  57794. * Gets the current class name
  57795. * @returns the class name
  57796. */
  57797. getClassName(): string;
  57798. /**
  57799. * Gets the left operand input component
  57800. */
  57801. readonly left: NodeMaterialConnectionPoint;
  57802. /**
  57803. * Gets the right operand input component
  57804. */
  57805. readonly right: NodeMaterialConnectionPoint;
  57806. /**
  57807. * Gets the output component
  57808. */
  57809. readonly output: NodeMaterialConnectionPoint;
  57810. protected _buildBlock(state: NodeMaterialBuildState): this;
  57811. }
  57812. }
  57813. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57817. import { Vector2 } from "babylonjs/Maths/math.vector";
  57818. import { Scene } from "babylonjs/scene";
  57819. /**
  57820. * Block used to remap a float from a range to a new one
  57821. */
  57822. export class RemapBlock extends NodeMaterialBlock {
  57823. /**
  57824. * Gets or sets the source range
  57825. */
  57826. sourceRange: Vector2;
  57827. /**
  57828. * Gets or sets the target range
  57829. */
  57830. targetRange: Vector2;
  57831. /**
  57832. * Creates a new RemapBlock
  57833. * @param name defines the block name
  57834. */
  57835. constructor(name: string);
  57836. /**
  57837. * Gets the current class name
  57838. * @returns the class name
  57839. */
  57840. getClassName(): string;
  57841. /**
  57842. * Gets the input component
  57843. */
  57844. readonly input: NodeMaterialConnectionPoint;
  57845. /**
  57846. * Gets the source min input component
  57847. */
  57848. readonly sourceMin: NodeMaterialConnectionPoint;
  57849. /**
  57850. * Gets the source max input component
  57851. */
  57852. readonly sourceMax: NodeMaterialConnectionPoint;
  57853. /**
  57854. * Gets the target min input component
  57855. */
  57856. readonly targetMin: NodeMaterialConnectionPoint;
  57857. /**
  57858. * Gets the target max input component
  57859. */
  57860. readonly targetMax: NodeMaterialConnectionPoint;
  57861. /**
  57862. * Gets the output component
  57863. */
  57864. readonly output: NodeMaterialConnectionPoint;
  57865. protected _buildBlock(state: NodeMaterialBuildState): this;
  57866. protected _dumpPropertiesCode(): string;
  57867. serialize(): any;
  57868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57869. }
  57870. }
  57871. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57875. /**
  57876. * Block used to normalize a vector
  57877. */
  57878. export class NormalizeBlock extends NodeMaterialBlock {
  57879. /**
  57880. * Creates a new NormalizeBlock
  57881. * @param name defines the block name
  57882. */
  57883. constructor(name: string);
  57884. /**
  57885. * Gets the current class name
  57886. * @returns the class name
  57887. */
  57888. getClassName(): string;
  57889. /**
  57890. * Gets the input component
  57891. */
  57892. readonly input: NodeMaterialConnectionPoint;
  57893. /**
  57894. * Gets the output component
  57895. */
  57896. readonly output: NodeMaterialConnectionPoint;
  57897. protected _buildBlock(state: NodeMaterialBuildState): this;
  57898. }
  57899. }
  57900. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57904. import { Scene } from "babylonjs/scene";
  57905. /**
  57906. * Operations supported by the Trigonometry block
  57907. */
  57908. export enum TrigonometryBlockOperations {
  57909. /** Cos */
  57910. Cos = 0,
  57911. /** Sin */
  57912. Sin = 1,
  57913. /** Abs */
  57914. Abs = 2,
  57915. /** Exp */
  57916. Exp = 3,
  57917. /** Exp2 */
  57918. Exp2 = 4,
  57919. /** Round */
  57920. Round = 5,
  57921. /** Floor */
  57922. Floor = 6,
  57923. /** Ceiling */
  57924. Ceiling = 7,
  57925. /** Square root */
  57926. Sqrt = 8,
  57927. /** Log */
  57928. Log = 9,
  57929. /** Tangent */
  57930. Tan = 10,
  57931. /** Arc tangent */
  57932. ArcTan = 11,
  57933. /** Arc cosinus */
  57934. ArcCos = 12,
  57935. /** Arc sinus */
  57936. ArcSin = 13,
  57937. /** Fraction */
  57938. Fract = 14,
  57939. /** Sign */
  57940. Sign = 15,
  57941. /** To radians (from degrees) */
  57942. Radians = 16,
  57943. /** To degrees (from radians) */
  57944. Degrees = 17
  57945. }
  57946. /**
  57947. * Block used to apply trigonometry operation to floats
  57948. */
  57949. export class TrigonometryBlock extends NodeMaterialBlock {
  57950. /**
  57951. * Gets or sets the operation applied by the block
  57952. */
  57953. operation: TrigonometryBlockOperations;
  57954. /**
  57955. * Creates a new TrigonometryBlock
  57956. * @param name defines the block name
  57957. */
  57958. constructor(name: string);
  57959. /**
  57960. * Gets the current class name
  57961. * @returns the class name
  57962. */
  57963. getClassName(): string;
  57964. /**
  57965. * Gets the input component
  57966. */
  57967. readonly input: NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the output component
  57970. */
  57971. readonly output: NodeMaterialConnectionPoint;
  57972. protected _buildBlock(state: NodeMaterialBuildState): this;
  57973. serialize(): any;
  57974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57975. }
  57976. }
  57977. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57981. /**
  57982. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57983. */
  57984. export class ColorMergerBlock extends NodeMaterialBlock {
  57985. /**
  57986. * Create a new ColorMergerBlock
  57987. * @param name defines the block name
  57988. */
  57989. constructor(name: string);
  57990. /**
  57991. * Gets the current class name
  57992. * @returns the class name
  57993. */
  57994. getClassName(): string;
  57995. /**
  57996. * Gets the r component (input)
  57997. */
  57998. readonly r: NodeMaterialConnectionPoint;
  57999. /**
  58000. * Gets the g component (input)
  58001. */
  58002. readonly g: NodeMaterialConnectionPoint;
  58003. /**
  58004. * Gets the b component (input)
  58005. */
  58006. readonly b: NodeMaterialConnectionPoint;
  58007. /**
  58008. * Gets the a component (input)
  58009. */
  58010. readonly a: NodeMaterialConnectionPoint;
  58011. /**
  58012. * Gets the rgba component (output)
  58013. */
  58014. readonly rgba: NodeMaterialConnectionPoint;
  58015. /**
  58016. * Gets the rgb component (output)
  58017. */
  58018. readonly rgb: NodeMaterialConnectionPoint;
  58019. protected _buildBlock(state: NodeMaterialBuildState): this;
  58020. }
  58021. }
  58022. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58026. /**
  58027. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58028. */
  58029. export class VectorMergerBlock extends NodeMaterialBlock {
  58030. /**
  58031. * Create a new VectorMergerBlock
  58032. * @param name defines the block name
  58033. */
  58034. constructor(name: string);
  58035. /**
  58036. * Gets the current class name
  58037. * @returns the class name
  58038. */
  58039. getClassName(): string;
  58040. /**
  58041. * Gets the x component (input)
  58042. */
  58043. readonly x: NodeMaterialConnectionPoint;
  58044. /**
  58045. * Gets the y component (input)
  58046. */
  58047. readonly y: NodeMaterialConnectionPoint;
  58048. /**
  58049. * Gets the z component (input)
  58050. */
  58051. readonly z: NodeMaterialConnectionPoint;
  58052. /**
  58053. * Gets the w component (input)
  58054. */
  58055. readonly w: NodeMaterialConnectionPoint;
  58056. /**
  58057. * Gets the xyzw component (output)
  58058. */
  58059. readonly xyzw: NodeMaterialConnectionPoint;
  58060. /**
  58061. * Gets the xyz component (output)
  58062. */
  58063. readonly xyz: NodeMaterialConnectionPoint;
  58064. /**
  58065. * Gets the xy component (output)
  58066. */
  58067. readonly xy: NodeMaterialConnectionPoint;
  58068. protected _buildBlock(state: NodeMaterialBuildState): this;
  58069. }
  58070. }
  58071. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58075. /**
  58076. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58077. */
  58078. export class ColorSplitterBlock extends NodeMaterialBlock {
  58079. /**
  58080. * Create a new ColorSplitterBlock
  58081. * @param name defines the block name
  58082. */
  58083. constructor(name: string);
  58084. /**
  58085. * Gets the current class name
  58086. * @returns the class name
  58087. */
  58088. getClassName(): string;
  58089. /**
  58090. * Gets the rgba component (input)
  58091. */
  58092. readonly rgba: NodeMaterialConnectionPoint;
  58093. /**
  58094. * Gets the rgb component (input)
  58095. */
  58096. readonly rgbIn: NodeMaterialConnectionPoint;
  58097. /**
  58098. * Gets the rgb component (output)
  58099. */
  58100. readonly rgbOut: NodeMaterialConnectionPoint;
  58101. /**
  58102. * Gets the r component (output)
  58103. */
  58104. readonly r: NodeMaterialConnectionPoint;
  58105. /**
  58106. * Gets the g component (output)
  58107. */
  58108. readonly g: NodeMaterialConnectionPoint;
  58109. /**
  58110. * Gets the b component (output)
  58111. */
  58112. readonly b: NodeMaterialConnectionPoint;
  58113. /**
  58114. * Gets the a component (output)
  58115. */
  58116. readonly a: NodeMaterialConnectionPoint;
  58117. protected _inputRename(name: string): string;
  58118. protected _outputRename(name: string): string;
  58119. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58120. }
  58121. }
  58122. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58126. /**
  58127. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58128. */
  58129. export class VectorSplitterBlock extends NodeMaterialBlock {
  58130. /**
  58131. * Create a new VectorSplitterBlock
  58132. * @param name defines the block name
  58133. */
  58134. constructor(name: string);
  58135. /**
  58136. * Gets the current class name
  58137. * @returns the class name
  58138. */
  58139. getClassName(): string;
  58140. /**
  58141. * Gets the xyzw component (input)
  58142. */
  58143. readonly xyzw: NodeMaterialConnectionPoint;
  58144. /**
  58145. * Gets the xyz component (input)
  58146. */
  58147. readonly xyzIn: NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the xy component (input)
  58150. */
  58151. readonly xyIn: NodeMaterialConnectionPoint;
  58152. /**
  58153. * Gets the xyz component (output)
  58154. */
  58155. readonly xyzOut: NodeMaterialConnectionPoint;
  58156. /**
  58157. * Gets the xy component (output)
  58158. */
  58159. readonly xyOut: NodeMaterialConnectionPoint;
  58160. /**
  58161. * Gets the x component (output)
  58162. */
  58163. readonly x: NodeMaterialConnectionPoint;
  58164. /**
  58165. * Gets the y component (output)
  58166. */
  58167. readonly y: NodeMaterialConnectionPoint;
  58168. /**
  58169. * Gets the z component (output)
  58170. */
  58171. readonly z: NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the w component (output)
  58174. */
  58175. readonly w: NodeMaterialConnectionPoint;
  58176. protected _inputRename(name: string): string;
  58177. protected _outputRename(name: string): string;
  58178. protected _buildBlock(state: NodeMaterialBuildState): this;
  58179. }
  58180. }
  58181. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58185. /**
  58186. * Block used to lerp between 2 values
  58187. */
  58188. export class LerpBlock extends NodeMaterialBlock {
  58189. /**
  58190. * Creates a new LerpBlock
  58191. * @param name defines the block name
  58192. */
  58193. constructor(name: string);
  58194. /**
  58195. * Gets the current class name
  58196. * @returns the class name
  58197. */
  58198. getClassName(): string;
  58199. /**
  58200. * Gets the left operand input component
  58201. */
  58202. readonly left: NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the right operand input component
  58205. */
  58206. readonly right: NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the gradient operand input component
  58209. */
  58210. readonly gradient: NodeMaterialConnectionPoint;
  58211. /**
  58212. * Gets the output component
  58213. */
  58214. readonly output: NodeMaterialConnectionPoint;
  58215. protected _buildBlock(state: NodeMaterialBuildState): this;
  58216. }
  58217. }
  58218. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58222. /**
  58223. * Block used to divide 2 vectors
  58224. */
  58225. export class DivideBlock extends NodeMaterialBlock {
  58226. /**
  58227. * Creates a new DivideBlock
  58228. * @param name defines the block name
  58229. */
  58230. constructor(name: string);
  58231. /**
  58232. * Gets the current class name
  58233. * @returns the class name
  58234. */
  58235. getClassName(): string;
  58236. /**
  58237. * Gets the left operand input component
  58238. */
  58239. readonly left: NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the right operand input component
  58242. */
  58243. readonly right: NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the output component
  58246. */
  58247. readonly output: NodeMaterialConnectionPoint;
  58248. protected _buildBlock(state: NodeMaterialBuildState): this;
  58249. }
  58250. }
  58251. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58255. /**
  58256. * Block used to subtract 2 vectors
  58257. */
  58258. export class SubtractBlock extends NodeMaterialBlock {
  58259. /**
  58260. * Creates a new SubtractBlock
  58261. * @param name defines the block name
  58262. */
  58263. constructor(name: string);
  58264. /**
  58265. * Gets the current class name
  58266. * @returns the class name
  58267. */
  58268. getClassName(): string;
  58269. /**
  58270. * Gets the left operand input component
  58271. */
  58272. readonly left: NodeMaterialConnectionPoint;
  58273. /**
  58274. * Gets the right operand input component
  58275. */
  58276. readonly right: NodeMaterialConnectionPoint;
  58277. /**
  58278. * Gets the output component
  58279. */
  58280. readonly output: NodeMaterialConnectionPoint;
  58281. protected _buildBlock(state: NodeMaterialBuildState): this;
  58282. }
  58283. }
  58284. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58288. /**
  58289. * Block used to step a value
  58290. */
  58291. export class StepBlock extends NodeMaterialBlock {
  58292. /**
  58293. * Creates a new StepBlock
  58294. * @param name defines the block name
  58295. */
  58296. constructor(name: string);
  58297. /**
  58298. * Gets the current class name
  58299. * @returns the class name
  58300. */
  58301. getClassName(): string;
  58302. /**
  58303. * Gets the value operand input component
  58304. */
  58305. readonly value: NodeMaterialConnectionPoint;
  58306. /**
  58307. * Gets the edge operand input component
  58308. */
  58309. readonly edge: NodeMaterialConnectionPoint;
  58310. /**
  58311. * Gets the output component
  58312. */
  58313. readonly output: NodeMaterialConnectionPoint;
  58314. protected _buildBlock(state: NodeMaterialBuildState): this;
  58315. }
  58316. }
  58317. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58321. /**
  58322. * Block used to get the opposite (1 - x) of a value
  58323. */
  58324. export class OneMinusBlock extends NodeMaterialBlock {
  58325. /**
  58326. * Creates a new OneMinusBlock
  58327. * @param name defines the block name
  58328. */
  58329. constructor(name: string);
  58330. /**
  58331. * Gets the current class name
  58332. * @returns the class name
  58333. */
  58334. getClassName(): string;
  58335. /**
  58336. * Gets the input component
  58337. */
  58338. readonly input: NodeMaterialConnectionPoint;
  58339. /**
  58340. * Gets the output component
  58341. */
  58342. readonly output: NodeMaterialConnectionPoint;
  58343. protected _buildBlock(state: NodeMaterialBuildState): this;
  58344. }
  58345. }
  58346. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58350. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58351. /**
  58352. * Block used to get the view direction
  58353. */
  58354. export class ViewDirectionBlock extends NodeMaterialBlock {
  58355. /**
  58356. * Creates a new ViewDirectionBlock
  58357. * @param name defines the block name
  58358. */
  58359. constructor(name: string);
  58360. /**
  58361. * Gets the current class name
  58362. * @returns the class name
  58363. */
  58364. getClassName(): string;
  58365. /**
  58366. * Gets the world position component
  58367. */
  58368. readonly worldPosition: NodeMaterialConnectionPoint;
  58369. /**
  58370. * Gets the camera position component
  58371. */
  58372. readonly cameraPosition: NodeMaterialConnectionPoint;
  58373. /**
  58374. * Gets the output component
  58375. */
  58376. readonly output: NodeMaterialConnectionPoint;
  58377. autoConfigure(material: NodeMaterial): void;
  58378. protected _buildBlock(state: NodeMaterialBuildState): this;
  58379. }
  58380. }
  58381. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58385. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58386. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58387. /**
  58388. * Block used to compute fresnel value
  58389. */
  58390. export class FresnelBlock extends NodeMaterialBlock {
  58391. /**
  58392. * Create a new FresnelBlock
  58393. * @param name defines the block name
  58394. */
  58395. constructor(name: string);
  58396. /**
  58397. * Gets the current class name
  58398. * @returns the class name
  58399. */
  58400. getClassName(): string;
  58401. /**
  58402. * Gets the world normal input component
  58403. */
  58404. readonly worldNormal: NodeMaterialConnectionPoint;
  58405. /**
  58406. * Gets the view direction input component
  58407. */
  58408. readonly viewDirection: NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the bias input component
  58411. */
  58412. readonly bias: NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the camera (or eye) position component
  58415. */
  58416. readonly power: NodeMaterialConnectionPoint;
  58417. /**
  58418. * Gets the fresnel output component
  58419. */
  58420. readonly fresnel: NodeMaterialConnectionPoint;
  58421. autoConfigure(material: NodeMaterial): void;
  58422. protected _buildBlock(state: NodeMaterialBuildState): this;
  58423. }
  58424. }
  58425. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58429. /**
  58430. * Block used to get the max of 2 values
  58431. */
  58432. export class MaxBlock extends NodeMaterialBlock {
  58433. /**
  58434. * Creates a new MaxBlock
  58435. * @param name defines the block name
  58436. */
  58437. constructor(name: string);
  58438. /**
  58439. * Gets the current class name
  58440. * @returns the class name
  58441. */
  58442. getClassName(): string;
  58443. /**
  58444. * Gets the left operand input component
  58445. */
  58446. readonly left: NodeMaterialConnectionPoint;
  58447. /**
  58448. * Gets the right operand input component
  58449. */
  58450. readonly right: NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the output component
  58453. */
  58454. readonly output: NodeMaterialConnectionPoint;
  58455. protected _buildBlock(state: NodeMaterialBuildState): this;
  58456. }
  58457. }
  58458. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58462. /**
  58463. * Block used to get the min of 2 values
  58464. */
  58465. export class MinBlock extends NodeMaterialBlock {
  58466. /**
  58467. * Creates a new MinBlock
  58468. * @param name defines the block name
  58469. */
  58470. constructor(name: string);
  58471. /**
  58472. * Gets the current class name
  58473. * @returns the class name
  58474. */
  58475. getClassName(): string;
  58476. /**
  58477. * Gets the left operand input component
  58478. */
  58479. readonly left: NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the right operand input component
  58482. */
  58483. readonly right: NodeMaterialConnectionPoint;
  58484. /**
  58485. * Gets the output component
  58486. */
  58487. readonly output: NodeMaterialConnectionPoint;
  58488. protected _buildBlock(state: NodeMaterialBuildState): this;
  58489. }
  58490. }
  58491. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58495. /**
  58496. * Block used to get the distance between 2 values
  58497. */
  58498. export class DistanceBlock extends NodeMaterialBlock {
  58499. /**
  58500. * Creates a new DistanceBlock
  58501. * @param name defines the block name
  58502. */
  58503. constructor(name: string);
  58504. /**
  58505. * Gets the current class name
  58506. * @returns the class name
  58507. */
  58508. getClassName(): string;
  58509. /**
  58510. * Gets the left operand input component
  58511. */
  58512. readonly left: NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the right operand input component
  58515. */
  58516. readonly right: NodeMaterialConnectionPoint;
  58517. /**
  58518. * Gets the output component
  58519. */
  58520. readonly output: NodeMaterialConnectionPoint;
  58521. protected _buildBlock(state: NodeMaterialBuildState): this;
  58522. }
  58523. }
  58524. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58528. /**
  58529. * Block used to get the length of a vector
  58530. */
  58531. export class LengthBlock extends NodeMaterialBlock {
  58532. /**
  58533. * Creates a new LengthBlock
  58534. * @param name defines the block name
  58535. */
  58536. constructor(name: string);
  58537. /**
  58538. * Gets the current class name
  58539. * @returns the class name
  58540. */
  58541. getClassName(): string;
  58542. /**
  58543. * Gets the value input component
  58544. */
  58545. readonly value: NodeMaterialConnectionPoint;
  58546. /**
  58547. * Gets the output component
  58548. */
  58549. readonly output: NodeMaterialConnectionPoint;
  58550. protected _buildBlock(state: NodeMaterialBuildState): this;
  58551. }
  58552. }
  58553. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58557. /**
  58558. * Block used to get negative version of a value (i.e. x * -1)
  58559. */
  58560. export class NegateBlock extends NodeMaterialBlock {
  58561. /**
  58562. * Creates a new NegateBlock
  58563. * @param name defines the block name
  58564. */
  58565. constructor(name: string);
  58566. /**
  58567. * Gets the current class name
  58568. * @returns the class name
  58569. */
  58570. getClassName(): string;
  58571. /**
  58572. * Gets the value input component
  58573. */
  58574. readonly value: NodeMaterialConnectionPoint;
  58575. /**
  58576. * Gets the output component
  58577. */
  58578. readonly output: NodeMaterialConnectionPoint;
  58579. protected _buildBlock(state: NodeMaterialBuildState): this;
  58580. }
  58581. }
  58582. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58586. /**
  58587. * Block used to get the value of the first parameter raised to the power of the second
  58588. */
  58589. export class PowBlock extends NodeMaterialBlock {
  58590. /**
  58591. * Creates a new PowBlock
  58592. * @param name defines the block name
  58593. */
  58594. constructor(name: string);
  58595. /**
  58596. * Gets the current class name
  58597. * @returns the class name
  58598. */
  58599. getClassName(): string;
  58600. /**
  58601. * Gets the value operand input component
  58602. */
  58603. readonly value: NodeMaterialConnectionPoint;
  58604. /**
  58605. * Gets the power operand input component
  58606. */
  58607. readonly power: NodeMaterialConnectionPoint;
  58608. /**
  58609. * Gets the output component
  58610. */
  58611. readonly output: NodeMaterialConnectionPoint;
  58612. protected _buildBlock(state: NodeMaterialBuildState): this;
  58613. }
  58614. }
  58615. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58619. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58620. /**
  58621. * Block used to get a random number
  58622. */
  58623. export class RandomNumberBlock extends NodeMaterialBlock {
  58624. /**
  58625. * Creates a new RandomNumberBlock
  58626. * @param name defines the block name
  58627. */
  58628. constructor(name: string);
  58629. /**
  58630. * Gets the current class name
  58631. * @returns the class name
  58632. */
  58633. getClassName(): string;
  58634. /**
  58635. * Gets the seed input component
  58636. */
  58637. readonly seed: NodeMaterialConnectionPoint;
  58638. /**
  58639. * Gets the output component
  58640. */
  58641. readonly output: NodeMaterialConnectionPoint;
  58642. protected _buildBlock(state: NodeMaterialBuildState): this;
  58643. }
  58644. }
  58645. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58649. /**
  58650. * Block used to compute arc tangent of 2 values
  58651. */
  58652. export class ArcTan2Block extends NodeMaterialBlock {
  58653. /**
  58654. * Creates a new ArcTan2Block
  58655. * @param name defines the block name
  58656. */
  58657. constructor(name: string);
  58658. /**
  58659. * Gets the current class name
  58660. * @returns the class name
  58661. */
  58662. getClassName(): string;
  58663. /**
  58664. * Gets the x operand input component
  58665. */
  58666. readonly x: NodeMaterialConnectionPoint;
  58667. /**
  58668. * Gets the y operand input component
  58669. */
  58670. readonly y: NodeMaterialConnectionPoint;
  58671. /**
  58672. * Gets the output component
  58673. */
  58674. readonly output: NodeMaterialConnectionPoint;
  58675. protected _buildBlock(state: NodeMaterialBuildState): this;
  58676. }
  58677. }
  58678. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58682. /**
  58683. * Block used to smooth step a value
  58684. */
  58685. export class SmoothStepBlock extends NodeMaterialBlock {
  58686. /**
  58687. * Creates a new SmoothStepBlock
  58688. * @param name defines the block name
  58689. */
  58690. constructor(name: string);
  58691. /**
  58692. * Gets the current class name
  58693. * @returns the class name
  58694. */
  58695. getClassName(): string;
  58696. /**
  58697. * Gets the value operand input component
  58698. */
  58699. readonly value: NodeMaterialConnectionPoint;
  58700. /**
  58701. * Gets the first edge operand input component
  58702. */
  58703. readonly edge0: NodeMaterialConnectionPoint;
  58704. /**
  58705. * Gets the second edge operand input component
  58706. */
  58707. readonly edge1: NodeMaterialConnectionPoint;
  58708. /**
  58709. * Gets the output component
  58710. */
  58711. readonly output: NodeMaterialConnectionPoint;
  58712. protected _buildBlock(state: NodeMaterialBuildState): this;
  58713. }
  58714. }
  58715. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58719. /**
  58720. * Block used to get the reciprocal (1 / x) of a value
  58721. */
  58722. export class ReciprocalBlock extends NodeMaterialBlock {
  58723. /**
  58724. * Creates a new ReciprocalBlock
  58725. * @param name defines the block name
  58726. */
  58727. constructor(name: string);
  58728. /**
  58729. * Gets the current class name
  58730. * @returns the class name
  58731. */
  58732. getClassName(): string;
  58733. /**
  58734. * Gets the input component
  58735. */
  58736. readonly input: NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the output component
  58739. */
  58740. readonly output: NodeMaterialConnectionPoint;
  58741. protected _buildBlock(state: NodeMaterialBuildState): this;
  58742. }
  58743. }
  58744. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58748. /**
  58749. * Block used to replace a color by another one
  58750. */
  58751. export class ReplaceColorBlock extends NodeMaterialBlock {
  58752. /**
  58753. * Creates a new ReplaceColorBlock
  58754. * @param name defines the block name
  58755. */
  58756. constructor(name: string);
  58757. /**
  58758. * Gets the current class name
  58759. * @returns the class name
  58760. */
  58761. getClassName(): string;
  58762. /**
  58763. * Gets the value input component
  58764. */
  58765. readonly value: NodeMaterialConnectionPoint;
  58766. /**
  58767. * Gets the reference input component
  58768. */
  58769. readonly reference: NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the distance input component
  58772. */
  58773. readonly distance: NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the replacement input component
  58776. */
  58777. readonly replacement: NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the output component
  58780. */
  58781. readonly output: NodeMaterialConnectionPoint;
  58782. protected _buildBlock(state: NodeMaterialBuildState): this;
  58783. }
  58784. }
  58785. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58789. /**
  58790. * Block used to posterize a value
  58791. * @see https://en.wikipedia.org/wiki/Posterization
  58792. */
  58793. export class PosterizeBlock extends NodeMaterialBlock {
  58794. /**
  58795. * Creates a new PosterizeBlock
  58796. * @param name defines the block name
  58797. */
  58798. constructor(name: string);
  58799. /**
  58800. * Gets the current class name
  58801. * @returns the class name
  58802. */
  58803. getClassName(): string;
  58804. /**
  58805. * Gets the value input component
  58806. */
  58807. readonly value: NodeMaterialConnectionPoint;
  58808. /**
  58809. * Gets the steps input component
  58810. */
  58811. readonly steps: NodeMaterialConnectionPoint;
  58812. /**
  58813. * Gets the output component
  58814. */
  58815. readonly output: NodeMaterialConnectionPoint;
  58816. protected _buildBlock(state: NodeMaterialBuildState): this;
  58817. }
  58818. }
  58819. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58823. import { Scene } from "babylonjs/scene";
  58824. /**
  58825. * Operations supported by the Wave block
  58826. */
  58827. export enum WaveBlockKind {
  58828. /** SawTooth */
  58829. SawTooth = 0,
  58830. /** Square */
  58831. Square = 1,
  58832. /** Triangle */
  58833. Triangle = 2
  58834. }
  58835. /**
  58836. * Block used to apply wave operation to floats
  58837. */
  58838. export class WaveBlock extends NodeMaterialBlock {
  58839. /**
  58840. * Gets or sets the kibnd of wave to be applied by the block
  58841. */
  58842. kind: WaveBlockKind;
  58843. /**
  58844. * Creates a new WaveBlock
  58845. * @param name defines the block name
  58846. */
  58847. constructor(name: string);
  58848. /**
  58849. * Gets the current class name
  58850. * @returns the class name
  58851. */
  58852. getClassName(): string;
  58853. /**
  58854. * Gets the input component
  58855. */
  58856. readonly input: NodeMaterialConnectionPoint;
  58857. /**
  58858. * Gets the output component
  58859. */
  58860. readonly output: NodeMaterialConnectionPoint;
  58861. protected _buildBlock(state: NodeMaterialBuildState): this;
  58862. serialize(): any;
  58863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58864. }
  58865. }
  58866. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58870. import { Color3 } from "babylonjs/Maths/math.color";
  58871. import { Scene } from "babylonjs/scene";
  58872. /**
  58873. * Class used to store a color step for the GradientBlock
  58874. */
  58875. export class GradientBlockColorStep {
  58876. /**
  58877. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58878. */
  58879. step: number;
  58880. /**
  58881. * Gets or sets the color associated with this step
  58882. */
  58883. color: Color3;
  58884. /**
  58885. * Creates a new GradientBlockColorStep
  58886. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58887. * @param color defines the color associated with this step
  58888. */
  58889. constructor(
  58890. /**
  58891. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58892. */
  58893. step: number,
  58894. /**
  58895. * Gets or sets the color associated with this step
  58896. */
  58897. color: Color3);
  58898. }
  58899. /**
  58900. * Block used to return a color from a gradient based on an input value between 0 and 1
  58901. */
  58902. export class GradientBlock extends NodeMaterialBlock {
  58903. /**
  58904. * Gets or sets the list of color steps
  58905. */
  58906. colorSteps: GradientBlockColorStep[];
  58907. /**
  58908. * Creates a new GradientBlock
  58909. * @param name defines the block name
  58910. */
  58911. constructor(name: string);
  58912. /**
  58913. * Gets the current class name
  58914. * @returns the class name
  58915. */
  58916. getClassName(): string;
  58917. /**
  58918. * Gets the gradient input component
  58919. */
  58920. readonly gradient: NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the output component
  58923. */
  58924. readonly output: NodeMaterialConnectionPoint;
  58925. private _writeColorConstant;
  58926. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58927. serialize(): any;
  58928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58929. protected _dumpPropertiesCode(): string;
  58930. }
  58931. }
  58932. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58936. /**
  58937. * Block used to normalize lerp between 2 values
  58938. */
  58939. export class NLerpBlock extends NodeMaterialBlock {
  58940. /**
  58941. * Creates a new NLerpBlock
  58942. * @param name defines the block name
  58943. */
  58944. constructor(name: string);
  58945. /**
  58946. * Gets the current class name
  58947. * @returns the class name
  58948. */
  58949. getClassName(): string;
  58950. /**
  58951. * Gets the left operand input component
  58952. */
  58953. readonly left: NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the right operand input component
  58956. */
  58957. readonly right: NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the gradient operand input component
  58960. */
  58961. readonly gradient: NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the output component
  58964. */
  58965. readonly output: NodeMaterialConnectionPoint;
  58966. protected _buildBlock(state: NodeMaterialBuildState): this;
  58967. }
  58968. }
  58969. declare module "babylonjs/Materials/Node/Blocks/frontFacingBlock" {
  58970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58973. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58974. /**
  58975. * Block used to test if the fragment shader is front facing
  58976. */
  58977. export class FrontFacingBlock extends NodeMaterialBlock {
  58978. /**
  58979. * Creates a new FrontFacingBlock
  58980. * @param name defines the block name
  58981. */
  58982. constructor(name: string);
  58983. /**
  58984. * Gets the current class name
  58985. * @returns the class name
  58986. */
  58987. getClassName(): string;
  58988. /**
  58989. * Gets the world normal component
  58990. */
  58991. readonly worldNormal: NodeMaterialConnectionPoint;
  58992. /**
  58993. * Gets the view direction input component
  58994. */
  58995. readonly viewDirection: NodeMaterialConnectionPoint;
  58996. /**
  58997. * Gets the output component
  58998. */
  58999. readonly output: NodeMaterialConnectionPoint;
  59000. autoConfigure(material: NodeMaterial): void;
  59001. protected _buildBlock(state: NodeMaterialBuildState): this;
  59002. }
  59003. }
  59004. declare module "babylonjs/Materials/Node/Blocks/index" {
  59005. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59006. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59007. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59008. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59009. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59010. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59011. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59012. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59013. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59014. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59015. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59016. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59017. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59018. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59019. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59020. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59021. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59022. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59023. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59024. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59025. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59026. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59027. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59028. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59029. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59030. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59031. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59032. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59033. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59034. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59035. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59036. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59037. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59038. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59039. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59040. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59041. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59042. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59043. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59044. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59045. export * from "babylonjs/Materials/Node/Blocks/frontFacingBlock";
  59046. }
  59047. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59048. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59049. }
  59050. declare module "babylonjs/Materials/Node/index" {
  59051. export * from "babylonjs/Materials/Node/Enums/index";
  59052. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59053. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59054. export * from "babylonjs/Materials/Node/nodeMaterial";
  59055. export * from "babylonjs/Materials/Node/Blocks/index";
  59056. export * from "babylonjs/Materials/Node/Optimizers/index";
  59057. }
  59058. declare module "babylonjs/Materials/effectRenderer" {
  59059. import { Nullable } from "babylonjs/types";
  59060. import { Texture } from "babylonjs/Materials/Textures/texture";
  59061. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59062. import { Viewport } from "babylonjs/Maths/math.viewport";
  59063. import { Observable } from "babylonjs/Misc/observable";
  59064. import { Effect } from "babylonjs/Materials/effect";
  59065. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59066. import "babylonjs/Shaders/postprocess.vertex";
  59067. /**
  59068. * Effect Render Options
  59069. */
  59070. export interface IEffectRendererOptions {
  59071. /**
  59072. * Defines the vertices positions.
  59073. */
  59074. positions?: number[];
  59075. /**
  59076. * Defines the indices.
  59077. */
  59078. indices?: number[];
  59079. }
  59080. /**
  59081. * Helper class to render one or more effects
  59082. */
  59083. export class EffectRenderer {
  59084. private engine;
  59085. private static _DefaultOptions;
  59086. private _vertexBuffers;
  59087. private _indexBuffer;
  59088. private _ringBufferIndex;
  59089. private _ringScreenBuffer;
  59090. private _fullscreenViewport;
  59091. private _getNextFrameBuffer;
  59092. /**
  59093. * Creates an effect renderer
  59094. * @param engine the engine to use for rendering
  59095. * @param options defines the options of the effect renderer
  59096. */
  59097. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59098. /**
  59099. * Sets the current viewport in normalized coordinates 0-1
  59100. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59101. */
  59102. setViewport(viewport?: Viewport): void;
  59103. /**
  59104. * Binds the embedded attributes buffer to the effect.
  59105. * @param effect Defines the effect to bind the attributes for
  59106. */
  59107. bindBuffers(effect: Effect): void;
  59108. /**
  59109. * Sets the current effect wrapper to use during draw.
  59110. * The effect needs to be ready before calling this api.
  59111. * This also sets the default full screen position attribute.
  59112. * @param effectWrapper Defines the effect to draw with
  59113. */
  59114. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59115. /**
  59116. * Draws a full screen quad.
  59117. */
  59118. draw(): void;
  59119. /**
  59120. * renders one or more effects to a specified texture
  59121. * @param effectWrappers list of effects to renderer
  59122. * @param outputTexture texture to draw to, if null it will render to the screen
  59123. */
  59124. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59125. /**
  59126. * Disposes of the effect renderer
  59127. */
  59128. dispose(): void;
  59129. }
  59130. /**
  59131. * Options to create an EffectWrapper
  59132. */
  59133. interface EffectWrapperCreationOptions {
  59134. /**
  59135. * Engine to use to create the effect
  59136. */
  59137. engine: ThinEngine;
  59138. /**
  59139. * Fragment shader for the effect
  59140. */
  59141. fragmentShader: string;
  59142. /**
  59143. * Vertex shader for the effect
  59144. */
  59145. vertexShader?: string;
  59146. /**
  59147. * Attributes to use in the shader
  59148. */
  59149. attributeNames?: Array<string>;
  59150. /**
  59151. * Uniforms to use in the shader
  59152. */
  59153. uniformNames?: Array<string>;
  59154. /**
  59155. * Texture sampler names to use in the shader
  59156. */
  59157. samplerNames?: Array<string>;
  59158. /**
  59159. * The friendly name of the effect displayed in Spector.
  59160. */
  59161. name?: string;
  59162. }
  59163. /**
  59164. * Wraps an effect to be used for rendering
  59165. */
  59166. export class EffectWrapper {
  59167. /**
  59168. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59169. */
  59170. onApplyObservable: Observable<{}>;
  59171. /**
  59172. * The underlying effect
  59173. */
  59174. effect: Effect;
  59175. /**
  59176. * Creates an effect to be renderer
  59177. * @param creationOptions options to create the effect
  59178. */
  59179. constructor(creationOptions: EffectWrapperCreationOptions);
  59180. /**
  59181. * Disposes of the effect wrapper
  59182. */
  59183. dispose(): void;
  59184. }
  59185. }
  59186. declare module "babylonjs/Materials/index" {
  59187. export * from "babylonjs/Materials/Background/index";
  59188. export * from "babylonjs/Materials/colorCurves";
  59189. export * from "babylonjs/Materials/iEffectFallbacks";
  59190. export * from "babylonjs/Materials/effectFallbacks";
  59191. export * from "babylonjs/Materials/effect";
  59192. export * from "babylonjs/Materials/fresnelParameters";
  59193. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59194. export * from "babylonjs/Materials/material";
  59195. export * from "babylonjs/Materials/materialDefines";
  59196. export * from "babylonjs/Materials/materialHelper";
  59197. export * from "babylonjs/Materials/multiMaterial";
  59198. export * from "babylonjs/Materials/PBR/index";
  59199. export * from "babylonjs/Materials/pushMaterial";
  59200. export * from "babylonjs/Materials/shaderMaterial";
  59201. export * from "babylonjs/Materials/standardMaterial";
  59202. export * from "babylonjs/Materials/Textures/index";
  59203. export * from "babylonjs/Materials/uniformBuffer";
  59204. export * from "babylonjs/Materials/materialFlags";
  59205. export * from "babylonjs/Materials/Node/index";
  59206. export * from "babylonjs/Materials/effectRenderer";
  59207. }
  59208. declare module "babylonjs/Maths/index" {
  59209. export * from "babylonjs/Maths/math.scalar";
  59210. export * from "babylonjs/Maths/math";
  59211. export * from "babylonjs/Maths/sphericalPolynomial";
  59212. }
  59213. declare module "babylonjs/Misc/workerPool" {
  59214. import { IDisposable } from "babylonjs/scene";
  59215. /**
  59216. * Helper class to push actions to a pool of workers.
  59217. */
  59218. export class WorkerPool implements IDisposable {
  59219. private _workerInfos;
  59220. private _pendingActions;
  59221. /**
  59222. * Constructor
  59223. * @param workers Array of workers to use for actions
  59224. */
  59225. constructor(workers: Array<Worker>);
  59226. /**
  59227. * Terminates all workers and clears any pending actions.
  59228. */
  59229. dispose(): void;
  59230. /**
  59231. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59232. * pended until a worker has completed its action.
  59233. * @param action The action to perform. Call onComplete when the action is complete.
  59234. */
  59235. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59236. private _execute;
  59237. }
  59238. }
  59239. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59240. import { IDisposable } from "babylonjs/scene";
  59241. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59242. /**
  59243. * Configuration for Draco compression
  59244. */
  59245. export interface IDracoCompressionConfiguration {
  59246. /**
  59247. * Configuration for the decoder.
  59248. */
  59249. decoder: {
  59250. /**
  59251. * The url to the WebAssembly module.
  59252. */
  59253. wasmUrl?: string;
  59254. /**
  59255. * The url to the WebAssembly binary.
  59256. */
  59257. wasmBinaryUrl?: string;
  59258. /**
  59259. * The url to the fallback JavaScript module.
  59260. */
  59261. fallbackUrl?: string;
  59262. };
  59263. }
  59264. /**
  59265. * Draco compression (https://google.github.io/draco/)
  59266. *
  59267. * This class wraps the Draco module.
  59268. *
  59269. * **Encoder**
  59270. *
  59271. * The encoder is not currently implemented.
  59272. *
  59273. * **Decoder**
  59274. *
  59275. * 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.
  59276. *
  59277. * To update the configuration, use the following code:
  59278. * ```javascript
  59279. * DracoCompression.Configuration = {
  59280. * decoder: {
  59281. * wasmUrl: "<url to the WebAssembly library>",
  59282. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59283. * fallbackUrl: "<url to the fallback JavaScript library>",
  59284. * }
  59285. * };
  59286. * ```
  59287. *
  59288. * 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.
  59289. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59290. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59291. *
  59292. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59293. * ```javascript
  59294. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59295. * ```
  59296. *
  59297. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59298. */
  59299. export class DracoCompression implements IDisposable {
  59300. private _workerPoolPromise?;
  59301. private _decoderModulePromise?;
  59302. /**
  59303. * The configuration. Defaults to the following urls:
  59304. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59305. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59306. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59307. */
  59308. static Configuration: IDracoCompressionConfiguration;
  59309. /**
  59310. * Returns true if the decoder configuration is available.
  59311. */
  59312. static readonly DecoderAvailable: boolean;
  59313. /**
  59314. * Default number of workers to create when creating the draco compression object.
  59315. */
  59316. static DefaultNumWorkers: number;
  59317. private static GetDefaultNumWorkers;
  59318. private static _Default;
  59319. /**
  59320. * Default instance for the draco compression object.
  59321. */
  59322. static readonly Default: DracoCompression;
  59323. /**
  59324. * Constructor
  59325. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59326. */
  59327. constructor(numWorkers?: number);
  59328. /**
  59329. * Stop all async operations and release resources.
  59330. */
  59331. dispose(): void;
  59332. /**
  59333. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59334. * @returns a promise that resolves when ready
  59335. */
  59336. whenReadyAsync(): Promise<void>;
  59337. /**
  59338. * Decode Draco compressed mesh data to vertex data.
  59339. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59340. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59341. * @returns A promise that resolves with the decoded vertex data
  59342. */
  59343. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59344. [kind: string]: number;
  59345. }): Promise<VertexData>;
  59346. }
  59347. }
  59348. declare module "babylonjs/Meshes/Compression/index" {
  59349. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59350. }
  59351. declare module "babylonjs/Meshes/csg" {
  59352. import { Nullable } from "babylonjs/types";
  59353. import { Scene } from "babylonjs/scene";
  59354. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59355. import { Mesh } from "babylonjs/Meshes/mesh";
  59356. import { Material } from "babylonjs/Materials/material";
  59357. /**
  59358. * Class for building Constructive Solid Geometry
  59359. */
  59360. export class CSG {
  59361. private polygons;
  59362. /**
  59363. * The world matrix
  59364. */
  59365. matrix: Matrix;
  59366. /**
  59367. * Stores the position
  59368. */
  59369. position: Vector3;
  59370. /**
  59371. * Stores the rotation
  59372. */
  59373. rotation: Vector3;
  59374. /**
  59375. * Stores the rotation quaternion
  59376. */
  59377. rotationQuaternion: Nullable<Quaternion>;
  59378. /**
  59379. * Stores the scaling vector
  59380. */
  59381. scaling: Vector3;
  59382. /**
  59383. * Convert the Mesh to CSG
  59384. * @param mesh The Mesh to convert to CSG
  59385. * @returns A new CSG from the Mesh
  59386. */
  59387. static FromMesh(mesh: Mesh): CSG;
  59388. /**
  59389. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59390. * @param polygons Polygons used to construct a CSG solid
  59391. */
  59392. private static FromPolygons;
  59393. /**
  59394. * Clones, or makes a deep copy, of the CSG
  59395. * @returns A new CSG
  59396. */
  59397. clone(): CSG;
  59398. /**
  59399. * Unions this CSG with another CSG
  59400. * @param csg The CSG to union against this CSG
  59401. * @returns The unioned CSG
  59402. */
  59403. union(csg: CSG): CSG;
  59404. /**
  59405. * Unions this CSG with another CSG in place
  59406. * @param csg The CSG to union against this CSG
  59407. */
  59408. unionInPlace(csg: CSG): void;
  59409. /**
  59410. * Subtracts this CSG with another CSG
  59411. * @param csg The CSG to subtract against this CSG
  59412. * @returns A new CSG
  59413. */
  59414. subtract(csg: CSG): CSG;
  59415. /**
  59416. * Subtracts this CSG with another CSG in place
  59417. * @param csg The CSG to subtact against this CSG
  59418. */
  59419. subtractInPlace(csg: CSG): void;
  59420. /**
  59421. * Intersect this CSG with another CSG
  59422. * @param csg The CSG to intersect against this CSG
  59423. * @returns A new CSG
  59424. */
  59425. intersect(csg: CSG): CSG;
  59426. /**
  59427. * Intersects this CSG with another CSG in place
  59428. * @param csg The CSG to intersect against this CSG
  59429. */
  59430. intersectInPlace(csg: CSG): void;
  59431. /**
  59432. * Return a new CSG solid with solid and empty space switched. This solid is
  59433. * not modified.
  59434. * @returns A new CSG solid with solid and empty space switched
  59435. */
  59436. inverse(): CSG;
  59437. /**
  59438. * Inverses the CSG in place
  59439. */
  59440. inverseInPlace(): void;
  59441. /**
  59442. * This is used to keep meshes transformations so they can be restored
  59443. * when we build back a Babylon Mesh
  59444. * NB : All CSG operations are performed in world coordinates
  59445. * @param csg The CSG to copy the transform attributes from
  59446. * @returns This CSG
  59447. */
  59448. copyTransformAttributes(csg: CSG): CSG;
  59449. /**
  59450. * Build Raw mesh from CSG
  59451. * Coordinates here are in world space
  59452. * @param name The name of the mesh geometry
  59453. * @param scene The Scene
  59454. * @param keepSubMeshes Specifies if the submeshes should be kept
  59455. * @returns A new Mesh
  59456. */
  59457. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59458. /**
  59459. * Build Mesh from CSG taking material and transforms into account
  59460. * @param name The name of the Mesh
  59461. * @param material The material of the Mesh
  59462. * @param scene The Scene
  59463. * @param keepSubMeshes Specifies if submeshes should be kept
  59464. * @returns The new Mesh
  59465. */
  59466. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59467. }
  59468. }
  59469. declare module "babylonjs/Meshes/trailMesh" {
  59470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59471. import { Mesh } from "babylonjs/Meshes/mesh";
  59472. import { Scene } from "babylonjs/scene";
  59473. /**
  59474. * Class used to create a trail following a mesh
  59475. */
  59476. export class TrailMesh extends Mesh {
  59477. private _generator;
  59478. private _autoStart;
  59479. private _running;
  59480. private _diameter;
  59481. private _length;
  59482. private _sectionPolygonPointsCount;
  59483. private _sectionVectors;
  59484. private _sectionNormalVectors;
  59485. private _beforeRenderObserver;
  59486. /**
  59487. * @constructor
  59488. * @param name The value used by scene.getMeshByName() to do a lookup.
  59489. * @param generator The mesh to generate a trail.
  59490. * @param scene The scene to add this mesh to.
  59491. * @param diameter Diameter of trailing mesh. Default is 1.
  59492. * @param length Length of trailing mesh. Default is 60.
  59493. * @param autoStart Automatically start trailing mesh. Default true.
  59494. */
  59495. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59496. /**
  59497. * "TrailMesh"
  59498. * @returns "TrailMesh"
  59499. */
  59500. getClassName(): string;
  59501. private _createMesh;
  59502. /**
  59503. * Start trailing mesh.
  59504. */
  59505. start(): void;
  59506. /**
  59507. * Stop trailing mesh.
  59508. */
  59509. stop(): void;
  59510. /**
  59511. * Update trailing mesh geometry.
  59512. */
  59513. update(): void;
  59514. /**
  59515. * Returns a new TrailMesh object.
  59516. * @param name is a string, the name given to the new mesh
  59517. * @param newGenerator use new generator object for cloned trail mesh
  59518. * @returns a new mesh
  59519. */
  59520. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59521. /**
  59522. * Serializes this trail mesh
  59523. * @param serializationObject object to write serialization to
  59524. */
  59525. serialize(serializationObject: any): void;
  59526. /**
  59527. * Parses a serialized trail mesh
  59528. * @param parsedMesh the serialized mesh
  59529. * @param scene the scene to create the trail mesh in
  59530. * @returns the created trail mesh
  59531. */
  59532. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59533. }
  59534. }
  59535. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59536. import { Nullable } from "babylonjs/types";
  59537. import { Scene } from "babylonjs/scene";
  59538. import { Vector4 } from "babylonjs/Maths/math.vector";
  59539. import { Color4 } from "babylonjs/Maths/math.color";
  59540. import { Mesh } from "babylonjs/Meshes/mesh";
  59541. /**
  59542. * Class containing static functions to help procedurally build meshes
  59543. */
  59544. export class TiledBoxBuilder {
  59545. /**
  59546. * Creates a box mesh
  59547. * 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)
  59548. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59552. * @param name defines the name of the mesh
  59553. * @param options defines the options used to create the mesh
  59554. * @param scene defines the hosting scene
  59555. * @returns the box mesh
  59556. */
  59557. static CreateTiledBox(name: string, options: {
  59558. pattern?: number;
  59559. width?: number;
  59560. height?: number;
  59561. depth?: number;
  59562. tileSize?: number;
  59563. tileWidth?: number;
  59564. tileHeight?: number;
  59565. alignHorizontal?: number;
  59566. alignVertical?: number;
  59567. faceUV?: Vector4[];
  59568. faceColors?: Color4[];
  59569. sideOrientation?: number;
  59570. updatable?: boolean;
  59571. }, scene?: Nullable<Scene>): Mesh;
  59572. }
  59573. }
  59574. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59575. import { Vector4 } from "babylonjs/Maths/math.vector";
  59576. import { Mesh } from "babylonjs/Meshes/mesh";
  59577. /**
  59578. * Class containing static functions to help procedurally build meshes
  59579. */
  59580. export class TorusKnotBuilder {
  59581. /**
  59582. * Creates a torus knot mesh
  59583. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59584. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59585. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59586. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59590. * @param name defines the name of the mesh
  59591. * @param options defines the options used to create the mesh
  59592. * @param scene defines the hosting scene
  59593. * @returns the torus knot mesh
  59594. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59595. */
  59596. static CreateTorusKnot(name: string, options: {
  59597. radius?: number;
  59598. tube?: number;
  59599. radialSegments?: number;
  59600. tubularSegments?: number;
  59601. p?: number;
  59602. q?: number;
  59603. updatable?: boolean;
  59604. sideOrientation?: number;
  59605. frontUVs?: Vector4;
  59606. backUVs?: Vector4;
  59607. }, scene: any): Mesh;
  59608. }
  59609. }
  59610. declare module "babylonjs/Meshes/polygonMesh" {
  59611. import { Scene } from "babylonjs/scene";
  59612. import { Vector2 } from "babylonjs/Maths/math.vector";
  59613. import { Mesh } from "babylonjs/Meshes/mesh";
  59614. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59615. import { Path2 } from "babylonjs/Maths/math.path";
  59616. /**
  59617. * Polygon
  59618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59619. */
  59620. export class Polygon {
  59621. /**
  59622. * Creates a rectangle
  59623. * @param xmin bottom X coord
  59624. * @param ymin bottom Y coord
  59625. * @param xmax top X coord
  59626. * @param ymax top Y coord
  59627. * @returns points that make the resulting rectation
  59628. */
  59629. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59630. /**
  59631. * Creates a circle
  59632. * @param radius radius of circle
  59633. * @param cx scale in x
  59634. * @param cy scale in y
  59635. * @param numberOfSides number of sides that make up the circle
  59636. * @returns points that make the resulting circle
  59637. */
  59638. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59639. /**
  59640. * Creates a polygon from input string
  59641. * @param input Input polygon data
  59642. * @returns the parsed points
  59643. */
  59644. static Parse(input: string): Vector2[];
  59645. /**
  59646. * Starts building a polygon from x and y coordinates
  59647. * @param x x coordinate
  59648. * @param y y coordinate
  59649. * @returns the started path2
  59650. */
  59651. static StartingAt(x: number, y: number): Path2;
  59652. }
  59653. /**
  59654. * Builds a polygon
  59655. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59656. */
  59657. export class PolygonMeshBuilder {
  59658. private _points;
  59659. private _outlinepoints;
  59660. private _holes;
  59661. private _name;
  59662. private _scene;
  59663. private _epoints;
  59664. private _eholes;
  59665. private _addToepoint;
  59666. /**
  59667. * Babylon reference to the earcut plugin.
  59668. */
  59669. bjsEarcut: any;
  59670. /**
  59671. * Creates a PolygonMeshBuilder
  59672. * @param name name of the builder
  59673. * @param contours Path of the polygon
  59674. * @param scene scene to add to when creating the mesh
  59675. * @param earcutInjection can be used to inject your own earcut reference
  59676. */
  59677. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59678. /**
  59679. * Adds a whole within the polygon
  59680. * @param hole Array of points defining the hole
  59681. * @returns this
  59682. */
  59683. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59684. /**
  59685. * Creates the polygon
  59686. * @param updatable If the mesh should be updatable
  59687. * @param depth The depth of the mesh created
  59688. * @returns the created mesh
  59689. */
  59690. build(updatable?: boolean, depth?: number): Mesh;
  59691. /**
  59692. * Creates the polygon
  59693. * @param depth The depth of the mesh created
  59694. * @returns the created VertexData
  59695. */
  59696. buildVertexData(depth?: number): VertexData;
  59697. /**
  59698. * Adds a side to the polygon
  59699. * @param positions points that make the polygon
  59700. * @param normals normals of the polygon
  59701. * @param uvs uvs of the polygon
  59702. * @param indices indices of the polygon
  59703. * @param bounds bounds of the polygon
  59704. * @param points points of the polygon
  59705. * @param depth depth of the polygon
  59706. * @param flip flip of the polygon
  59707. */
  59708. private addSide;
  59709. }
  59710. }
  59711. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59712. import { Scene } from "babylonjs/scene";
  59713. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59714. import { Color4 } from "babylonjs/Maths/math.color";
  59715. import { Mesh } from "babylonjs/Meshes/mesh";
  59716. import { Nullable } from "babylonjs/types";
  59717. /**
  59718. * Class containing static functions to help procedurally build meshes
  59719. */
  59720. export class PolygonBuilder {
  59721. /**
  59722. * Creates a polygon mesh
  59723. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59724. * * 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
  59725. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59728. * * Remember you can only change the shape positions, not their number when updating a polygon
  59729. * @param name defines the name of the mesh
  59730. * @param options defines the options used to create the mesh
  59731. * @param scene defines the hosting scene
  59732. * @param earcutInjection can be used to inject your own earcut reference
  59733. * @returns the polygon mesh
  59734. */
  59735. static CreatePolygon(name: string, options: {
  59736. shape: Vector3[];
  59737. holes?: Vector3[][];
  59738. depth?: number;
  59739. faceUV?: Vector4[];
  59740. faceColors?: Color4[];
  59741. updatable?: boolean;
  59742. sideOrientation?: number;
  59743. frontUVs?: Vector4;
  59744. backUVs?: Vector4;
  59745. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59746. /**
  59747. * Creates an extruded polygon mesh, with depth in the Y direction.
  59748. * * 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)
  59749. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59750. * @param name defines the name of the mesh
  59751. * @param options defines the options used to create the mesh
  59752. * @param scene defines the hosting scene
  59753. * @param earcutInjection can be used to inject your own earcut reference
  59754. * @returns the polygon mesh
  59755. */
  59756. static ExtrudePolygon(name: string, options: {
  59757. shape: Vector3[];
  59758. holes?: Vector3[][];
  59759. depth?: number;
  59760. faceUV?: Vector4[];
  59761. faceColors?: Color4[];
  59762. updatable?: boolean;
  59763. sideOrientation?: number;
  59764. frontUVs?: Vector4;
  59765. backUVs?: Vector4;
  59766. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59767. }
  59768. }
  59769. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59770. import { Scene } from "babylonjs/scene";
  59771. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59772. import { Mesh } from "babylonjs/Meshes/mesh";
  59773. import { Nullable } from "babylonjs/types";
  59774. /**
  59775. * Class containing static functions to help procedurally build meshes
  59776. */
  59777. export class LatheBuilder {
  59778. /**
  59779. * Creates lathe mesh.
  59780. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59781. * * 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
  59782. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59783. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59784. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59785. * * 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
  59786. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59787. * * 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
  59788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59792. * @param name defines the name of the mesh
  59793. * @param options defines the options used to create the mesh
  59794. * @param scene defines the hosting scene
  59795. * @returns the lathe mesh
  59796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59797. */
  59798. static CreateLathe(name: string, options: {
  59799. shape: Vector3[];
  59800. radius?: number;
  59801. tessellation?: number;
  59802. clip?: number;
  59803. arc?: number;
  59804. closed?: boolean;
  59805. updatable?: boolean;
  59806. sideOrientation?: number;
  59807. frontUVs?: Vector4;
  59808. backUVs?: Vector4;
  59809. cap?: number;
  59810. invertUV?: boolean;
  59811. }, scene?: Nullable<Scene>): Mesh;
  59812. }
  59813. }
  59814. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59815. import { Nullable } from "babylonjs/types";
  59816. import { Scene } from "babylonjs/scene";
  59817. import { Vector4 } from "babylonjs/Maths/math.vector";
  59818. import { Mesh } from "babylonjs/Meshes/mesh";
  59819. /**
  59820. * Class containing static functions to help procedurally build meshes
  59821. */
  59822. export class TiledPlaneBuilder {
  59823. /**
  59824. * Creates a tiled plane mesh
  59825. * * The parameter `pattern` will, depending on value, do nothing or
  59826. * * * flip (reflect about central vertical) alternate tiles across and up
  59827. * * * flip every tile on alternate rows
  59828. * * * rotate (180 degs) alternate tiles across and up
  59829. * * * rotate every tile on alternate rows
  59830. * * * flip and rotate alternate tiles across and up
  59831. * * * flip and rotate every tile on alternate rows
  59832. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59833. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59836. * * 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)
  59837. * * 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)
  59838. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59839. * @param name defines the name of the mesh
  59840. * @param options defines the options used to create the mesh
  59841. * @param scene defines the hosting scene
  59842. * @returns the box mesh
  59843. */
  59844. static CreateTiledPlane(name: string, options: {
  59845. pattern?: number;
  59846. tileSize?: number;
  59847. tileWidth?: number;
  59848. tileHeight?: number;
  59849. size?: number;
  59850. width?: number;
  59851. height?: number;
  59852. alignHorizontal?: number;
  59853. alignVertical?: number;
  59854. sideOrientation?: number;
  59855. frontUVs?: Vector4;
  59856. backUVs?: Vector4;
  59857. updatable?: boolean;
  59858. }, scene?: Nullable<Scene>): Mesh;
  59859. }
  59860. }
  59861. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59862. import { Nullable } from "babylonjs/types";
  59863. import { Scene } from "babylonjs/scene";
  59864. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59865. import { Mesh } from "babylonjs/Meshes/mesh";
  59866. /**
  59867. * Class containing static functions to help procedurally build meshes
  59868. */
  59869. export class TubeBuilder {
  59870. /**
  59871. * Creates a tube mesh.
  59872. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59873. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59874. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59875. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59876. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59877. * * 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)
  59878. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59879. * * 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
  59880. * * 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
  59881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59885. * @param name defines the name of the mesh
  59886. * @param options defines the options used to create the mesh
  59887. * @param scene defines the hosting scene
  59888. * @returns the tube mesh
  59889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59890. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59891. */
  59892. static CreateTube(name: string, options: {
  59893. path: Vector3[];
  59894. radius?: number;
  59895. tessellation?: number;
  59896. radiusFunction?: {
  59897. (i: number, distance: number): number;
  59898. };
  59899. cap?: number;
  59900. arc?: number;
  59901. updatable?: boolean;
  59902. sideOrientation?: number;
  59903. frontUVs?: Vector4;
  59904. backUVs?: Vector4;
  59905. instance?: Mesh;
  59906. invertUV?: boolean;
  59907. }, scene?: Nullable<Scene>): Mesh;
  59908. }
  59909. }
  59910. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59911. import { Scene } from "babylonjs/scene";
  59912. import { Vector4 } from "babylonjs/Maths/math.vector";
  59913. import { Mesh } from "babylonjs/Meshes/mesh";
  59914. import { Nullable } from "babylonjs/types";
  59915. /**
  59916. * Class containing static functions to help procedurally build meshes
  59917. */
  59918. export class IcoSphereBuilder {
  59919. /**
  59920. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59921. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59922. * * 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`)
  59923. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59924. * * 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
  59925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59928. * @param name defines the name of the mesh
  59929. * @param options defines the options used to create the mesh
  59930. * @param scene defines the hosting scene
  59931. * @returns the icosahedron mesh
  59932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59933. */
  59934. static CreateIcoSphere(name: string, options: {
  59935. radius?: number;
  59936. radiusX?: number;
  59937. radiusY?: number;
  59938. radiusZ?: number;
  59939. flat?: boolean;
  59940. subdivisions?: number;
  59941. sideOrientation?: number;
  59942. frontUVs?: Vector4;
  59943. backUVs?: Vector4;
  59944. updatable?: boolean;
  59945. }, scene?: Nullable<Scene>): Mesh;
  59946. }
  59947. }
  59948. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59949. import { Vector3 } from "babylonjs/Maths/math.vector";
  59950. import { Mesh } from "babylonjs/Meshes/mesh";
  59951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59952. /**
  59953. * Class containing static functions to help procedurally build meshes
  59954. */
  59955. export class DecalBuilder {
  59956. /**
  59957. * Creates a decal mesh.
  59958. * 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
  59959. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59960. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59961. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59962. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59963. * @param name defines the name of the mesh
  59964. * @param sourceMesh defines the mesh where the decal must be applied
  59965. * @param options defines the options used to create the mesh
  59966. * @param scene defines the hosting scene
  59967. * @returns the decal mesh
  59968. * @see https://doc.babylonjs.com/how_to/decals
  59969. */
  59970. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59971. position?: Vector3;
  59972. normal?: Vector3;
  59973. size?: Vector3;
  59974. angle?: number;
  59975. }): Mesh;
  59976. }
  59977. }
  59978. declare module "babylonjs/Meshes/meshBuilder" {
  59979. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59980. import { Nullable } from "babylonjs/types";
  59981. import { Scene } from "babylonjs/scene";
  59982. import { Mesh } from "babylonjs/Meshes/mesh";
  59983. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59984. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59986. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59987. import { Plane } from "babylonjs/Maths/math.plane";
  59988. /**
  59989. * Class containing static functions to help procedurally build meshes
  59990. */
  59991. export class MeshBuilder {
  59992. /**
  59993. * Creates a box mesh
  59994. * * The parameter `size` sets the size (float) of each box side (default 1)
  59995. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59996. * * 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)
  59997. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60001. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60002. * @param name defines the name of the mesh
  60003. * @param options defines the options used to create the mesh
  60004. * @param scene defines the hosting scene
  60005. * @returns the box mesh
  60006. */
  60007. static CreateBox(name: string, options: {
  60008. size?: number;
  60009. width?: number;
  60010. height?: number;
  60011. depth?: number;
  60012. faceUV?: Vector4[];
  60013. faceColors?: Color4[];
  60014. sideOrientation?: number;
  60015. frontUVs?: Vector4;
  60016. backUVs?: Vector4;
  60017. updatable?: boolean;
  60018. }, scene?: Nullable<Scene>): Mesh;
  60019. /**
  60020. * Creates a tiled box mesh
  60021. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60023. * @param name defines the name of the mesh
  60024. * @param options defines the options used to create the mesh
  60025. * @param scene defines the hosting scene
  60026. * @returns the tiled box mesh
  60027. */
  60028. static CreateTiledBox(name: string, options: {
  60029. pattern?: number;
  60030. size?: number;
  60031. width?: number;
  60032. height?: number;
  60033. depth: number;
  60034. tileSize?: number;
  60035. tileWidth?: number;
  60036. tileHeight?: number;
  60037. faceUV?: Vector4[];
  60038. faceColors?: Color4[];
  60039. alignHorizontal?: number;
  60040. alignVertical?: number;
  60041. sideOrientation?: number;
  60042. updatable?: boolean;
  60043. }, scene?: Nullable<Scene>): Mesh;
  60044. /**
  60045. * Creates a sphere mesh
  60046. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60047. * * 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`)
  60048. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60049. * * 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
  60050. * * 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)
  60051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60054. * @param name defines the name of the mesh
  60055. * @param options defines the options used to create the mesh
  60056. * @param scene defines the hosting scene
  60057. * @returns the sphere mesh
  60058. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60059. */
  60060. static CreateSphere(name: string, options: {
  60061. segments?: number;
  60062. diameter?: number;
  60063. diameterX?: number;
  60064. diameterY?: number;
  60065. diameterZ?: number;
  60066. arc?: number;
  60067. slice?: number;
  60068. sideOrientation?: number;
  60069. frontUVs?: Vector4;
  60070. backUVs?: Vector4;
  60071. updatable?: boolean;
  60072. }, scene?: Nullable<Scene>): Mesh;
  60073. /**
  60074. * Creates a plane polygonal mesh. By default, this is a disc
  60075. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60076. * * 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
  60077. * * 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
  60078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60081. * @param name defines the name of the mesh
  60082. * @param options defines the options used to create the mesh
  60083. * @param scene defines the hosting scene
  60084. * @returns the plane polygonal mesh
  60085. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60086. */
  60087. static CreateDisc(name: string, options: {
  60088. radius?: number;
  60089. tessellation?: number;
  60090. arc?: number;
  60091. updatable?: boolean;
  60092. sideOrientation?: number;
  60093. frontUVs?: Vector4;
  60094. backUVs?: Vector4;
  60095. }, scene?: Nullable<Scene>): Mesh;
  60096. /**
  60097. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60098. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60099. * * 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`)
  60100. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60101. * * 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
  60102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60105. * @param name defines the name of the mesh
  60106. * @param options defines the options used to create the mesh
  60107. * @param scene defines the hosting scene
  60108. * @returns the icosahedron mesh
  60109. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60110. */
  60111. static CreateIcoSphere(name: string, options: {
  60112. radius?: number;
  60113. radiusX?: number;
  60114. radiusY?: number;
  60115. radiusZ?: number;
  60116. flat?: boolean;
  60117. subdivisions?: number;
  60118. sideOrientation?: number;
  60119. frontUVs?: Vector4;
  60120. backUVs?: Vector4;
  60121. updatable?: boolean;
  60122. }, scene?: Nullable<Scene>): Mesh;
  60123. /**
  60124. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60125. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60126. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60127. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60128. * * 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
  60129. * * 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
  60130. * * 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
  60131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60134. * * 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
  60135. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60136. * * 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
  60137. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60139. * @param name defines the name of the mesh
  60140. * @param options defines the options used to create the mesh
  60141. * @param scene defines the hosting scene
  60142. * @returns the ribbon mesh
  60143. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60145. */
  60146. static CreateRibbon(name: string, options: {
  60147. pathArray: Vector3[][];
  60148. closeArray?: boolean;
  60149. closePath?: boolean;
  60150. offset?: number;
  60151. updatable?: boolean;
  60152. sideOrientation?: number;
  60153. frontUVs?: Vector4;
  60154. backUVs?: Vector4;
  60155. instance?: Mesh;
  60156. invertUV?: boolean;
  60157. uvs?: Vector2[];
  60158. colors?: Color4[];
  60159. }, scene?: Nullable<Scene>): Mesh;
  60160. /**
  60161. * Creates a cylinder or a cone mesh
  60162. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60163. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60164. * * 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.
  60165. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60166. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60167. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60168. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60169. * * 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).
  60170. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60171. * * 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).
  60172. * * 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
  60173. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60174. * * 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
  60175. * * 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.
  60176. * * If `enclose` is false, a ring surface is one element.
  60177. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60178. * * 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
  60179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60182. * @param name defines the name of the mesh
  60183. * @param options defines the options used to create the mesh
  60184. * @param scene defines the hosting scene
  60185. * @returns the cylinder mesh
  60186. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60187. */
  60188. static CreateCylinder(name: string, options: {
  60189. height?: number;
  60190. diameterTop?: number;
  60191. diameterBottom?: number;
  60192. diameter?: number;
  60193. tessellation?: number;
  60194. subdivisions?: number;
  60195. arc?: number;
  60196. faceColors?: Color4[];
  60197. faceUV?: Vector4[];
  60198. updatable?: boolean;
  60199. hasRings?: boolean;
  60200. enclose?: boolean;
  60201. cap?: number;
  60202. sideOrientation?: number;
  60203. frontUVs?: Vector4;
  60204. backUVs?: Vector4;
  60205. }, scene?: Nullable<Scene>): Mesh;
  60206. /**
  60207. * Creates a torus mesh
  60208. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60209. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60210. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60214. * @param name defines the name of the mesh
  60215. * @param options defines the options used to create the mesh
  60216. * @param scene defines the hosting scene
  60217. * @returns the torus mesh
  60218. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60219. */
  60220. static CreateTorus(name: string, options: {
  60221. diameter?: number;
  60222. thickness?: number;
  60223. tessellation?: number;
  60224. updatable?: boolean;
  60225. sideOrientation?: number;
  60226. frontUVs?: Vector4;
  60227. backUVs?: Vector4;
  60228. }, scene?: Nullable<Scene>): Mesh;
  60229. /**
  60230. * Creates a torus knot mesh
  60231. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60232. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60233. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60234. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60238. * @param name defines the name of the mesh
  60239. * @param options defines the options used to create the mesh
  60240. * @param scene defines the hosting scene
  60241. * @returns the torus knot mesh
  60242. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60243. */
  60244. static CreateTorusKnot(name: string, options: {
  60245. radius?: number;
  60246. tube?: number;
  60247. radialSegments?: number;
  60248. tubularSegments?: number;
  60249. p?: number;
  60250. q?: number;
  60251. updatable?: boolean;
  60252. sideOrientation?: number;
  60253. frontUVs?: Vector4;
  60254. backUVs?: Vector4;
  60255. }, scene?: Nullable<Scene>): Mesh;
  60256. /**
  60257. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60258. * * 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
  60259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60260. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60261. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60262. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60264. * * 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
  60265. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60268. * @param name defines the name of the new line system
  60269. * @param options defines the options used to create the line system
  60270. * @param scene defines the hosting scene
  60271. * @returns a new line system mesh
  60272. */
  60273. static CreateLineSystem(name: string, options: {
  60274. lines: Vector3[][];
  60275. updatable?: boolean;
  60276. instance?: Nullable<LinesMesh>;
  60277. colors?: Nullable<Color4[][]>;
  60278. useVertexAlpha?: boolean;
  60279. }, scene: Nullable<Scene>): LinesMesh;
  60280. /**
  60281. * Creates a line mesh
  60282. * 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
  60283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60284. * * The parameter `points` is an array successive Vector3
  60285. * * 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
  60286. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60288. * * When updating an instance, remember that only point positions can change, not the number of points
  60289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60291. * @param name defines the name of the new line system
  60292. * @param options defines the options used to create the line system
  60293. * @param scene defines the hosting scene
  60294. * @returns a new line mesh
  60295. */
  60296. static CreateLines(name: string, options: {
  60297. points: Vector3[];
  60298. updatable?: boolean;
  60299. instance?: Nullable<LinesMesh>;
  60300. colors?: Color4[];
  60301. useVertexAlpha?: boolean;
  60302. }, scene?: Nullable<Scene>): LinesMesh;
  60303. /**
  60304. * Creates a dashed line mesh
  60305. * * 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
  60306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60307. * * The parameter `points` is an array successive Vector3
  60308. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60309. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60310. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60311. * * 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
  60312. * * When updating an instance, remember that only point positions can change, not the number of points
  60313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60314. * @param name defines the name of the mesh
  60315. * @param options defines the options used to create the mesh
  60316. * @param scene defines the hosting scene
  60317. * @returns the dashed line mesh
  60318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60319. */
  60320. static CreateDashedLines(name: string, options: {
  60321. points: Vector3[];
  60322. dashSize?: number;
  60323. gapSize?: number;
  60324. dashNb?: number;
  60325. updatable?: boolean;
  60326. instance?: LinesMesh;
  60327. }, scene?: Nullable<Scene>): LinesMesh;
  60328. /**
  60329. * 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.
  60330. * * 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.
  60331. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60332. * * 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.
  60333. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60334. * * 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
  60335. * * 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
  60336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60341. * @param name defines the name of the mesh
  60342. * @param options defines the options used to create the mesh
  60343. * @param scene defines the hosting scene
  60344. * @returns the extruded shape mesh
  60345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60347. */
  60348. static ExtrudeShape(name: string, options: {
  60349. shape: Vector3[];
  60350. path: Vector3[];
  60351. scale?: number;
  60352. rotation?: number;
  60353. cap?: number;
  60354. updatable?: boolean;
  60355. sideOrientation?: number;
  60356. frontUVs?: Vector4;
  60357. backUVs?: Vector4;
  60358. instance?: Mesh;
  60359. invertUV?: boolean;
  60360. }, scene?: Nullable<Scene>): Mesh;
  60361. /**
  60362. * Creates an custom extruded shape mesh.
  60363. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60364. * * 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.
  60365. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60366. * * 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
  60367. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60368. * * 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
  60369. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60370. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60371. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60372. * * 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
  60373. * * 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
  60374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60379. * @param name defines the name of the mesh
  60380. * @param options defines the options used to create the mesh
  60381. * @param scene defines the hosting scene
  60382. * @returns the custom extruded shape mesh
  60383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60386. */
  60387. static ExtrudeShapeCustom(name: string, options: {
  60388. shape: Vector3[];
  60389. path: Vector3[];
  60390. scaleFunction?: any;
  60391. rotationFunction?: any;
  60392. ribbonCloseArray?: boolean;
  60393. ribbonClosePath?: boolean;
  60394. cap?: number;
  60395. updatable?: boolean;
  60396. sideOrientation?: number;
  60397. frontUVs?: Vector4;
  60398. backUVs?: Vector4;
  60399. instance?: Mesh;
  60400. invertUV?: boolean;
  60401. }, scene?: Nullable<Scene>): Mesh;
  60402. /**
  60403. * Creates lathe mesh.
  60404. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60405. * * 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
  60406. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60407. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60408. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60409. * * 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
  60410. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60411. * * 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
  60412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60416. * @param name defines the name of the mesh
  60417. * @param options defines the options used to create the mesh
  60418. * @param scene defines the hosting scene
  60419. * @returns the lathe mesh
  60420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60421. */
  60422. static CreateLathe(name: string, options: {
  60423. shape: Vector3[];
  60424. radius?: number;
  60425. tessellation?: number;
  60426. clip?: number;
  60427. arc?: number;
  60428. closed?: boolean;
  60429. updatable?: boolean;
  60430. sideOrientation?: number;
  60431. frontUVs?: Vector4;
  60432. backUVs?: Vector4;
  60433. cap?: number;
  60434. invertUV?: boolean;
  60435. }, scene?: Nullable<Scene>): Mesh;
  60436. /**
  60437. * Creates a tiled plane mesh
  60438. * * You can set a limited pattern arrangement with the tiles
  60439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60442. * @param name defines the name of the mesh
  60443. * @param options defines the options used to create the mesh
  60444. * @param scene defines the hosting scene
  60445. * @returns the plane mesh
  60446. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60447. */
  60448. static CreateTiledPlane(name: string, options: {
  60449. pattern?: number;
  60450. tileSize?: number;
  60451. tileWidth?: number;
  60452. tileHeight?: number;
  60453. size?: number;
  60454. width?: number;
  60455. height?: number;
  60456. alignHorizontal?: number;
  60457. alignVertical?: number;
  60458. sideOrientation?: number;
  60459. frontUVs?: Vector4;
  60460. backUVs?: Vector4;
  60461. updatable?: boolean;
  60462. }, scene?: Nullable<Scene>): Mesh;
  60463. /**
  60464. * Creates a plane mesh
  60465. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60466. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60467. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60471. * @param name defines the name of the mesh
  60472. * @param options defines the options used to create the mesh
  60473. * @param scene defines the hosting scene
  60474. * @returns the plane mesh
  60475. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60476. */
  60477. static CreatePlane(name: string, options: {
  60478. size?: number;
  60479. width?: number;
  60480. height?: number;
  60481. sideOrientation?: number;
  60482. frontUVs?: Vector4;
  60483. backUVs?: Vector4;
  60484. updatable?: boolean;
  60485. sourcePlane?: Plane;
  60486. }, scene?: Nullable<Scene>): Mesh;
  60487. /**
  60488. * Creates a ground mesh
  60489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60492. * @param name defines the name of the mesh
  60493. * @param options defines the options used to create the mesh
  60494. * @param scene defines the hosting scene
  60495. * @returns the ground mesh
  60496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60497. */
  60498. static CreateGround(name: string, options: {
  60499. width?: number;
  60500. height?: number;
  60501. subdivisions?: number;
  60502. subdivisionsX?: number;
  60503. subdivisionsY?: number;
  60504. updatable?: boolean;
  60505. }, scene?: Nullable<Scene>): Mesh;
  60506. /**
  60507. * Creates a tiled ground mesh
  60508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60510. * * 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
  60511. * * 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
  60512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60513. * @param name defines the name of the mesh
  60514. * @param options defines the options used to create the mesh
  60515. * @param scene defines the hosting scene
  60516. * @returns the tiled ground mesh
  60517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60518. */
  60519. static CreateTiledGround(name: string, options: {
  60520. xmin: number;
  60521. zmin: number;
  60522. xmax: number;
  60523. zmax: number;
  60524. subdivisions?: {
  60525. w: number;
  60526. h: number;
  60527. };
  60528. precision?: {
  60529. w: number;
  60530. h: number;
  60531. };
  60532. updatable?: boolean;
  60533. }, scene?: Nullable<Scene>): Mesh;
  60534. /**
  60535. * Creates a ground mesh from a height map
  60536. * * The parameter `url` sets the URL of the height map image resource.
  60537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60541. * * 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.
  60542. * * 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).
  60543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60545. * @param name defines the name of the mesh
  60546. * @param url defines the url to the height map
  60547. * @param options defines the options used to create the mesh
  60548. * @param scene defines the hosting scene
  60549. * @returns the ground mesh
  60550. * @see https://doc.babylonjs.com/babylon101/height_map
  60551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60552. */
  60553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60554. width?: number;
  60555. height?: number;
  60556. subdivisions?: number;
  60557. minHeight?: number;
  60558. maxHeight?: number;
  60559. colorFilter?: Color3;
  60560. alphaFilter?: number;
  60561. updatable?: boolean;
  60562. onReady?: (mesh: GroundMesh) => void;
  60563. }, scene?: Nullable<Scene>): GroundMesh;
  60564. /**
  60565. * Creates a polygon mesh
  60566. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60567. * * 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
  60568. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60571. * * Remember you can only change the shape positions, not their number when updating a polygon
  60572. * @param name defines the name of the mesh
  60573. * @param options defines the options used to create the mesh
  60574. * @param scene defines the hosting scene
  60575. * @param earcutInjection can be used to inject your own earcut reference
  60576. * @returns the polygon mesh
  60577. */
  60578. static CreatePolygon(name: string, options: {
  60579. shape: Vector3[];
  60580. holes?: Vector3[][];
  60581. depth?: number;
  60582. faceUV?: Vector4[];
  60583. faceColors?: Color4[];
  60584. updatable?: boolean;
  60585. sideOrientation?: number;
  60586. frontUVs?: Vector4;
  60587. backUVs?: Vector4;
  60588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60589. /**
  60590. * Creates an extruded polygon mesh, with depth in the Y direction.
  60591. * * 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)
  60592. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60593. * @param name defines the name of the mesh
  60594. * @param options defines the options used to create the mesh
  60595. * @param scene defines the hosting scene
  60596. * @param earcutInjection can be used to inject your own earcut reference
  60597. * @returns the polygon mesh
  60598. */
  60599. static ExtrudePolygon(name: string, options: {
  60600. shape: Vector3[];
  60601. holes?: Vector3[][];
  60602. depth?: number;
  60603. faceUV?: Vector4[];
  60604. faceColors?: Color4[];
  60605. updatable?: boolean;
  60606. sideOrientation?: number;
  60607. frontUVs?: Vector4;
  60608. backUVs?: Vector4;
  60609. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60610. /**
  60611. * Creates a tube mesh.
  60612. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60613. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60614. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60615. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60616. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60617. * * 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)
  60618. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60619. * * 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
  60620. * * 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
  60621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60625. * @param name defines the name of the mesh
  60626. * @param options defines the options used to create the mesh
  60627. * @param scene defines the hosting scene
  60628. * @returns the tube mesh
  60629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60630. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60631. */
  60632. static CreateTube(name: string, options: {
  60633. path: Vector3[];
  60634. radius?: number;
  60635. tessellation?: number;
  60636. radiusFunction?: {
  60637. (i: number, distance: number): number;
  60638. };
  60639. cap?: number;
  60640. arc?: number;
  60641. updatable?: boolean;
  60642. sideOrientation?: number;
  60643. frontUVs?: Vector4;
  60644. backUVs?: Vector4;
  60645. instance?: Mesh;
  60646. invertUV?: boolean;
  60647. }, scene?: Nullable<Scene>): Mesh;
  60648. /**
  60649. * Creates a polyhedron mesh
  60650. * * 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
  60651. * * The parameter `size` (positive float, default 1) sets the polygon size
  60652. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60653. * * 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`
  60654. * * 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
  60655. * * 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)`)
  60656. * * 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
  60657. * * 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
  60658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60661. * @param name defines the name of the mesh
  60662. * @param options defines the options used to create the mesh
  60663. * @param scene defines the hosting scene
  60664. * @returns the polyhedron mesh
  60665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60666. */
  60667. static CreatePolyhedron(name: string, options: {
  60668. type?: number;
  60669. size?: number;
  60670. sizeX?: number;
  60671. sizeY?: number;
  60672. sizeZ?: number;
  60673. custom?: any;
  60674. faceUV?: Vector4[];
  60675. faceColors?: Color4[];
  60676. flat?: boolean;
  60677. updatable?: boolean;
  60678. sideOrientation?: number;
  60679. frontUVs?: Vector4;
  60680. backUVs?: Vector4;
  60681. }, scene?: Nullable<Scene>): Mesh;
  60682. /**
  60683. * Creates a decal mesh.
  60684. * 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
  60685. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60686. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60687. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60688. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60689. * @param name defines the name of the mesh
  60690. * @param sourceMesh defines the mesh where the decal must be applied
  60691. * @param options defines the options used to create the mesh
  60692. * @param scene defines the hosting scene
  60693. * @returns the decal mesh
  60694. * @see https://doc.babylonjs.com/how_to/decals
  60695. */
  60696. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60697. position?: Vector3;
  60698. normal?: Vector3;
  60699. size?: Vector3;
  60700. angle?: number;
  60701. }): Mesh;
  60702. }
  60703. }
  60704. declare module "babylonjs/Meshes/meshSimplification" {
  60705. import { Mesh } from "babylonjs/Meshes/mesh";
  60706. /**
  60707. * A simplifier interface for future simplification implementations
  60708. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60709. */
  60710. export interface ISimplifier {
  60711. /**
  60712. * Simplification of a given mesh according to the given settings.
  60713. * Since this requires computation, it is assumed that the function runs async.
  60714. * @param settings The settings of the simplification, including quality and distance
  60715. * @param successCallback A callback that will be called after the mesh was simplified.
  60716. * @param errorCallback in case of an error, this callback will be called. optional.
  60717. */
  60718. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60719. }
  60720. /**
  60721. * Expected simplification settings.
  60722. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60723. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60724. */
  60725. export interface ISimplificationSettings {
  60726. /**
  60727. * Gets or sets the expected quality
  60728. */
  60729. quality: number;
  60730. /**
  60731. * Gets or sets the distance when this optimized version should be used
  60732. */
  60733. distance: number;
  60734. /**
  60735. * Gets an already optimized mesh
  60736. */
  60737. optimizeMesh?: boolean;
  60738. }
  60739. /**
  60740. * Class used to specify simplification options
  60741. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60742. */
  60743. export class SimplificationSettings implements ISimplificationSettings {
  60744. /** expected quality */
  60745. quality: number;
  60746. /** distance when this optimized version should be used */
  60747. distance: number;
  60748. /** already optimized mesh */
  60749. optimizeMesh?: boolean | undefined;
  60750. /**
  60751. * Creates a SimplificationSettings
  60752. * @param quality expected quality
  60753. * @param distance distance when this optimized version should be used
  60754. * @param optimizeMesh already optimized mesh
  60755. */
  60756. constructor(
  60757. /** expected quality */
  60758. quality: number,
  60759. /** distance when this optimized version should be used */
  60760. distance: number,
  60761. /** already optimized mesh */
  60762. optimizeMesh?: boolean | undefined);
  60763. }
  60764. /**
  60765. * Interface used to define a simplification task
  60766. */
  60767. export interface ISimplificationTask {
  60768. /**
  60769. * Array of settings
  60770. */
  60771. settings: Array<ISimplificationSettings>;
  60772. /**
  60773. * Simplification type
  60774. */
  60775. simplificationType: SimplificationType;
  60776. /**
  60777. * Mesh to simplify
  60778. */
  60779. mesh: Mesh;
  60780. /**
  60781. * Callback called on success
  60782. */
  60783. successCallback?: () => void;
  60784. /**
  60785. * Defines if parallel processing can be used
  60786. */
  60787. parallelProcessing: boolean;
  60788. }
  60789. /**
  60790. * Queue used to order the simplification tasks
  60791. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60792. */
  60793. export class SimplificationQueue {
  60794. private _simplificationArray;
  60795. /**
  60796. * Gets a boolean indicating that the process is still running
  60797. */
  60798. running: boolean;
  60799. /**
  60800. * Creates a new queue
  60801. */
  60802. constructor();
  60803. /**
  60804. * Adds a new simplification task
  60805. * @param task defines a task to add
  60806. */
  60807. addTask(task: ISimplificationTask): void;
  60808. /**
  60809. * Execute next task
  60810. */
  60811. executeNext(): void;
  60812. /**
  60813. * Execute a simplification task
  60814. * @param task defines the task to run
  60815. */
  60816. runSimplification(task: ISimplificationTask): void;
  60817. private getSimplifier;
  60818. }
  60819. /**
  60820. * The implemented types of simplification
  60821. * At the moment only Quadratic Error Decimation is implemented
  60822. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60823. */
  60824. export enum SimplificationType {
  60825. /** Quadratic error decimation */
  60826. QUADRATIC = 0
  60827. }
  60828. }
  60829. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60830. import { Scene } from "babylonjs/scene";
  60831. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60832. import { ISceneComponent } from "babylonjs/sceneComponent";
  60833. module "babylonjs/scene" {
  60834. interface Scene {
  60835. /** @hidden (Backing field) */
  60836. _simplificationQueue: SimplificationQueue;
  60837. /**
  60838. * Gets or sets the simplification queue attached to the scene
  60839. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60840. */
  60841. simplificationQueue: SimplificationQueue;
  60842. }
  60843. }
  60844. module "babylonjs/Meshes/mesh" {
  60845. interface Mesh {
  60846. /**
  60847. * Simplify the mesh according to the given array of settings.
  60848. * Function will return immediately and will simplify async
  60849. * @param settings a collection of simplification settings
  60850. * @param parallelProcessing should all levels calculate parallel or one after the other
  60851. * @param simplificationType the type of simplification to run
  60852. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60853. * @returns the current mesh
  60854. */
  60855. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60856. }
  60857. }
  60858. /**
  60859. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60860. * created in a scene
  60861. */
  60862. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60863. /**
  60864. * The component name helpfull to identify the component in the list of scene components.
  60865. */
  60866. readonly name: string;
  60867. /**
  60868. * The scene the component belongs to.
  60869. */
  60870. scene: Scene;
  60871. /**
  60872. * Creates a new instance of the component for the given scene
  60873. * @param scene Defines the scene to register the component in
  60874. */
  60875. constructor(scene: Scene);
  60876. /**
  60877. * Registers the component in a given scene
  60878. */
  60879. register(): void;
  60880. /**
  60881. * Rebuilds the elements related to this component in case of
  60882. * context lost for instance.
  60883. */
  60884. rebuild(): void;
  60885. /**
  60886. * Disposes the component and the associated ressources
  60887. */
  60888. dispose(): void;
  60889. private _beforeCameraUpdate;
  60890. }
  60891. }
  60892. declare module "babylonjs/Meshes/Builders/index" {
  60893. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60894. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60895. export * from "babylonjs/Meshes/Builders/discBuilder";
  60896. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60897. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60898. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60899. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60900. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60901. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60902. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60903. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60904. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60905. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60906. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60907. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60908. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60909. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60910. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60911. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60912. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60913. }
  60914. declare module "babylonjs/Meshes/index" {
  60915. export * from "babylonjs/Meshes/abstractMesh";
  60916. export * from "babylonjs/Meshes/buffer";
  60917. export * from "babylonjs/Meshes/Compression/index";
  60918. export * from "babylonjs/Meshes/csg";
  60919. export * from "babylonjs/Meshes/geometry";
  60920. export * from "babylonjs/Meshes/groundMesh";
  60921. export * from "babylonjs/Meshes/trailMesh";
  60922. export * from "babylonjs/Meshes/instancedMesh";
  60923. export * from "babylonjs/Meshes/linesMesh";
  60924. export * from "babylonjs/Meshes/mesh";
  60925. export * from "babylonjs/Meshes/mesh.vertexData";
  60926. export * from "babylonjs/Meshes/meshBuilder";
  60927. export * from "babylonjs/Meshes/meshSimplification";
  60928. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60929. export * from "babylonjs/Meshes/polygonMesh";
  60930. export * from "babylonjs/Meshes/subMesh";
  60931. export * from "babylonjs/Meshes/meshLODLevel";
  60932. export * from "babylonjs/Meshes/transformNode";
  60933. export * from "babylonjs/Meshes/Builders/index";
  60934. export * from "babylonjs/Meshes/dataBuffer";
  60935. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60936. }
  60937. declare module "babylonjs/Morph/index" {
  60938. export * from "babylonjs/Morph/morphTarget";
  60939. export * from "babylonjs/Morph/morphTargetManager";
  60940. }
  60941. declare module "babylonjs/Navigation/INavigationEngine" {
  60942. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60943. import { Vector3 } from "babylonjs/Maths/math";
  60944. import { Mesh } from "babylonjs/Meshes/mesh";
  60945. import { Scene } from "babylonjs/scene";
  60946. /**
  60947. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60948. */
  60949. export interface INavigationEnginePlugin {
  60950. /**
  60951. * plugin name
  60952. */
  60953. name: string;
  60954. /**
  60955. * Creates a navigation mesh
  60956. * @param meshes array of all the geometry used to compute the navigatio mesh
  60957. * @param parameters bunch of parameters used to filter geometry
  60958. */
  60959. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60960. /**
  60961. * Create a navigation mesh debug mesh
  60962. * @param scene is where the mesh will be added
  60963. * @returns debug display mesh
  60964. */
  60965. createDebugNavMesh(scene: Scene): Mesh;
  60966. /**
  60967. * Get a navigation mesh constrained position, closest to the parameter position
  60968. * @param position world position
  60969. * @returns the closest point to position constrained by the navigation mesh
  60970. */
  60971. getClosestPoint(position: Vector3): Vector3;
  60972. /**
  60973. * Get a navigation mesh constrained position, within a particular radius
  60974. * @param position world position
  60975. * @param maxRadius the maximum distance to the constrained world position
  60976. * @returns the closest point to position constrained by the navigation mesh
  60977. */
  60978. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60979. /**
  60980. * Compute the final position from a segment made of destination-position
  60981. * @param position world position
  60982. * @param destination world position
  60983. * @returns the resulting point along the navmesh
  60984. */
  60985. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60986. /**
  60987. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60988. * @param start world position
  60989. * @param end world position
  60990. * @returns array containing world position composing the path
  60991. */
  60992. computePath(start: Vector3, end: Vector3): Vector3[];
  60993. /**
  60994. * If this plugin is supported
  60995. * @returns true if plugin is supported
  60996. */
  60997. isSupported(): boolean;
  60998. /**
  60999. * Create a new Crowd so you can add agents
  61000. * @param maxAgents the maximum agent count in the crowd
  61001. * @param maxAgentRadius the maximum radius an agent can have
  61002. * @param scene to attach the crowd to
  61003. * @returns the crowd you can add agents to
  61004. */
  61005. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61006. /**
  61007. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61008. * The queries will try to find a solution within those bounds
  61009. * default is (1,1,1)
  61010. * @param extent x,y,z value that define the extent around the queries point of reference
  61011. */
  61012. setDefaultQueryExtent(extent: Vector3): void;
  61013. /**
  61014. * Get the Bounding box extent specified by setDefaultQueryExtent
  61015. * @returns the box extent values
  61016. */
  61017. getDefaultQueryExtent(): Vector3;
  61018. /**
  61019. * Release all resources
  61020. */
  61021. dispose(): void;
  61022. }
  61023. /**
  61024. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61025. */
  61026. export interface ICrowd {
  61027. /**
  61028. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61029. * You can attach anything to that node. The node position is updated in the scene update tick.
  61030. * @param pos world position that will be constrained by the navigation mesh
  61031. * @param parameters agent parameters
  61032. * @param transform hooked to the agent that will be update by the scene
  61033. * @returns agent index
  61034. */
  61035. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61036. /**
  61037. * Returns the agent position in world space
  61038. * @param index agent index returned by addAgent
  61039. * @returns world space position
  61040. */
  61041. getAgentPosition(index: number): Vector3;
  61042. /**
  61043. * Gets the agent velocity in world space
  61044. * @param index agent index returned by addAgent
  61045. * @returns world space velocity
  61046. */
  61047. getAgentVelocity(index: number): Vector3;
  61048. /**
  61049. * remove a particular agent previously created
  61050. * @param index agent index returned by addAgent
  61051. */
  61052. removeAgent(index: number): void;
  61053. /**
  61054. * get the list of all agents attached to this crowd
  61055. * @returns list of agent indices
  61056. */
  61057. getAgents(): number[];
  61058. /**
  61059. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61060. * @param deltaTime in seconds
  61061. */
  61062. update(deltaTime: number): void;
  61063. /**
  61064. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61065. * @param index agent index returned by addAgent
  61066. * @param destination targeted world position
  61067. */
  61068. agentGoto(index: number, destination: Vector3): void;
  61069. /**
  61070. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61071. * The queries will try to find a solution within those bounds
  61072. * default is (1,1,1)
  61073. * @param extent x,y,z value that define the extent around the queries point of reference
  61074. */
  61075. setDefaultQueryExtent(extent: Vector3): void;
  61076. /**
  61077. * Get the Bounding box extent specified by setDefaultQueryExtent
  61078. * @returns the box extent values
  61079. */
  61080. getDefaultQueryExtent(): Vector3;
  61081. /**
  61082. * Release all resources
  61083. */
  61084. dispose(): void;
  61085. }
  61086. /**
  61087. * Configures an agent
  61088. */
  61089. export interface IAgentParameters {
  61090. /**
  61091. * Agent radius. [Limit: >= 0]
  61092. */
  61093. radius: number;
  61094. /**
  61095. * Agent height. [Limit: > 0]
  61096. */
  61097. height: number;
  61098. /**
  61099. * Maximum allowed acceleration. [Limit: >= 0]
  61100. */
  61101. maxAcceleration: number;
  61102. /**
  61103. * Maximum allowed speed. [Limit: >= 0]
  61104. */
  61105. maxSpeed: number;
  61106. /**
  61107. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61108. */
  61109. collisionQueryRange: number;
  61110. /**
  61111. * The path visibility optimization range. [Limit: > 0]
  61112. */
  61113. pathOptimizationRange: number;
  61114. /**
  61115. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61116. */
  61117. separationWeight: number;
  61118. }
  61119. /**
  61120. * Configures the navigation mesh creation
  61121. */
  61122. export interface INavMeshParameters {
  61123. /**
  61124. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61125. */
  61126. cs: number;
  61127. /**
  61128. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61129. */
  61130. ch: number;
  61131. /**
  61132. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61133. */
  61134. walkableSlopeAngle: number;
  61135. /**
  61136. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61137. * be considered walkable. [Limit: >= 3] [Units: vx]
  61138. */
  61139. walkableHeight: number;
  61140. /**
  61141. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61142. */
  61143. walkableClimb: number;
  61144. /**
  61145. * The distance to erode/shrink the walkable area of the heightfield away from
  61146. * obstructions. [Limit: >=0] [Units: vx]
  61147. */
  61148. walkableRadius: number;
  61149. /**
  61150. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61151. */
  61152. maxEdgeLen: number;
  61153. /**
  61154. * The maximum distance a simplfied contour's border edges should deviate
  61155. * the original raw contour. [Limit: >=0] [Units: vx]
  61156. */
  61157. maxSimplificationError: number;
  61158. /**
  61159. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61160. */
  61161. minRegionArea: number;
  61162. /**
  61163. * Any regions with a span count smaller than this value will, if possible,
  61164. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61165. */
  61166. mergeRegionArea: number;
  61167. /**
  61168. * The maximum number of vertices allowed for polygons generated during the
  61169. * contour to polygon conversion process. [Limit: >= 3]
  61170. */
  61171. maxVertsPerPoly: number;
  61172. /**
  61173. * Sets the sampling distance to use when generating the detail mesh.
  61174. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61175. */
  61176. detailSampleDist: number;
  61177. /**
  61178. * The maximum distance the detail mesh surface should deviate from heightfield
  61179. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61180. */
  61181. detailSampleMaxError: number;
  61182. }
  61183. }
  61184. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61185. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61186. import { Mesh } from "babylonjs/Meshes/mesh";
  61187. import { Scene } from "babylonjs/scene";
  61188. import { Vector3 } from "babylonjs/Maths/math";
  61189. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61190. /**
  61191. * RecastJS navigation plugin
  61192. */
  61193. export class RecastJSPlugin implements INavigationEnginePlugin {
  61194. /**
  61195. * Reference to the Recast library
  61196. */
  61197. bjsRECAST: any;
  61198. /**
  61199. * plugin name
  61200. */
  61201. name: string;
  61202. /**
  61203. * the first navmesh created. We might extend this to support multiple navmeshes
  61204. */
  61205. navMesh: any;
  61206. /**
  61207. * Initializes the recastJS plugin
  61208. * @param recastInjection can be used to inject your own recast reference
  61209. */
  61210. constructor(recastInjection?: any);
  61211. /**
  61212. * Creates a navigation mesh
  61213. * @param meshes array of all the geometry used to compute the navigatio mesh
  61214. * @param parameters bunch of parameters used to filter geometry
  61215. */
  61216. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61217. /**
  61218. * Create a navigation mesh debug mesh
  61219. * @param scene is where the mesh will be added
  61220. * @returns debug display mesh
  61221. */
  61222. createDebugNavMesh(scene: Scene): Mesh;
  61223. /**
  61224. * Get a navigation mesh constrained position, closest to the parameter position
  61225. * @param position world position
  61226. * @returns the closest point to position constrained by the navigation mesh
  61227. */
  61228. getClosestPoint(position: Vector3): Vector3;
  61229. /**
  61230. * Get a navigation mesh constrained position, within a particular radius
  61231. * @param position world position
  61232. * @param maxRadius the maximum distance to the constrained world position
  61233. * @returns the closest point to position constrained by the navigation mesh
  61234. */
  61235. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61236. /**
  61237. * Compute the final position from a segment made of destination-position
  61238. * @param position world position
  61239. * @param destination world position
  61240. * @returns the resulting point along the navmesh
  61241. */
  61242. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61243. /**
  61244. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61245. * @param start world position
  61246. * @param end world position
  61247. * @returns array containing world position composing the path
  61248. */
  61249. computePath(start: Vector3, end: Vector3): Vector3[];
  61250. /**
  61251. * Create a new Crowd so you can add agents
  61252. * @param maxAgents the maximum agent count in the crowd
  61253. * @param maxAgentRadius the maximum radius an agent can have
  61254. * @param scene to attach the crowd to
  61255. * @returns the crowd you can add agents to
  61256. */
  61257. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61258. /**
  61259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61260. * The queries will try to find a solution within those bounds
  61261. * default is (1,1,1)
  61262. * @param extent x,y,z value that define the extent around the queries point of reference
  61263. */
  61264. setDefaultQueryExtent(extent: Vector3): void;
  61265. /**
  61266. * Get the Bounding box extent specified by setDefaultQueryExtent
  61267. * @returns the box extent values
  61268. */
  61269. getDefaultQueryExtent(): Vector3;
  61270. /**
  61271. * Disposes
  61272. */
  61273. dispose(): void;
  61274. /**
  61275. * If this plugin is supported
  61276. * @returns true if plugin is supported
  61277. */
  61278. isSupported(): boolean;
  61279. }
  61280. /**
  61281. * Recast detour crowd implementation
  61282. */
  61283. export class RecastJSCrowd implements ICrowd {
  61284. /**
  61285. * Recast/detour plugin
  61286. */
  61287. bjsRECASTPlugin: RecastJSPlugin;
  61288. /**
  61289. * Link to the detour crowd
  61290. */
  61291. recastCrowd: any;
  61292. /**
  61293. * One transform per agent
  61294. */
  61295. transforms: TransformNode[];
  61296. /**
  61297. * All agents created
  61298. */
  61299. agents: number[];
  61300. /**
  61301. * Link to the scene is kept to unregister the crowd from the scene
  61302. */
  61303. private _scene;
  61304. /**
  61305. * Observer for crowd updates
  61306. */
  61307. private _onBeforeAnimationsObserver;
  61308. /**
  61309. * Constructor
  61310. * @param plugin recastJS plugin
  61311. * @param maxAgents the maximum agent count in the crowd
  61312. * @param maxAgentRadius the maximum radius an agent can have
  61313. * @param scene to attach the crowd to
  61314. * @returns the crowd you can add agents to
  61315. */
  61316. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61317. /**
  61318. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61319. * You can attach anything to that node. The node position is updated in the scene update tick.
  61320. * @param pos world position that will be constrained by the navigation mesh
  61321. * @param parameters agent parameters
  61322. * @param transform hooked to the agent that will be update by the scene
  61323. * @returns agent index
  61324. */
  61325. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61326. /**
  61327. * Returns the agent position in world space
  61328. * @param index agent index returned by addAgent
  61329. * @returns world space position
  61330. */
  61331. getAgentPosition(index: number): Vector3;
  61332. /**
  61333. * Returns the agent velocity in world space
  61334. * @param index agent index returned by addAgent
  61335. * @returns world space velocity
  61336. */
  61337. getAgentVelocity(index: number): Vector3;
  61338. /**
  61339. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61340. * @param index agent index returned by addAgent
  61341. * @param destination targeted world position
  61342. */
  61343. agentGoto(index: number, destination: Vector3): void;
  61344. /**
  61345. * remove a particular agent previously created
  61346. * @param index agent index returned by addAgent
  61347. */
  61348. removeAgent(index: number): void;
  61349. /**
  61350. * get the list of all agents attached to this crowd
  61351. * @returns list of agent indices
  61352. */
  61353. getAgents(): number[];
  61354. /**
  61355. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61356. * @param deltaTime in seconds
  61357. */
  61358. update(deltaTime: number): void;
  61359. /**
  61360. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61361. * The queries will try to find a solution within those bounds
  61362. * default is (1,1,1)
  61363. * @param extent x,y,z value that define the extent around the queries point of reference
  61364. */
  61365. setDefaultQueryExtent(extent: Vector3): void;
  61366. /**
  61367. * Get the Bounding box extent specified by setDefaultQueryExtent
  61368. * @returns the box extent values
  61369. */
  61370. getDefaultQueryExtent(): Vector3;
  61371. /**
  61372. * Release all resources
  61373. */
  61374. dispose(): void;
  61375. }
  61376. }
  61377. declare module "babylonjs/Navigation/Plugins/index" {
  61378. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61379. }
  61380. declare module "babylonjs/Navigation/index" {
  61381. export * from "babylonjs/Navigation/INavigationEngine";
  61382. export * from "babylonjs/Navigation/Plugins/index";
  61383. }
  61384. declare module "babylonjs/Offline/database" {
  61385. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61386. /**
  61387. * Class used to enable access to IndexedDB
  61388. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61389. */
  61390. export class Database implements IOfflineProvider {
  61391. private _callbackManifestChecked;
  61392. private _currentSceneUrl;
  61393. private _db;
  61394. private _enableSceneOffline;
  61395. private _enableTexturesOffline;
  61396. private _manifestVersionFound;
  61397. private _mustUpdateRessources;
  61398. private _hasReachedQuota;
  61399. private _isSupported;
  61400. private _idbFactory;
  61401. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61402. private static IsUASupportingBlobStorage;
  61403. /**
  61404. * Gets a boolean indicating if Database storate is enabled (off by default)
  61405. */
  61406. static IDBStorageEnabled: boolean;
  61407. /**
  61408. * Gets a boolean indicating if scene must be saved in the database
  61409. */
  61410. readonly enableSceneOffline: boolean;
  61411. /**
  61412. * Gets a boolean indicating if textures must be saved in the database
  61413. */
  61414. readonly enableTexturesOffline: boolean;
  61415. /**
  61416. * Creates a new Database
  61417. * @param urlToScene defines the url to load the scene
  61418. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61419. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61420. */
  61421. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61422. private static _ParseURL;
  61423. private static _ReturnFullUrlLocation;
  61424. private _checkManifestFile;
  61425. /**
  61426. * Open the database and make it available
  61427. * @param successCallback defines the callback to call on success
  61428. * @param errorCallback defines the callback to call on error
  61429. */
  61430. open(successCallback: () => void, errorCallback: () => void): void;
  61431. /**
  61432. * Loads an image from the database
  61433. * @param url defines the url to load from
  61434. * @param image defines the target DOM image
  61435. */
  61436. loadImage(url: string, image: HTMLImageElement): void;
  61437. private _loadImageFromDBAsync;
  61438. private _saveImageIntoDBAsync;
  61439. private _checkVersionFromDB;
  61440. private _loadVersionFromDBAsync;
  61441. private _saveVersionIntoDBAsync;
  61442. /**
  61443. * Loads a file from database
  61444. * @param url defines the URL to load from
  61445. * @param sceneLoaded defines a callback to call on success
  61446. * @param progressCallBack defines a callback to call when progress changed
  61447. * @param errorCallback defines a callback to call on error
  61448. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61449. */
  61450. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61451. private _loadFileAsync;
  61452. private _saveFileAsync;
  61453. /**
  61454. * Validates if xhr data is correct
  61455. * @param xhr defines the request to validate
  61456. * @param dataType defines the expected data type
  61457. * @returns true if data is correct
  61458. */
  61459. private static _ValidateXHRData;
  61460. }
  61461. }
  61462. declare module "babylonjs/Offline/index" {
  61463. export * from "babylonjs/Offline/database";
  61464. export * from "babylonjs/Offline/IOfflineProvider";
  61465. }
  61466. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61467. /** @hidden */
  61468. export var gpuUpdateParticlesPixelShader: {
  61469. name: string;
  61470. shader: string;
  61471. };
  61472. }
  61473. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61474. /** @hidden */
  61475. export var gpuUpdateParticlesVertexShader: {
  61476. name: string;
  61477. shader: string;
  61478. };
  61479. }
  61480. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61481. /** @hidden */
  61482. export var clipPlaneFragmentDeclaration2: {
  61483. name: string;
  61484. shader: string;
  61485. };
  61486. }
  61487. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61488. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61489. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61490. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61491. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61492. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61493. /** @hidden */
  61494. export var gpuRenderParticlesPixelShader: {
  61495. name: string;
  61496. shader: string;
  61497. };
  61498. }
  61499. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61500. /** @hidden */
  61501. export var clipPlaneVertexDeclaration2: {
  61502. name: string;
  61503. shader: string;
  61504. };
  61505. }
  61506. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61507. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61509. /** @hidden */
  61510. export var gpuRenderParticlesVertexShader: {
  61511. name: string;
  61512. shader: string;
  61513. };
  61514. }
  61515. declare module "babylonjs/Particles/gpuParticleSystem" {
  61516. import { Nullable } from "babylonjs/types";
  61517. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61518. import { Observable } from "babylonjs/Misc/observable";
  61519. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61520. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61521. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61522. import { Scene, IDisposable } from "babylonjs/scene";
  61523. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61524. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61525. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61526. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61527. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61528. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61529. /**
  61530. * This represents a GPU particle system in Babylon
  61531. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61532. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61533. */
  61534. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61535. /**
  61536. * The layer mask we are rendering the particles through.
  61537. */
  61538. layerMask: number;
  61539. private _capacity;
  61540. private _activeCount;
  61541. private _currentActiveCount;
  61542. private _accumulatedCount;
  61543. private _renderEffect;
  61544. private _updateEffect;
  61545. private _buffer0;
  61546. private _buffer1;
  61547. private _spriteBuffer;
  61548. private _updateVAO;
  61549. private _renderVAO;
  61550. private _targetIndex;
  61551. private _sourceBuffer;
  61552. private _targetBuffer;
  61553. private _engine;
  61554. private _currentRenderId;
  61555. private _started;
  61556. private _stopped;
  61557. private _timeDelta;
  61558. private _randomTexture;
  61559. private _randomTexture2;
  61560. private _attributesStrideSize;
  61561. private _updateEffectOptions;
  61562. private _randomTextureSize;
  61563. private _actualFrame;
  61564. private readonly _rawTextureWidth;
  61565. /**
  61566. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61567. */
  61568. static readonly IsSupported: boolean;
  61569. /**
  61570. * An event triggered when the system is disposed.
  61571. */
  61572. onDisposeObservable: Observable<GPUParticleSystem>;
  61573. /**
  61574. * Gets the maximum number of particles active at the same time.
  61575. * @returns The max number of active particles.
  61576. */
  61577. getCapacity(): number;
  61578. /**
  61579. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61580. * to override the particles.
  61581. */
  61582. forceDepthWrite: boolean;
  61583. /**
  61584. * Gets or set the number of active particles
  61585. */
  61586. activeParticleCount: number;
  61587. private _preWarmDone;
  61588. /**
  61589. * Is this system ready to be used/rendered
  61590. * @return true if the system is ready
  61591. */
  61592. isReady(): boolean;
  61593. /**
  61594. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61595. * @returns True if it has been started, otherwise false.
  61596. */
  61597. isStarted(): boolean;
  61598. /**
  61599. * Starts the particle system and begins to emit
  61600. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61601. */
  61602. start(delay?: number): void;
  61603. /**
  61604. * Stops the particle system.
  61605. */
  61606. stop(): void;
  61607. /**
  61608. * Remove all active particles
  61609. */
  61610. reset(): void;
  61611. /**
  61612. * Returns the string "GPUParticleSystem"
  61613. * @returns a string containing the class name
  61614. */
  61615. getClassName(): string;
  61616. private _colorGradientsTexture;
  61617. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61618. /**
  61619. * Adds a new color gradient
  61620. * @param gradient defines the gradient to use (between 0 and 1)
  61621. * @param color1 defines the color to affect to the specified gradient
  61622. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61623. * @returns the current particle system
  61624. */
  61625. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61626. /**
  61627. * Remove a specific color gradient
  61628. * @param gradient defines the gradient to remove
  61629. * @returns the current particle system
  61630. */
  61631. removeColorGradient(gradient: number): GPUParticleSystem;
  61632. private _angularSpeedGradientsTexture;
  61633. private _sizeGradientsTexture;
  61634. private _velocityGradientsTexture;
  61635. private _limitVelocityGradientsTexture;
  61636. private _dragGradientsTexture;
  61637. private _addFactorGradient;
  61638. /**
  61639. * Adds a new size gradient
  61640. * @param gradient defines the gradient to use (between 0 and 1)
  61641. * @param factor defines the size factor to affect to the specified gradient
  61642. * @returns the current particle system
  61643. */
  61644. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61645. /**
  61646. * Remove a specific size gradient
  61647. * @param gradient defines the gradient to remove
  61648. * @returns the current particle system
  61649. */
  61650. removeSizeGradient(gradient: number): GPUParticleSystem;
  61651. /**
  61652. * Adds a new angular speed gradient
  61653. * @param gradient defines the gradient to use (between 0 and 1)
  61654. * @param factor defines the angular speed to affect to the specified gradient
  61655. * @returns the current particle system
  61656. */
  61657. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61658. /**
  61659. * Remove a specific angular speed gradient
  61660. * @param gradient defines the gradient to remove
  61661. * @returns the current particle system
  61662. */
  61663. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61664. /**
  61665. * Adds a new velocity gradient
  61666. * @param gradient defines the gradient to use (between 0 and 1)
  61667. * @param factor defines the velocity to affect to the specified gradient
  61668. * @returns the current particle system
  61669. */
  61670. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61671. /**
  61672. * Remove a specific velocity gradient
  61673. * @param gradient defines the gradient to remove
  61674. * @returns the current particle system
  61675. */
  61676. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61677. /**
  61678. * Adds a new limit velocity gradient
  61679. * @param gradient defines the gradient to use (between 0 and 1)
  61680. * @param factor defines the limit velocity value to affect to the specified gradient
  61681. * @returns the current particle system
  61682. */
  61683. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61684. /**
  61685. * Remove a specific limit velocity gradient
  61686. * @param gradient defines the gradient to remove
  61687. * @returns the current particle system
  61688. */
  61689. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61690. /**
  61691. * Adds a new drag gradient
  61692. * @param gradient defines the gradient to use (between 0 and 1)
  61693. * @param factor defines the drag value to affect to the specified gradient
  61694. * @returns the current particle system
  61695. */
  61696. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61697. /**
  61698. * Remove a specific drag gradient
  61699. * @param gradient defines the gradient to remove
  61700. * @returns the current particle system
  61701. */
  61702. removeDragGradient(gradient: number): GPUParticleSystem;
  61703. /**
  61704. * Not supported by GPUParticleSystem
  61705. * @param gradient defines the gradient to use (between 0 and 1)
  61706. * @param factor defines the emit rate value to affect to the specified gradient
  61707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61708. * @returns the current particle system
  61709. */
  61710. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61711. /**
  61712. * Not supported by GPUParticleSystem
  61713. * @param gradient defines the gradient to remove
  61714. * @returns the current particle system
  61715. */
  61716. removeEmitRateGradient(gradient: number): IParticleSystem;
  61717. /**
  61718. * Not supported by GPUParticleSystem
  61719. * @param gradient defines the gradient to use (between 0 and 1)
  61720. * @param factor defines the start size value to affect to the specified gradient
  61721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61722. * @returns the current particle system
  61723. */
  61724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61725. /**
  61726. * Not supported by GPUParticleSystem
  61727. * @param gradient defines the gradient to remove
  61728. * @returns the current particle system
  61729. */
  61730. removeStartSizeGradient(gradient: number): IParticleSystem;
  61731. /**
  61732. * Not supported by GPUParticleSystem
  61733. * @param gradient defines the gradient to use (between 0 and 1)
  61734. * @param min defines the color remap minimal range
  61735. * @param max defines the color remap maximal range
  61736. * @returns the current particle system
  61737. */
  61738. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61739. /**
  61740. * Not supported by GPUParticleSystem
  61741. * @param gradient defines the gradient to remove
  61742. * @returns the current particle system
  61743. */
  61744. removeColorRemapGradient(): IParticleSystem;
  61745. /**
  61746. * Not supported by GPUParticleSystem
  61747. * @param gradient defines the gradient to use (between 0 and 1)
  61748. * @param min defines the alpha remap minimal range
  61749. * @param max defines the alpha remap maximal range
  61750. * @returns the current particle system
  61751. */
  61752. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61753. /**
  61754. * Not supported by GPUParticleSystem
  61755. * @param gradient defines the gradient to remove
  61756. * @returns the current particle system
  61757. */
  61758. removeAlphaRemapGradient(): IParticleSystem;
  61759. /**
  61760. * Not supported by GPUParticleSystem
  61761. * @param gradient defines the gradient to use (between 0 and 1)
  61762. * @param color defines the color to affect to the specified gradient
  61763. * @returns the current particle system
  61764. */
  61765. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61766. /**
  61767. * Not supported by GPUParticleSystem
  61768. * @param gradient defines the gradient to remove
  61769. * @returns the current particle system
  61770. */
  61771. removeRampGradient(): IParticleSystem;
  61772. /**
  61773. * Not supported by GPUParticleSystem
  61774. * @returns the list of ramp gradients
  61775. */
  61776. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61777. /**
  61778. * Not supported by GPUParticleSystem
  61779. * Gets or sets a boolean indicating that ramp gradients must be used
  61780. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61781. */
  61782. useRampGradients: boolean;
  61783. /**
  61784. * Not supported by GPUParticleSystem
  61785. * @param gradient defines the gradient to use (between 0 and 1)
  61786. * @param factor defines the life time factor to affect to the specified gradient
  61787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61788. * @returns the current particle system
  61789. */
  61790. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61791. /**
  61792. * Not supported by GPUParticleSystem
  61793. * @param gradient defines the gradient to remove
  61794. * @returns the current particle system
  61795. */
  61796. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61797. /**
  61798. * Instantiates a GPU particle system.
  61799. * 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.
  61800. * @param name The name of the particle system
  61801. * @param options The options used to create the system
  61802. * @param scene The scene the particle system belongs to
  61803. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61804. */
  61805. constructor(name: string, options: Partial<{
  61806. capacity: number;
  61807. randomTextureSize: number;
  61808. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61809. protected _reset(): void;
  61810. private _createUpdateVAO;
  61811. private _createRenderVAO;
  61812. private _initialize;
  61813. /** @hidden */
  61814. _recreateUpdateEffect(): void;
  61815. /** @hidden */
  61816. _recreateRenderEffect(): void;
  61817. /**
  61818. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61819. * @param preWarm defines if we are in the pre-warmimg phase
  61820. */
  61821. animate(preWarm?: boolean): void;
  61822. private _createFactorGradientTexture;
  61823. private _createSizeGradientTexture;
  61824. private _createAngularSpeedGradientTexture;
  61825. private _createVelocityGradientTexture;
  61826. private _createLimitVelocityGradientTexture;
  61827. private _createDragGradientTexture;
  61828. private _createColorGradientTexture;
  61829. /**
  61830. * Renders the particle system in its current state
  61831. * @param preWarm defines if the system should only update the particles but not render them
  61832. * @returns the current number of particles
  61833. */
  61834. render(preWarm?: boolean): number;
  61835. /**
  61836. * Rebuilds the particle system
  61837. */
  61838. rebuild(): void;
  61839. private _releaseBuffers;
  61840. private _releaseVAOs;
  61841. /**
  61842. * Disposes the particle system and free the associated resources
  61843. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61844. */
  61845. dispose(disposeTexture?: boolean): void;
  61846. /**
  61847. * Clones the particle system.
  61848. * @param name The name of the cloned object
  61849. * @param newEmitter The new emitter to use
  61850. * @returns the cloned particle system
  61851. */
  61852. clone(name: string, newEmitter: any): GPUParticleSystem;
  61853. /**
  61854. * Serializes the particle system to a JSON object.
  61855. * @returns the JSON object
  61856. */
  61857. serialize(): any;
  61858. /**
  61859. * Parses a JSON object to create a GPU particle system.
  61860. * @param parsedParticleSystem The JSON object to parse
  61861. * @param scene The scene to create the particle system in
  61862. * @param rootUrl The root url to use to load external dependencies like texture
  61863. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61864. * @returns the parsed GPU particle system
  61865. */
  61866. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61867. }
  61868. }
  61869. declare module "babylonjs/Particles/particleSystemSet" {
  61870. import { Nullable } from "babylonjs/types";
  61871. import { Color3 } from "babylonjs/Maths/math.color";
  61872. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61874. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61875. import { Scene, IDisposable } from "babylonjs/scene";
  61876. /**
  61877. * Represents a set of particle systems working together to create a specific effect
  61878. */
  61879. export class ParticleSystemSet implements IDisposable {
  61880. /**
  61881. * Gets or sets base Assets URL
  61882. */
  61883. static BaseAssetsUrl: string;
  61884. private _emitterCreationOptions;
  61885. private _emitterNode;
  61886. /**
  61887. * Gets the particle system list
  61888. */
  61889. systems: IParticleSystem[];
  61890. /**
  61891. * Gets the emitter node used with this set
  61892. */
  61893. readonly emitterNode: Nullable<TransformNode>;
  61894. /**
  61895. * Creates a new emitter mesh as a sphere
  61896. * @param options defines the options used to create the sphere
  61897. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61898. * @param scene defines the hosting scene
  61899. */
  61900. setEmitterAsSphere(options: {
  61901. diameter: number;
  61902. segments: number;
  61903. color: Color3;
  61904. }, renderingGroupId: number, scene: Scene): void;
  61905. /**
  61906. * Starts all particle systems of the set
  61907. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61908. */
  61909. start(emitter?: AbstractMesh): void;
  61910. /**
  61911. * Release all associated resources
  61912. */
  61913. dispose(): void;
  61914. /**
  61915. * Serialize the set into a JSON compatible object
  61916. * @returns a JSON compatible representation of the set
  61917. */
  61918. serialize(): any;
  61919. /**
  61920. * Parse a new ParticleSystemSet from a serialized source
  61921. * @param data defines a JSON compatible representation of the set
  61922. * @param scene defines the hosting scene
  61923. * @param gpu defines if we want GPU particles or CPU particles
  61924. * @returns a new ParticleSystemSet
  61925. */
  61926. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61927. }
  61928. }
  61929. declare module "babylonjs/Particles/particleHelper" {
  61930. import { Nullable } from "babylonjs/types";
  61931. import { Scene } from "babylonjs/scene";
  61932. import { Vector3 } from "babylonjs/Maths/math.vector";
  61933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61934. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61935. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61936. /**
  61937. * This class is made for on one-liner static method to help creating particle system set.
  61938. */
  61939. export class ParticleHelper {
  61940. /**
  61941. * Gets or sets base Assets URL
  61942. */
  61943. static BaseAssetsUrl: string;
  61944. /**
  61945. * Create a default particle system that you can tweak
  61946. * @param emitter defines the emitter to use
  61947. * @param capacity defines the system capacity (default is 500 particles)
  61948. * @param scene defines the hosting scene
  61949. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61950. * @returns the new Particle system
  61951. */
  61952. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61953. /**
  61954. * This is the main static method (one-liner) of this helper to create different particle systems
  61955. * @param type This string represents the type to the particle system to create
  61956. * @param scene The scene where the particle system should live
  61957. * @param gpu If the system will use gpu
  61958. * @returns the ParticleSystemSet created
  61959. */
  61960. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61961. /**
  61962. * Static function used to export a particle system to a ParticleSystemSet variable.
  61963. * Please note that the emitter shape is not exported
  61964. * @param systems defines the particle systems to export
  61965. * @returns the created particle system set
  61966. */
  61967. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61968. }
  61969. }
  61970. declare module "babylonjs/Particles/particleSystemComponent" {
  61971. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61972. import { Effect } from "babylonjs/Materials/effect";
  61973. import "babylonjs/Shaders/particles.vertex";
  61974. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61975. module "babylonjs/Engines/engine" {
  61976. interface Engine {
  61977. /**
  61978. * Create an effect to use with particle systems.
  61979. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61980. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61981. * @param uniformsNames defines a list of attribute names
  61982. * @param samplers defines an array of string used to represent textures
  61983. * @param defines defines the string containing the defines to use to compile the shaders
  61984. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61985. * @param onCompiled defines a function to call when the effect creation is successful
  61986. * @param onError defines a function to call when the effect creation has failed
  61987. * @returns the new Effect
  61988. */
  61989. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61990. }
  61991. }
  61992. module "babylonjs/Meshes/mesh" {
  61993. interface Mesh {
  61994. /**
  61995. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61996. * @returns an array of IParticleSystem
  61997. */
  61998. getEmittedParticleSystems(): IParticleSystem[];
  61999. /**
  62000. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62001. * @returns an array of IParticleSystem
  62002. */
  62003. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62004. }
  62005. }
  62006. /**
  62007. * @hidden
  62008. */
  62009. export var _IDoNeedToBeInTheBuild: number;
  62010. }
  62011. declare module "babylonjs/Particles/pointsCloudSystem" {
  62012. import { Color4 } from "babylonjs/Maths/math";
  62013. import { Mesh } from "babylonjs/Meshes/mesh";
  62014. import { Scene, IDisposable } from "babylonjs/scene";
  62015. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62016. /** Defines the 4 color options */
  62017. export enum PointColor {
  62018. /** color value */
  62019. Color = 2,
  62020. /** uv value */
  62021. UV = 1,
  62022. /** random value */
  62023. Random = 0,
  62024. /** stated value */
  62025. Stated = 3
  62026. }
  62027. /**
  62028. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62029. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  62030. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62031. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62032. *
  62033. * Full documentation here : TO BE ENTERED
  62034. */
  62035. export class PointsCloudSystem implements IDisposable {
  62036. /**
  62037. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62038. * Example : var p = SPS.particles[i];
  62039. */
  62040. particles: CloudPoint[];
  62041. /**
  62042. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62043. */
  62044. nbParticles: number;
  62045. /**
  62046. * This a counter for your own usage. It's not set by any SPS functions.
  62047. */
  62048. counter: number;
  62049. /**
  62050. * The PCS name. This name is also given to the underlying mesh.
  62051. */
  62052. name: string;
  62053. /**
  62054. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62055. */
  62056. mesh: Mesh;
  62057. /**
  62058. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62059. * Please read :
  62060. */
  62061. vars: any;
  62062. /**
  62063. * @hidden
  62064. */
  62065. _size: number;
  62066. private _scene;
  62067. private _promises;
  62068. private _positions;
  62069. private _indices;
  62070. private _normals;
  62071. private _colors;
  62072. private _uvs;
  62073. private _indices32;
  62074. private _positions32;
  62075. private _colors32;
  62076. private _uvs32;
  62077. private _updatable;
  62078. private _isVisibilityBoxLocked;
  62079. private _alwaysVisible;
  62080. private _groups;
  62081. private _groupCounter;
  62082. private _computeParticleColor;
  62083. private _computeParticleTexture;
  62084. private _computeParticleRotation;
  62085. private _computeBoundingBox;
  62086. private _isReady;
  62087. /**
  62088. * Creates a PCS (Points Cloud System) object
  62089. * @param name (String) is the PCS name, this will be the underlying mesh name
  62090. * @param pointSize (number) is the size for each point
  62091. * @param scene (Scene) is the scene in which the PCS is added
  62092. * @param options defines the options of the PCS e.g.
  62093. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62094. */
  62095. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62096. updatable?: boolean;
  62097. });
  62098. /**
  62099. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62100. * If no points were added to the PCS, the returned mesh is just a single point.
  62101. * @returns a promise for the created mesh
  62102. */
  62103. buildMeshAsync(): Promise<Mesh>;
  62104. /**
  62105. * @hidden
  62106. */
  62107. private _buildMesh;
  62108. private _addParticle;
  62109. private _randomUnitVector;
  62110. private _getColorIndicesForCoord;
  62111. private _setPointsColorOrUV;
  62112. private _colorFromTexture;
  62113. private _calculateDensity;
  62114. /**
  62115. * Adds points to the PCS in random positions within a unit sphere
  62116. * @param nb (positive integer) the number of particles to be created from this model
  62117. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62118. * @returns the number of groups in the system
  62119. */
  62120. addPoints(nb: number, pointFunction?: any): number;
  62121. /**
  62122. * Adds points to the PCS from the surface of the model shape
  62123. * @param mesh is any Mesh object that will be used as a surface model for the points
  62124. * @param nb (positive integer) the number of particles to be created from this model
  62125. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62126. * @param color (color3) to be used when colorWith is stated
  62127. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62128. * @returns the number of groups in the system
  62129. */
  62130. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  62131. /**
  62132. * Adds points to the PCS inside the model shape
  62133. * @param mesh is any Mesh object that will be used as a surface model for the points
  62134. * @param nb (positive integer) the number of particles to be created from this model
  62135. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  62136. * @param color (color4) to be used when colorWith is stated
  62137. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62138. * @returns the number of groups in the system
  62139. */
  62140. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  62141. /**
  62142. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62143. * This method calls `updateParticle()` for each particle of the SPS.
  62144. * For an animated SPS, it is usually called within the render loop.
  62145. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62146. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62147. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62148. * @returns the PCS.
  62149. */
  62150. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62151. /**
  62152. * Disposes the PCS.
  62153. */
  62154. dispose(): void;
  62155. /**
  62156. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62157. * doc :
  62158. * @returns the PCS.
  62159. */
  62160. refreshVisibleSize(): PointsCloudSystem;
  62161. /**
  62162. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62163. * @param size the size (float) of the visibility box
  62164. * note : this doesn't lock the PCS mesh bounding box.
  62165. * doc :
  62166. */
  62167. setVisibilityBox(size: number): void;
  62168. /**
  62169. * Gets whether the PCS is always visible or not
  62170. * doc :
  62171. */
  62172. /**
  62173. * Sets the PCS as always visible or not
  62174. * doc :
  62175. */
  62176. isAlwaysVisible: boolean;
  62177. /**
  62178. * Tells to `setParticles()` to compute the particle rotations or not
  62179. * Default value : false. The PCS is faster when it's set to false
  62180. * Note : particle rotations are only applied to parent particles
  62181. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62182. */
  62183. computeParticleRotation: boolean;
  62184. /**
  62185. * Tells to `setParticles()` to compute the particle colors or not.
  62186. * Default value : true. The PCS is faster when it's set to false.
  62187. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62188. */
  62189. /**
  62190. * Gets if `setParticles()` computes the particle colors or not.
  62191. * Default value : false. The PCS is faster when it's set to false.
  62192. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62193. */
  62194. computeParticleColor: boolean;
  62195. /**
  62196. * Gets if `setParticles()` computes the particle textures or not.
  62197. * Default value : false. The PCS is faster when it's set to false.
  62198. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62199. */
  62200. computeParticleTexture: boolean;
  62201. /**
  62202. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62203. */
  62204. /**
  62205. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62206. */
  62207. computeBoundingBox: boolean;
  62208. /**
  62209. * This function does nothing. It may be overwritten to set all the particle first values.
  62210. * The PCS doesn't call this function, you may have to call it by your own.
  62211. * doc :
  62212. */
  62213. initParticles(): void;
  62214. /**
  62215. * This function does nothing. It may be overwritten to recycle a particle
  62216. * The PCS doesn't call this function, you can to call it
  62217. * doc :
  62218. * @param particle The particle to recycle
  62219. * @returns the recycled particle
  62220. */
  62221. recycleParticle(particle: CloudPoint): CloudPoint;
  62222. /**
  62223. * Updates a particle : this function should be overwritten by the user.
  62224. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62225. * doc :
  62226. * @example : just set a particle position or velocity and recycle conditions
  62227. * @param particle The particle to update
  62228. * @returns the updated particle
  62229. */
  62230. updateParticle(particle: CloudPoint): CloudPoint;
  62231. /**
  62232. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62233. * This does nothing and may be overwritten by the user.
  62234. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62235. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62236. * @param update the boolean update value actually passed to setParticles()
  62237. */
  62238. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62239. /**
  62240. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62241. * This will be passed three parameters.
  62242. * This does nothing and may be overwritten by the user.
  62243. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62244. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62245. * @param update the boolean update value actually passed to setParticles()
  62246. */
  62247. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62248. }
  62249. }
  62250. declare module "babylonjs/Particles/cloudPoint" {
  62251. import { Nullable } from "babylonjs/types";
  62252. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62253. import { Mesh } from "babylonjs/Meshes/mesh";
  62254. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62255. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62256. /**
  62257. * Represents one particle of a points cloud system.
  62258. */
  62259. export class CloudPoint {
  62260. /**
  62261. * particle global index
  62262. */
  62263. idx: number;
  62264. /**
  62265. * The color of the particle
  62266. */
  62267. color: Nullable<Color4>;
  62268. /**
  62269. * The world space position of the particle.
  62270. */
  62271. position: Vector3;
  62272. /**
  62273. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62274. */
  62275. rotation: Vector3;
  62276. /**
  62277. * The world space rotation quaternion of the particle.
  62278. */
  62279. rotationQuaternion: Nullable<Quaternion>;
  62280. /**
  62281. * The uv of the particle.
  62282. */
  62283. uv: Nullable<Vector2>;
  62284. /**
  62285. * The current speed of the particle.
  62286. */
  62287. velocity: Vector3;
  62288. /**
  62289. * The pivot point in the particle local space.
  62290. */
  62291. pivot: Vector3;
  62292. /**
  62293. * Must the particle be translated from its pivot point in its local space ?
  62294. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62295. * Default : false
  62296. */
  62297. translateFromPivot: boolean;
  62298. /**
  62299. * Index of this particle in the global "positions" array (Internal use)
  62300. * @hidden
  62301. */
  62302. _pos: number;
  62303. /**
  62304. * @hidden Index of this particle in the global "indices" array (Internal use)
  62305. */
  62306. _ind: number;
  62307. /**
  62308. * Group this particle belongs to
  62309. */
  62310. _group: PointsGroup;
  62311. /**
  62312. * Group id of this particle
  62313. */
  62314. groupId: number;
  62315. /**
  62316. * Index of the particle in its group id (Internal use)
  62317. */
  62318. idxInGroup: number;
  62319. /**
  62320. * @hidden Particle BoundingInfo object (Internal use)
  62321. */
  62322. _boundingInfo: BoundingInfo;
  62323. /**
  62324. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62325. */
  62326. _pcs: PointsCloudSystem;
  62327. /**
  62328. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62329. */
  62330. _stillInvisible: boolean;
  62331. /**
  62332. * @hidden Last computed particle rotation matrix
  62333. */
  62334. _rotationMatrix: number[];
  62335. /**
  62336. * Parent particle Id, if any.
  62337. * Default null.
  62338. */
  62339. parentId: Nullable<number>;
  62340. /**
  62341. * @hidden Internal global position in the PCS.
  62342. */
  62343. _globalPosition: Vector3;
  62344. /**
  62345. * Creates a Point Cloud object.
  62346. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62347. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62348. * @param group (PointsGroup) is the group the particle belongs to
  62349. * @param groupId (integer) is the group identifier in the PCS.
  62350. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62351. * @param pcs defines the PCS it is associated to
  62352. */
  62353. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62354. /**
  62355. * get point size
  62356. */
  62357. /**
  62358. * Set point size
  62359. */
  62360. size: Vector3;
  62361. /**
  62362. * Legacy support, changed quaternion to rotationQuaternion
  62363. */
  62364. /**
  62365. * Legacy support, changed quaternion to rotationQuaternion
  62366. */
  62367. quaternion: Nullable<Quaternion>;
  62368. /**
  62369. * Returns a boolean. True if the particle intersects a mesh, else false
  62370. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62371. * @param target is the object (point or mesh) what the intersection is computed against
  62372. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62373. * @returns true if it intersects
  62374. */
  62375. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62376. /**
  62377. * get the rotation matrix of the particle
  62378. * @hidden
  62379. */
  62380. getRotationMatrix(m: Matrix): void;
  62381. }
  62382. /**
  62383. * Represents a group of points in a points cloud system
  62384. * * PCS internal tool, don't use it manually.
  62385. */
  62386. export class PointsGroup {
  62387. /**
  62388. * The group id
  62389. * @hidden
  62390. */
  62391. groupID: number;
  62392. /**
  62393. * image data for group (internal use)
  62394. * @hidden
  62395. */
  62396. _groupImageData: Nullable<ArrayBufferView>;
  62397. /**
  62398. * Image Width (internal use)
  62399. * @hidden
  62400. */
  62401. _groupImgWidth: number;
  62402. /**
  62403. * Image Height (internal use)
  62404. * @hidden
  62405. */
  62406. _groupImgHeight: number;
  62407. /**
  62408. * Custom position function (internal use)
  62409. * @hidden
  62410. */
  62411. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62412. /**
  62413. * density per facet for surface points
  62414. * @hidden
  62415. */
  62416. _groupDensity: number[];
  62417. /**
  62418. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62419. * PCS internal tool, don't use it manually.
  62420. * @hidden
  62421. */
  62422. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62423. }
  62424. }
  62425. declare module "babylonjs/Particles/index" {
  62426. export * from "babylonjs/Particles/baseParticleSystem";
  62427. export * from "babylonjs/Particles/EmitterTypes/index";
  62428. export * from "babylonjs/Particles/gpuParticleSystem";
  62429. export * from "babylonjs/Particles/IParticleSystem";
  62430. export * from "babylonjs/Particles/particle";
  62431. export * from "babylonjs/Particles/particleHelper";
  62432. export * from "babylonjs/Particles/particleSystem";
  62433. export * from "babylonjs/Particles/particleSystemComponent";
  62434. export * from "babylonjs/Particles/particleSystemSet";
  62435. export * from "babylonjs/Particles/solidParticle";
  62436. export * from "babylonjs/Particles/solidParticleSystem";
  62437. export * from "babylonjs/Particles/cloudPoint";
  62438. export * from "babylonjs/Particles/pointsCloudSystem";
  62439. export * from "babylonjs/Particles/subEmitter";
  62440. }
  62441. declare module "babylonjs/Physics/physicsEngineComponent" {
  62442. import { Nullable } from "babylonjs/types";
  62443. import { Observable, Observer } from "babylonjs/Misc/observable";
  62444. import { Vector3 } from "babylonjs/Maths/math.vector";
  62445. import { Mesh } from "babylonjs/Meshes/mesh";
  62446. import { ISceneComponent } from "babylonjs/sceneComponent";
  62447. import { Scene } from "babylonjs/scene";
  62448. import { Node } from "babylonjs/node";
  62449. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62450. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62451. module "babylonjs/scene" {
  62452. interface Scene {
  62453. /** @hidden (Backing field) */
  62454. _physicsEngine: Nullable<IPhysicsEngine>;
  62455. /**
  62456. * Gets the current physics engine
  62457. * @returns a IPhysicsEngine or null if none attached
  62458. */
  62459. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62460. /**
  62461. * Enables physics to the current scene
  62462. * @param gravity defines the scene's gravity for the physics engine
  62463. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62464. * @return a boolean indicating if the physics engine was initialized
  62465. */
  62466. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62467. /**
  62468. * Disables and disposes the physics engine associated with the scene
  62469. */
  62470. disablePhysicsEngine(): void;
  62471. /**
  62472. * Gets a boolean indicating if there is an active physics engine
  62473. * @returns a boolean indicating if there is an active physics engine
  62474. */
  62475. isPhysicsEnabled(): boolean;
  62476. /**
  62477. * Deletes a physics compound impostor
  62478. * @param compound defines the compound to delete
  62479. */
  62480. deleteCompoundImpostor(compound: any): void;
  62481. /**
  62482. * An event triggered when physic simulation is about to be run
  62483. */
  62484. onBeforePhysicsObservable: Observable<Scene>;
  62485. /**
  62486. * An event triggered when physic simulation has been done
  62487. */
  62488. onAfterPhysicsObservable: Observable<Scene>;
  62489. }
  62490. }
  62491. module "babylonjs/Meshes/abstractMesh" {
  62492. interface AbstractMesh {
  62493. /** @hidden */
  62494. _physicsImpostor: Nullable<PhysicsImpostor>;
  62495. /**
  62496. * Gets or sets impostor used for physic simulation
  62497. * @see http://doc.babylonjs.com/features/physics_engine
  62498. */
  62499. physicsImpostor: Nullable<PhysicsImpostor>;
  62500. /**
  62501. * Gets the current physics impostor
  62502. * @see http://doc.babylonjs.com/features/physics_engine
  62503. * @returns a physics impostor or null
  62504. */
  62505. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62506. /** Apply a physic impulse to the mesh
  62507. * @param force defines the force to apply
  62508. * @param contactPoint defines where to apply the force
  62509. * @returns the current mesh
  62510. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62511. */
  62512. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62513. /**
  62514. * Creates a physic joint between two meshes
  62515. * @param otherMesh defines the other mesh to use
  62516. * @param pivot1 defines the pivot to use on this mesh
  62517. * @param pivot2 defines the pivot to use on the other mesh
  62518. * @param options defines additional options (can be plugin dependent)
  62519. * @returns the current mesh
  62520. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62521. */
  62522. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62523. /** @hidden */
  62524. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62525. }
  62526. }
  62527. /**
  62528. * Defines the physics engine scene component responsible to manage a physics engine
  62529. */
  62530. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62531. /**
  62532. * The component name helpful to identify the component in the list of scene components.
  62533. */
  62534. readonly name: string;
  62535. /**
  62536. * The scene the component belongs to.
  62537. */
  62538. scene: Scene;
  62539. /**
  62540. * Creates a new instance of the component for the given scene
  62541. * @param scene Defines the scene to register the component in
  62542. */
  62543. constructor(scene: Scene);
  62544. /**
  62545. * Registers the component in a given scene
  62546. */
  62547. register(): void;
  62548. /**
  62549. * Rebuilds the elements related to this component in case of
  62550. * context lost for instance.
  62551. */
  62552. rebuild(): void;
  62553. /**
  62554. * Disposes the component and the associated ressources
  62555. */
  62556. dispose(): void;
  62557. }
  62558. }
  62559. declare module "babylonjs/Physics/physicsHelper" {
  62560. import { Nullable } from "babylonjs/types";
  62561. import { Vector3 } from "babylonjs/Maths/math.vector";
  62562. import { Mesh } from "babylonjs/Meshes/mesh";
  62563. import { Scene } from "babylonjs/scene";
  62564. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62565. /**
  62566. * A helper for physics simulations
  62567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62568. */
  62569. export class PhysicsHelper {
  62570. private _scene;
  62571. private _physicsEngine;
  62572. /**
  62573. * Initializes the Physics helper
  62574. * @param scene Babylon.js scene
  62575. */
  62576. constructor(scene: Scene);
  62577. /**
  62578. * Applies a radial explosion impulse
  62579. * @param origin the origin of the explosion
  62580. * @param radiusOrEventOptions the radius or the options of radial explosion
  62581. * @param strength the explosion strength
  62582. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62583. * @returns A physics radial explosion event, or null
  62584. */
  62585. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62586. /**
  62587. * Applies a radial explosion force
  62588. * @param origin the origin of the explosion
  62589. * @param radiusOrEventOptions the radius or the options of radial explosion
  62590. * @param strength the explosion strength
  62591. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62592. * @returns A physics radial explosion event, or null
  62593. */
  62594. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62595. /**
  62596. * Creates a gravitational field
  62597. * @param origin the origin of the explosion
  62598. * @param radiusOrEventOptions the radius or the options of radial explosion
  62599. * @param strength the explosion strength
  62600. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62601. * @returns A physics gravitational field event, or null
  62602. */
  62603. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62604. /**
  62605. * Creates a physics updraft event
  62606. * @param origin the origin of the updraft
  62607. * @param radiusOrEventOptions the radius or the options of the updraft
  62608. * @param strength the strength of the updraft
  62609. * @param height the height of the updraft
  62610. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62611. * @returns A physics updraft event, or null
  62612. */
  62613. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62614. /**
  62615. * Creates a physics vortex event
  62616. * @param origin the of the vortex
  62617. * @param radiusOrEventOptions the radius or the options of the vortex
  62618. * @param strength the strength of the vortex
  62619. * @param height the height of the vortex
  62620. * @returns a Physics vortex event, or null
  62621. * A physics vortex event or null
  62622. */
  62623. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62624. }
  62625. /**
  62626. * Represents a physics radial explosion event
  62627. */
  62628. class PhysicsRadialExplosionEvent {
  62629. private _scene;
  62630. private _options;
  62631. private _sphere;
  62632. private _dataFetched;
  62633. /**
  62634. * Initializes a radial explosioin event
  62635. * @param _scene BabylonJS scene
  62636. * @param _options The options for the vortex event
  62637. */
  62638. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62639. /**
  62640. * Returns the data related to the radial explosion event (sphere).
  62641. * @returns The radial explosion event data
  62642. */
  62643. getData(): PhysicsRadialExplosionEventData;
  62644. /**
  62645. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62646. * @param impostor A physics imposter
  62647. * @param origin the origin of the explosion
  62648. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62649. */
  62650. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62651. /**
  62652. * Triggers affecterd impostors callbacks
  62653. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62654. */
  62655. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62656. /**
  62657. * Disposes the sphere.
  62658. * @param force Specifies if the sphere should be disposed by force
  62659. */
  62660. dispose(force?: boolean): void;
  62661. /*** Helpers ***/
  62662. private _prepareSphere;
  62663. private _intersectsWithSphere;
  62664. }
  62665. /**
  62666. * Represents a gravitational field event
  62667. */
  62668. class PhysicsGravitationalFieldEvent {
  62669. private _physicsHelper;
  62670. private _scene;
  62671. private _origin;
  62672. private _options;
  62673. private _tickCallback;
  62674. private _sphere;
  62675. private _dataFetched;
  62676. /**
  62677. * Initializes the physics gravitational field event
  62678. * @param _physicsHelper A physics helper
  62679. * @param _scene BabylonJS scene
  62680. * @param _origin The origin position of the gravitational field event
  62681. * @param _options The options for the vortex event
  62682. */
  62683. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62684. /**
  62685. * Returns the data related to the gravitational field event (sphere).
  62686. * @returns A gravitational field event
  62687. */
  62688. getData(): PhysicsGravitationalFieldEventData;
  62689. /**
  62690. * Enables the gravitational field.
  62691. */
  62692. enable(): void;
  62693. /**
  62694. * Disables the gravitational field.
  62695. */
  62696. disable(): void;
  62697. /**
  62698. * Disposes the sphere.
  62699. * @param force The force to dispose from the gravitational field event
  62700. */
  62701. dispose(force?: boolean): void;
  62702. private _tick;
  62703. }
  62704. /**
  62705. * Represents a physics updraft event
  62706. */
  62707. class PhysicsUpdraftEvent {
  62708. private _scene;
  62709. private _origin;
  62710. private _options;
  62711. private _physicsEngine;
  62712. private _originTop;
  62713. private _originDirection;
  62714. private _tickCallback;
  62715. private _cylinder;
  62716. private _cylinderPosition;
  62717. private _dataFetched;
  62718. /**
  62719. * Initializes the physics updraft event
  62720. * @param _scene BabylonJS scene
  62721. * @param _origin The origin position of the updraft
  62722. * @param _options The options for the updraft event
  62723. */
  62724. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62725. /**
  62726. * Returns the data related to the updraft event (cylinder).
  62727. * @returns A physics updraft event
  62728. */
  62729. getData(): PhysicsUpdraftEventData;
  62730. /**
  62731. * Enables the updraft.
  62732. */
  62733. enable(): void;
  62734. /**
  62735. * Disables the updraft.
  62736. */
  62737. disable(): void;
  62738. /**
  62739. * Disposes the cylinder.
  62740. * @param force Specifies if the updraft should be disposed by force
  62741. */
  62742. dispose(force?: boolean): void;
  62743. private getImpostorHitData;
  62744. private _tick;
  62745. /*** Helpers ***/
  62746. private _prepareCylinder;
  62747. private _intersectsWithCylinder;
  62748. }
  62749. /**
  62750. * Represents a physics vortex event
  62751. */
  62752. class PhysicsVortexEvent {
  62753. private _scene;
  62754. private _origin;
  62755. private _options;
  62756. private _physicsEngine;
  62757. private _originTop;
  62758. private _tickCallback;
  62759. private _cylinder;
  62760. private _cylinderPosition;
  62761. private _dataFetched;
  62762. /**
  62763. * Initializes the physics vortex event
  62764. * @param _scene The BabylonJS scene
  62765. * @param _origin The origin position of the vortex
  62766. * @param _options The options for the vortex event
  62767. */
  62768. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62769. /**
  62770. * Returns the data related to the vortex event (cylinder).
  62771. * @returns The physics vortex event data
  62772. */
  62773. getData(): PhysicsVortexEventData;
  62774. /**
  62775. * Enables the vortex.
  62776. */
  62777. enable(): void;
  62778. /**
  62779. * Disables the cortex.
  62780. */
  62781. disable(): void;
  62782. /**
  62783. * Disposes the sphere.
  62784. * @param force
  62785. */
  62786. dispose(force?: boolean): void;
  62787. private getImpostorHitData;
  62788. private _tick;
  62789. /*** Helpers ***/
  62790. private _prepareCylinder;
  62791. private _intersectsWithCylinder;
  62792. }
  62793. /**
  62794. * Options fot the radial explosion event
  62795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62796. */
  62797. export class PhysicsRadialExplosionEventOptions {
  62798. /**
  62799. * The radius of the sphere for the radial explosion.
  62800. */
  62801. radius: number;
  62802. /**
  62803. * The strenth of the explosion.
  62804. */
  62805. strength: number;
  62806. /**
  62807. * The strenght of the force in correspondence to the distance of the affected object
  62808. */
  62809. falloff: PhysicsRadialImpulseFalloff;
  62810. /**
  62811. * Sphere options for the radial explosion.
  62812. */
  62813. sphere: {
  62814. segments: number;
  62815. diameter: number;
  62816. };
  62817. /**
  62818. * Sphere options for the radial explosion.
  62819. */
  62820. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62821. }
  62822. /**
  62823. * Options fot the updraft event
  62824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62825. */
  62826. export class PhysicsUpdraftEventOptions {
  62827. /**
  62828. * The radius of the cylinder for the vortex
  62829. */
  62830. radius: number;
  62831. /**
  62832. * The strenth of the updraft.
  62833. */
  62834. strength: number;
  62835. /**
  62836. * The height of the cylinder for the updraft.
  62837. */
  62838. height: number;
  62839. /**
  62840. * The mode for the the updraft.
  62841. */
  62842. updraftMode: PhysicsUpdraftMode;
  62843. }
  62844. /**
  62845. * Options fot the vortex event
  62846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62847. */
  62848. export class PhysicsVortexEventOptions {
  62849. /**
  62850. * The radius of the cylinder for the vortex
  62851. */
  62852. radius: number;
  62853. /**
  62854. * The strenth of the vortex.
  62855. */
  62856. strength: number;
  62857. /**
  62858. * The height of the cylinder for the vortex.
  62859. */
  62860. height: number;
  62861. /**
  62862. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62863. */
  62864. centripetalForceThreshold: number;
  62865. /**
  62866. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62867. */
  62868. centripetalForceMultiplier: number;
  62869. /**
  62870. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62871. */
  62872. centrifugalForceMultiplier: number;
  62873. /**
  62874. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62875. */
  62876. updraftForceMultiplier: number;
  62877. }
  62878. /**
  62879. * The strenght of the force in correspondence to the distance of the affected object
  62880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62881. */
  62882. export enum PhysicsRadialImpulseFalloff {
  62883. /** Defines that impulse is constant in strength across it's whole radius */
  62884. Constant = 0,
  62885. /** Defines that impulse gets weaker if it's further from the origin */
  62886. Linear = 1
  62887. }
  62888. /**
  62889. * The strength of the force in correspondence to the distance of the affected object
  62890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62891. */
  62892. export enum PhysicsUpdraftMode {
  62893. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62894. Center = 0,
  62895. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62896. Perpendicular = 1
  62897. }
  62898. /**
  62899. * Interface for a physics hit data
  62900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62901. */
  62902. export interface PhysicsHitData {
  62903. /**
  62904. * The force applied at the contact point
  62905. */
  62906. force: Vector3;
  62907. /**
  62908. * The contact point
  62909. */
  62910. contactPoint: Vector3;
  62911. /**
  62912. * The distance from the origin to the contact point
  62913. */
  62914. distanceFromOrigin: number;
  62915. }
  62916. /**
  62917. * Interface for radial explosion event data
  62918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62919. */
  62920. export interface PhysicsRadialExplosionEventData {
  62921. /**
  62922. * A sphere used for the radial explosion event
  62923. */
  62924. sphere: Mesh;
  62925. }
  62926. /**
  62927. * Interface for gravitational field event data
  62928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62929. */
  62930. export interface PhysicsGravitationalFieldEventData {
  62931. /**
  62932. * A sphere mesh used for the gravitational field event
  62933. */
  62934. sphere: Mesh;
  62935. }
  62936. /**
  62937. * Interface for updraft event data
  62938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62939. */
  62940. export interface PhysicsUpdraftEventData {
  62941. /**
  62942. * A cylinder used for the updraft event
  62943. */
  62944. cylinder: Mesh;
  62945. }
  62946. /**
  62947. * Interface for vortex event data
  62948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62949. */
  62950. export interface PhysicsVortexEventData {
  62951. /**
  62952. * A cylinder used for the vortex event
  62953. */
  62954. cylinder: Mesh;
  62955. }
  62956. /**
  62957. * Interface for an affected physics impostor
  62958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62959. */
  62960. export interface PhysicsAffectedImpostorWithData {
  62961. /**
  62962. * The impostor affected by the effect
  62963. */
  62964. impostor: PhysicsImpostor;
  62965. /**
  62966. * The data about the hit/horce from the explosion
  62967. */
  62968. hitData: PhysicsHitData;
  62969. }
  62970. }
  62971. declare module "babylonjs/Physics/Plugins/index" {
  62972. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62973. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62974. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62975. }
  62976. declare module "babylonjs/Physics/index" {
  62977. export * from "babylonjs/Physics/IPhysicsEngine";
  62978. export * from "babylonjs/Physics/physicsEngine";
  62979. export * from "babylonjs/Physics/physicsEngineComponent";
  62980. export * from "babylonjs/Physics/physicsHelper";
  62981. export * from "babylonjs/Physics/physicsImpostor";
  62982. export * from "babylonjs/Physics/physicsJoint";
  62983. export * from "babylonjs/Physics/Plugins/index";
  62984. }
  62985. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62986. /** @hidden */
  62987. export var blackAndWhitePixelShader: {
  62988. name: string;
  62989. shader: string;
  62990. };
  62991. }
  62992. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62993. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62994. import { Camera } from "babylonjs/Cameras/camera";
  62995. import { Engine } from "babylonjs/Engines/engine";
  62996. import "babylonjs/Shaders/blackAndWhite.fragment";
  62997. /**
  62998. * Post process used to render in black and white
  62999. */
  63000. export class BlackAndWhitePostProcess extends PostProcess {
  63001. /**
  63002. * Linear about to convert he result to black and white (default: 1)
  63003. */
  63004. degree: number;
  63005. /**
  63006. * Creates a black and white post process
  63007. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63008. * @param name The name of the effect.
  63009. * @param options The required width/height ratio to downsize to before computing the render pass.
  63010. * @param camera The camera to apply the render pass to.
  63011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63012. * @param engine The engine which the post process will be applied. (default: current engine)
  63013. * @param reusable If the post process can be reused on the same frame. (default: false)
  63014. */
  63015. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63016. }
  63017. }
  63018. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63019. import { Nullable } from "babylonjs/types";
  63020. import { Camera } from "babylonjs/Cameras/camera";
  63021. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63022. import { Engine } from "babylonjs/Engines/engine";
  63023. /**
  63024. * This represents a set of one or more post processes in Babylon.
  63025. * A post process can be used to apply a shader to a texture after it is rendered.
  63026. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63027. */
  63028. export class PostProcessRenderEffect {
  63029. private _postProcesses;
  63030. private _getPostProcesses;
  63031. private _singleInstance;
  63032. private _cameras;
  63033. private _indicesForCamera;
  63034. /**
  63035. * Name of the effect
  63036. * @hidden
  63037. */
  63038. _name: string;
  63039. /**
  63040. * Instantiates a post process render effect.
  63041. * A post process can be used to apply a shader to a texture after it is rendered.
  63042. * @param engine The engine the effect is tied to
  63043. * @param name The name of the effect
  63044. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63045. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63046. */
  63047. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63048. /**
  63049. * Checks if all the post processes in the effect are supported.
  63050. */
  63051. readonly isSupported: boolean;
  63052. /**
  63053. * Updates the current state of the effect
  63054. * @hidden
  63055. */
  63056. _update(): void;
  63057. /**
  63058. * Attaches the effect on cameras
  63059. * @param cameras The camera to attach to.
  63060. * @hidden
  63061. */
  63062. _attachCameras(cameras: Camera): void;
  63063. /**
  63064. * Attaches the effect on cameras
  63065. * @param cameras The camera to attach to.
  63066. * @hidden
  63067. */
  63068. _attachCameras(cameras: Camera[]): void;
  63069. /**
  63070. * Detaches the effect on cameras
  63071. * @param cameras The camera to detatch from.
  63072. * @hidden
  63073. */
  63074. _detachCameras(cameras: Camera): void;
  63075. /**
  63076. * Detatches the effect on cameras
  63077. * @param cameras The camera to detatch from.
  63078. * @hidden
  63079. */
  63080. _detachCameras(cameras: Camera[]): void;
  63081. /**
  63082. * Enables the effect on given cameras
  63083. * @param cameras The camera to enable.
  63084. * @hidden
  63085. */
  63086. _enable(cameras: Camera): void;
  63087. /**
  63088. * Enables the effect on given cameras
  63089. * @param cameras The camera to enable.
  63090. * @hidden
  63091. */
  63092. _enable(cameras: Nullable<Camera[]>): void;
  63093. /**
  63094. * Disables the effect on the given cameras
  63095. * @param cameras The camera to disable.
  63096. * @hidden
  63097. */
  63098. _disable(cameras: Camera): void;
  63099. /**
  63100. * Disables the effect on the given cameras
  63101. * @param cameras The camera to disable.
  63102. * @hidden
  63103. */
  63104. _disable(cameras: Nullable<Camera[]>): void;
  63105. /**
  63106. * Gets a list of the post processes contained in the effect.
  63107. * @param camera The camera to get the post processes on.
  63108. * @returns The list of the post processes in the effect.
  63109. */
  63110. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63111. }
  63112. }
  63113. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63114. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63115. /** @hidden */
  63116. export var extractHighlightsPixelShader: {
  63117. name: string;
  63118. shader: string;
  63119. };
  63120. }
  63121. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63122. import { Nullable } from "babylonjs/types";
  63123. import { Camera } from "babylonjs/Cameras/camera";
  63124. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63125. import { Engine } from "babylonjs/Engines/engine";
  63126. import "babylonjs/Shaders/extractHighlights.fragment";
  63127. /**
  63128. * 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.
  63129. */
  63130. export class ExtractHighlightsPostProcess extends PostProcess {
  63131. /**
  63132. * The luminance threshold, pixels below this value will be set to black.
  63133. */
  63134. threshold: number;
  63135. /** @hidden */
  63136. _exposure: number;
  63137. /**
  63138. * Post process which has the input texture to be used when performing highlight extraction
  63139. * @hidden
  63140. */
  63141. _inputPostProcess: Nullable<PostProcess>;
  63142. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63143. }
  63144. }
  63145. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63146. /** @hidden */
  63147. export var bloomMergePixelShader: {
  63148. name: string;
  63149. shader: string;
  63150. };
  63151. }
  63152. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63153. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63154. import { Nullable } from "babylonjs/types";
  63155. import { Engine } from "babylonjs/Engines/engine";
  63156. import { Camera } from "babylonjs/Cameras/camera";
  63157. import "babylonjs/Shaders/bloomMerge.fragment";
  63158. /**
  63159. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63160. */
  63161. export class BloomMergePostProcess extends PostProcess {
  63162. /** Weight of the bloom to be added to the original input. */
  63163. weight: number;
  63164. /**
  63165. * Creates a new instance of @see BloomMergePostProcess
  63166. * @param name The name of the effect.
  63167. * @param originalFromInput Post process which's input will be used for the merge.
  63168. * @param blurred Blurred highlights post process which's output will be used.
  63169. * @param weight Weight of the bloom to be added to the original input.
  63170. * @param options The required width/height ratio to downsize to before computing the render pass.
  63171. * @param camera The camera to apply the render pass to.
  63172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63173. * @param engine The engine which the post process will be applied. (default: current engine)
  63174. * @param reusable If the post process can be reused on the same frame. (default: false)
  63175. * @param textureType Type of textures used when performing the post process. (default: 0)
  63176. * @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)
  63177. */
  63178. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63179. /** Weight of the bloom to be added to the original input. */
  63180. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63181. }
  63182. }
  63183. declare module "babylonjs/PostProcesses/bloomEffect" {
  63184. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63185. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63186. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63187. import { Camera } from "babylonjs/Cameras/camera";
  63188. import { Scene } from "babylonjs/scene";
  63189. /**
  63190. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63191. */
  63192. export class BloomEffect extends PostProcessRenderEffect {
  63193. private bloomScale;
  63194. /**
  63195. * @hidden Internal
  63196. */
  63197. _effects: Array<PostProcess>;
  63198. /**
  63199. * @hidden Internal
  63200. */
  63201. _downscale: ExtractHighlightsPostProcess;
  63202. private _blurX;
  63203. private _blurY;
  63204. private _merge;
  63205. /**
  63206. * The luminance threshold to find bright areas of the image to bloom.
  63207. */
  63208. threshold: number;
  63209. /**
  63210. * The strength of the bloom.
  63211. */
  63212. weight: number;
  63213. /**
  63214. * Specifies the size of the bloom blur kernel, relative to the final output size
  63215. */
  63216. kernel: number;
  63217. /**
  63218. * Creates a new instance of @see BloomEffect
  63219. * @param scene The scene the effect belongs to.
  63220. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63221. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63222. * @param bloomWeight The the strength of bloom.
  63223. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63224. * @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)
  63225. */
  63226. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63227. /**
  63228. * Disposes each of the internal effects for a given camera.
  63229. * @param camera The camera to dispose the effect on.
  63230. */
  63231. disposeEffects(camera: Camera): void;
  63232. /**
  63233. * @hidden Internal
  63234. */
  63235. _updateEffects(): void;
  63236. /**
  63237. * Internal
  63238. * @returns if all the contained post processes are ready.
  63239. * @hidden
  63240. */
  63241. _isReady(): boolean;
  63242. }
  63243. }
  63244. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63245. /** @hidden */
  63246. export var chromaticAberrationPixelShader: {
  63247. name: string;
  63248. shader: string;
  63249. };
  63250. }
  63251. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63252. import { Vector2 } from "babylonjs/Maths/math.vector";
  63253. import { Nullable } from "babylonjs/types";
  63254. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63255. import { Camera } from "babylonjs/Cameras/camera";
  63256. import { Engine } from "babylonjs/Engines/engine";
  63257. import "babylonjs/Shaders/chromaticAberration.fragment";
  63258. /**
  63259. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63260. */
  63261. export class ChromaticAberrationPostProcess extends PostProcess {
  63262. /**
  63263. * The amount of seperation of rgb channels (default: 30)
  63264. */
  63265. aberrationAmount: number;
  63266. /**
  63267. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63268. */
  63269. radialIntensity: number;
  63270. /**
  63271. * 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))
  63272. */
  63273. direction: Vector2;
  63274. /**
  63275. * 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))
  63276. */
  63277. centerPosition: Vector2;
  63278. /**
  63279. * Creates a new instance ChromaticAberrationPostProcess
  63280. * @param name The name of the effect.
  63281. * @param screenWidth The width of the screen to apply the effect on.
  63282. * @param screenHeight The height of the screen to apply the effect on.
  63283. * @param options The required width/height ratio to downsize to before computing the render pass.
  63284. * @param camera The camera to apply the render pass to.
  63285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63286. * @param engine The engine which the post process will be applied. (default: current engine)
  63287. * @param reusable If the post process can be reused on the same frame. (default: false)
  63288. * @param textureType Type of textures used when performing the post process. (default: 0)
  63289. * @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)
  63290. */
  63291. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63292. }
  63293. }
  63294. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63295. /** @hidden */
  63296. export var circleOfConfusionPixelShader: {
  63297. name: string;
  63298. shader: string;
  63299. };
  63300. }
  63301. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63302. import { Nullable } from "babylonjs/types";
  63303. import { Engine } from "babylonjs/Engines/engine";
  63304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63305. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63306. import { Camera } from "babylonjs/Cameras/camera";
  63307. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63308. /**
  63309. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63310. */
  63311. export class CircleOfConfusionPostProcess extends PostProcess {
  63312. /**
  63313. * 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.
  63314. */
  63315. lensSize: number;
  63316. /**
  63317. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63318. */
  63319. fStop: number;
  63320. /**
  63321. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63322. */
  63323. focusDistance: number;
  63324. /**
  63325. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63326. */
  63327. focalLength: number;
  63328. private _depthTexture;
  63329. /**
  63330. * Creates a new instance CircleOfConfusionPostProcess
  63331. * @param name The name of the effect.
  63332. * @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.
  63333. * @param options The required width/height ratio to downsize to before computing the render pass.
  63334. * @param camera The camera to apply the render pass to.
  63335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63336. * @param engine The engine which the post process will be applied. (default: current engine)
  63337. * @param reusable If the post process can be reused on the same frame. (default: false)
  63338. * @param textureType Type of textures used when performing the post process. (default: 0)
  63339. * @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)
  63340. */
  63341. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63342. /**
  63343. * 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.
  63344. */
  63345. depthTexture: RenderTargetTexture;
  63346. }
  63347. }
  63348. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63349. /** @hidden */
  63350. export var colorCorrectionPixelShader: {
  63351. name: string;
  63352. shader: string;
  63353. };
  63354. }
  63355. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63357. import { Engine } from "babylonjs/Engines/engine";
  63358. import { Camera } from "babylonjs/Cameras/camera";
  63359. import "babylonjs/Shaders/colorCorrection.fragment";
  63360. /**
  63361. *
  63362. * This post-process allows the modification of rendered colors by using
  63363. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63364. *
  63365. * The object needs to be provided an url to a texture containing the color
  63366. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63367. * Use an image editing software to tweak the LUT to match your needs.
  63368. *
  63369. * For an example of a color LUT, see here:
  63370. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63371. * For explanations on color grading, see here:
  63372. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63373. *
  63374. */
  63375. export class ColorCorrectionPostProcess extends PostProcess {
  63376. private _colorTableTexture;
  63377. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63378. }
  63379. }
  63380. declare module "babylonjs/Shaders/convolution.fragment" {
  63381. /** @hidden */
  63382. export var convolutionPixelShader: {
  63383. name: string;
  63384. shader: string;
  63385. };
  63386. }
  63387. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63388. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63389. import { Nullable } from "babylonjs/types";
  63390. import { Camera } from "babylonjs/Cameras/camera";
  63391. import { Engine } from "babylonjs/Engines/engine";
  63392. import "babylonjs/Shaders/convolution.fragment";
  63393. /**
  63394. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63395. * input texture to perform effects such as edge detection or sharpening
  63396. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63397. */
  63398. export class ConvolutionPostProcess extends PostProcess {
  63399. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63400. kernel: number[];
  63401. /**
  63402. * Creates a new instance ConvolutionPostProcess
  63403. * @param name The name of the effect.
  63404. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63405. * @param options The required width/height ratio to downsize to before computing the render pass.
  63406. * @param camera The camera to apply the render pass to.
  63407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63408. * @param engine The engine which the post process will be applied. (default: current engine)
  63409. * @param reusable If the post process can be reused on the same frame. (default: false)
  63410. * @param textureType Type of textures used when performing the post process. (default: 0)
  63411. */
  63412. constructor(name: string,
  63413. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63414. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63415. /**
  63416. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63417. */
  63418. static EdgeDetect0Kernel: number[];
  63419. /**
  63420. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63421. */
  63422. static EdgeDetect1Kernel: number[];
  63423. /**
  63424. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63425. */
  63426. static EdgeDetect2Kernel: number[];
  63427. /**
  63428. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63429. */
  63430. static SharpenKernel: number[];
  63431. /**
  63432. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63433. */
  63434. static EmbossKernel: number[];
  63435. /**
  63436. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63437. */
  63438. static GaussianKernel: number[];
  63439. }
  63440. }
  63441. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63442. import { Nullable } from "babylonjs/types";
  63443. import { Vector2 } from "babylonjs/Maths/math.vector";
  63444. import { Camera } from "babylonjs/Cameras/camera";
  63445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63446. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63447. import { Engine } from "babylonjs/Engines/engine";
  63448. import { Scene } from "babylonjs/scene";
  63449. /**
  63450. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63451. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63452. * based on samples that have a large difference in distance than the center pixel.
  63453. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63454. */
  63455. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63456. direction: Vector2;
  63457. /**
  63458. * Creates a new instance CircleOfConfusionPostProcess
  63459. * @param name The name of the effect.
  63460. * @param scene The scene the effect belongs to.
  63461. * @param direction The direction the blur should be applied.
  63462. * @param kernel The size of the kernel used to blur.
  63463. * @param options The required width/height ratio to downsize to before computing the render pass.
  63464. * @param camera The camera to apply the render pass to.
  63465. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63466. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63468. * @param engine The engine which the post process will be applied. (default: current engine)
  63469. * @param reusable If the post process can be reused on the same frame. (default: false)
  63470. * @param textureType Type of textures used when performing the post process. (default: 0)
  63471. * @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)
  63472. */
  63473. 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);
  63474. }
  63475. }
  63476. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63477. /** @hidden */
  63478. export var depthOfFieldMergePixelShader: {
  63479. name: string;
  63480. shader: string;
  63481. };
  63482. }
  63483. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63484. import { Nullable } from "babylonjs/types";
  63485. import { Camera } from "babylonjs/Cameras/camera";
  63486. import { Effect } from "babylonjs/Materials/effect";
  63487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63488. import { Engine } from "babylonjs/Engines/engine";
  63489. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63490. /**
  63491. * Options to be set when merging outputs from the default pipeline.
  63492. */
  63493. export class DepthOfFieldMergePostProcessOptions {
  63494. /**
  63495. * The original image to merge on top of
  63496. */
  63497. originalFromInput: PostProcess;
  63498. /**
  63499. * Parameters to perform the merge of the depth of field effect
  63500. */
  63501. depthOfField?: {
  63502. circleOfConfusion: PostProcess;
  63503. blurSteps: Array<PostProcess>;
  63504. };
  63505. /**
  63506. * Parameters to perform the merge of bloom effect
  63507. */
  63508. bloom?: {
  63509. blurred: PostProcess;
  63510. weight: number;
  63511. };
  63512. }
  63513. /**
  63514. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63515. */
  63516. export class DepthOfFieldMergePostProcess extends PostProcess {
  63517. private blurSteps;
  63518. /**
  63519. * Creates a new instance of DepthOfFieldMergePostProcess
  63520. * @param name The name of the effect.
  63521. * @param originalFromInput Post process which's input will be used for the merge.
  63522. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63523. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63524. * @param options The required width/height ratio to downsize to before computing the render pass.
  63525. * @param camera The camera to apply the render pass to.
  63526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63527. * @param engine The engine which the post process will be applied. (default: current engine)
  63528. * @param reusable If the post process can be reused on the same frame. (default: false)
  63529. * @param textureType Type of textures used when performing the post process. (default: 0)
  63530. * @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)
  63531. */
  63532. 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);
  63533. /**
  63534. * Updates the effect with the current post process compile time values and recompiles the shader.
  63535. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63536. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63537. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63538. * @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
  63539. * @param onCompiled Called when the shader has been compiled.
  63540. * @param onError Called if there is an error when compiling a shader.
  63541. */
  63542. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63543. }
  63544. }
  63545. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63546. import { Nullable } from "babylonjs/types";
  63547. import { Camera } from "babylonjs/Cameras/camera";
  63548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63549. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63550. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63551. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63552. import { Scene } from "babylonjs/scene";
  63553. /**
  63554. * Specifies the level of max blur that should be applied when using the depth of field effect
  63555. */
  63556. export enum DepthOfFieldEffectBlurLevel {
  63557. /**
  63558. * Subtle blur
  63559. */
  63560. Low = 0,
  63561. /**
  63562. * Medium blur
  63563. */
  63564. Medium = 1,
  63565. /**
  63566. * Large blur
  63567. */
  63568. High = 2
  63569. }
  63570. /**
  63571. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63572. */
  63573. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63574. private _circleOfConfusion;
  63575. /**
  63576. * @hidden Internal, blurs from high to low
  63577. */
  63578. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63579. private _depthOfFieldBlurY;
  63580. private _dofMerge;
  63581. /**
  63582. * @hidden Internal post processes in depth of field effect
  63583. */
  63584. _effects: Array<PostProcess>;
  63585. /**
  63586. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63587. */
  63588. focalLength: number;
  63589. /**
  63590. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63591. */
  63592. fStop: number;
  63593. /**
  63594. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63595. */
  63596. focusDistance: number;
  63597. /**
  63598. * 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.
  63599. */
  63600. lensSize: number;
  63601. /**
  63602. * Creates a new instance DepthOfFieldEffect
  63603. * @param scene The scene the effect belongs to.
  63604. * @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.
  63605. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63606. * @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)
  63607. */
  63608. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63609. /**
  63610. * Get the current class name of the current effet
  63611. * @returns "DepthOfFieldEffect"
  63612. */
  63613. getClassName(): string;
  63614. /**
  63615. * 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.
  63616. */
  63617. depthTexture: RenderTargetTexture;
  63618. /**
  63619. * Disposes each of the internal effects for a given camera.
  63620. * @param camera The camera to dispose the effect on.
  63621. */
  63622. disposeEffects(camera: Camera): void;
  63623. /**
  63624. * @hidden Internal
  63625. */
  63626. _updateEffects(): void;
  63627. /**
  63628. * Internal
  63629. * @returns if all the contained post processes are ready.
  63630. * @hidden
  63631. */
  63632. _isReady(): boolean;
  63633. }
  63634. }
  63635. declare module "babylonjs/Shaders/displayPass.fragment" {
  63636. /** @hidden */
  63637. export var displayPassPixelShader: {
  63638. name: string;
  63639. shader: string;
  63640. };
  63641. }
  63642. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63643. import { Nullable } from "babylonjs/types";
  63644. import { Camera } from "babylonjs/Cameras/camera";
  63645. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63646. import { Engine } from "babylonjs/Engines/engine";
  63647. import "babylonjs/Shaders/displayPass.fragment";
  63648. /**
  63649. * DisplayPassPostProcess which produces an output the same as it's input
  63650. */
  63651. export class DisplayPassPostProcess extends PostProcess {
  63652. /**
  63653. * Creates the DisplayPassPostProcess
  63654. * @param name The name of the effect.
  63655. * @param options The required width/height ratio to downsize to before computing the render pass.
  63656. * @param camera The camera to apply the render pass to.
  63657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63658. * @param engine The engine which the post process will be applied. (default: current engine)
  63659. * @param reusable If the post process can be reused on the same frame. (default: false)
  63660. */
  63661. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63662. }
  63663. }
  63664. declare module "babylonjs/Shaders/filter.fragment" {
  63665. /** @hidden */
  63666. export var filterPixelShader: {
  63667. name: string;
  63668. shader: string;
  63669. };
  63670. }
  63671. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63672. import { Nullable } from "babylonjs/types";
  63673. import { Matrix } from "babylonjs/Maths/math.vector";
  63674. import { Camera } from "babylonjs/Cameras/camera";
  63675. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63676. import { Engine } from "babylonjs/Engines/engine";
  63677. import "babylonjs/Shaders/filter.fragment";
  63678. /**
  63679. * Applies a kernel filter to the image
  63680. */
  63681. export class FilterPostProcess extends PostProcess {
  63682. /** The matrix to be applied to the image */
  63683. kernelMatrix: Matrix;
  63684. /**
  63685. *
  63686. * @param name The name of the effect.
  63687. * @param kernelMatrix The matrix to be applied to the image
  63688. * @param options The required width/height ratio to downsize to before computing the render pass.
  63689. * @param camera The camera to apply the render pass to.
  63690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63691. * @param engine The engine which the post process will be applied. (default: current engine)
  63692. * @param reusable If the post process can be reused on the same frame. (default: false)
  63693. */
  63694. constructor(name: string,
  63695. /** The matrix to be applied to the image */
  63696. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63697. }
  63698. }
  63699. declare module "babylonjs/Shaders/fxaa.fragment" {
  63700. /** @hidden */
  63701. export var fxaaPixelShader: {
  63702. name: string;
  63703. shader: string;
  63704. };
  63705. }
  63706. declare module "babylonjs/Shaders/fxaa.vertex" {
  63707. /** @hidden */
  63708. export var fxaaVertexShader: {
  63709. name: string;
  63710. shader: string;
  63711. };
  63712. }
  63713. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63714. import { Nullable } from "babylonjs/types";
  63715. import { Camera } from "babylonjs/Cameras/camera";
  63716. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63717. import { Engine } from "babylonjs/Engines/engine";
  63718. import "babylonjs/Shaders/fxaa.fragment";
  63719. import "babylonjs/Shaders/fxaa.vertex";
  63720. /**
  63721. * Fxaa post process
  63722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63723. */
  63724. export class FxaaPostProcess extends PostProcess {
  63725. /** @hidden */
  63726. texelWidth: number;
  63727. /** @hidden */
  63728. texelHeight: number;
  63729. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63730. private _getDefines;
  63731. }
  63732. }
  63733. declare module "babylonjs/Shaders/grain.fragment" {
  63734. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63735. /** @hidden */
  63736. export var grainPixelShader: {
  63737. name: string;
  63738. shader: string;
  63739. };
  63740. }
  63741. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63742. import { Nullable } from "babylonjs/types";
  63743. import { Camera } from "babylonjs/Cameras/camera";
  63744. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63745. import { Engine } from "babylonjs/Engines/engine";
  63746. import "babylonjs/Shaders/grain.fragment";
  63747. /**
  63748. * The GrainPostProcess adds noise to the image at mid luminance levels
  63749. */
  63750. export class GrainPostProcess extends PostProcess {
  63751. /**
  63752. * The intensity of the grain added (default: 30)
  63753. */
  63754. intensity: number;
  63755. /**
  63756. * If the grain should be randomized on every frame
  63757. */
  63758. animated: boolean;
  63759. /**
  63760. * Creates a new instance of @see GrainPostProcess
  63761. * @param name The name of the effect.
  63762. * @param options The required width/height ratio to downsize to before computing the render pass.
  63763. * @param camera The camera to apply the render pass to.
  63764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63765. * @param engine The engine which the post process will be applied. (default: current engine)
  63766. * @param reusable If the post process can be reused on the same frame. (default: false)
  63767. * @param textureType Type of textures used when performing the post process. (default: 0)
  63768. * @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)
  63769. */
  63770. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63771. }
  63772. }
  63773. declare module "babylonjs/Shaders/highlights.fragment" {
  63774. /** @hidden */
  63775. export var highlightsPixelShader: {
  63776. name: string;
  63777. shader: string;
  63778. };
  63779. }
  63780. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63781. import { Nullable } from "babylonjs/types";
  63782. import { Camera } from "babylonjs/Cameras/camera";
  63783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63784. import { Engine } from "babylonjs/Engines/engine";
  63785. import "babylonjs/Shaders/highlights.fragment";
  63786. /**
  63787. * Extracts highlights from the image
  63788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63789. */
  63790. export class HighlightsPostProcess extends PostProcess {
  63791. /**
  63792. * Extracts highlights from the image
  63793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63794. * @param name The name of the effect.
  63795. * @param options The required width/height ratio to downsize to before computing the render pass.
  63796. * @param camera The camera to apply the render pass to.
  63797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63798. * @param engine The engine which the post process will be applied. (default: current engine)
  63799. * @param reusable If the post process can be reused on the same frame. (default: false)
  63800. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63801. */
  63802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63803. }
  63804. }
  63805. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63806. /** @hidden */
  63807. export var mrtFragmentDeclaration: {
  63808. name: string;
  63809. shader: string;
  63810. };
  63811. }
  63812. declare module "babylonjs/Shaders/geometry.fragment" {
  63813. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63814. /** @hidden */
  63815. export var geometryPixelShader: {
  63816. name: string;
  63817. shader: string;
  63818. };
  63819. }
  63820. declare module "babylonjs/Shaders/geometry.vertex" {
  63821. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63822. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63823. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63824. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63825. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63826. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63827. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63828. /** @hidden */
  63829. export var geometryVertexShader: {
  63830. name: string;
  63831. shader: string;
  63832. };
  63833. }
  63834. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63835. import { Matrix } from "babylonjs/Maths/math.vector";
  63836. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63837. import { Mesh } from "babylonjs/Meshes/mesh";
  63838. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63839. import { Effect } from "babylonjs/Materials/effect";
  63840. import { Scene } from "babylonjs/scene";
  63841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63842. import "babylonjs/Shaders/geometry.fragment";
  63843. import "babylonjs/Shaders/geometry.vertex";
  63844. /** @hidden */
  63845. interface ISavedTransformationMatrix {
  63846. world: Matrix;
  63847. viewProjection: Matrix;
  63848. }
  63849. /**
  63850. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63851. */
  63852. export class GeometryBufferRenderer {
  63853. /**
  63854. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63855. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63856. */
  63857. static readonly POSITION_TEXTURE_TYPE: number;
  63858. /**
  63859. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63860. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63861. */
  63862. static readonly VELOCITY_TEXTURE_TYPE: number;
  63863. /**
  63864. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63865. * in order to compute objects velocities when enableVelocity is set to "true"
  63866. * @hidden
  63867. */
  63868. _previousTransformationMatrices: {
  63869. [index: number]: ISavedTransformationMatrix;
  63870. };
  63871. /**
  63872. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63873. * in order to compute objects velocities when enableVelocity is set to "true"
  63874. * @hidden
  63875. */
  63876. _previousBonesTransformationMatrices: {
  63877. [index: number]: Float32Array;
  63878. };
  63879. /**
  63880. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63881. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63882. */
  63883. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63884. private _scene;
  63885. private _multiRenderTarget;
  63886. private _ratio;
  63887. private _enablePosition;
  63888. private _enableVelocity;
  63889. private _positionIndex;
  63890. private _velocityIndex;
  63891. protected _effect: Effect;
  63892. protected _cachedDefines: string;
  63893. /**
  63894. * Set the render list (meshes to be rendered) used in the G buffer.
  63895. */
  63896. renderList: Mesh[];
  63897. /**
  63898. * Gets wether or not G buffer are supported by the running hardware.
  63899. * This requires draw buffer supports
  63900. */
  63901. readonly isSupported: boolean;
  63902. /**
  63903. * Returns the index of the given texture type in the G-Buffer textures array
  63904. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63905. * @returns the index of the given texture type in the G-Buffer textures array
  63906. */
  63907. getTextureIndex(textureType: number): number;
  63908. /**
  63909. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63910. */
  63911. /**
  63912. * Sets whether or not objects positions are enabled for the G buffer.
  63913. */
  63914. enablePosition: boolean;
  63915. /**
  63916. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63917. */
  63918. /**
  63919. * Sets wether or not objects velocities are enabled for the G buffer.
  63920. */
  63921. enableVelocity: boolean;
  63922. /**
  63923. * Gets the scene associated with the buffer.
  63924. */
  63925. readonly scene: Scene;
  63926. /**
  63927. * Gets the ratio used by the buffer during its creation.
  63928. * How big is the buffer related to the main canvas.
  63929. */
  63930. readonly ratio: number;
  63931. /** @hidden */
  63932. static _SceneComponentInitialization: (scene: Scene) => void;
  63933. /**
  63934. * Creates a new G Buffer for the scene
  63935. * @param scene The scene the buffer belongs to
  63936. * @param ratio How big is the buffer related to the main canvas.
  63937. */
  63938. constructor(scene: Scene, ratio?: number);
  63939. /**
  63940. * Checks wether everything is ready to render a submesh to the G buffer.
  63941. * @param subMesh the submesh to check readiness for
  63942. * @param useInstances is the mesh drawn using instance or not
  63943. * @returns true if ready otherwise false
  63944. */
  63945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63946. /**
  63947. * Gets the current underlying G Buffer.
  63948. * @returns the buffer
  63949. */
  63950. getGBuffer(): MultiRenderTarget;
  63951. /**
  63952. * Gets the number of samples used to render the buffer (anti aliasing).
  63953. */
  63954. /**
  63955. * Sets the number of samples used to render the buffer (anti aliasing).
  63956. */
  63957. samples: number;
  63958. /**
  63959. * Disposes the renderer and frees up associated resources.
  63960. */
  63961. dispose(): void;
  63962. protected _createRenderTargets(): void;
  63963. private _copyBonesTransformationMatrices;
  63964. }
  63965. }
  63966. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63967. import { Nullable } from "babylonjs/types";
  63968. import { Scene } from "babylonjs/scene";
  63969. import { ISceneComponent } from "babylonjs/sceneComponent";
  63970. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63971. module "babylonjs/scene" {
  63972. interface Scene {
  63973. /** @hidden (Backing field) */
  63974. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63975. /**
  63976. * Gets or Sets the current geometry buffer associated to the scene.
  63977. */
  63978. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63979. /**
  63980. * Enables a GeometryBufferRender and associates it with the scene
  63981. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63982. * @returns the GeometryBufferRenderer
  63983. */
  63984. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63985. /**
  63986. * Disables the GeometryBufferRender associated with the scene
  63987. */
  63988. disableGeometryBufferRenderer(): void;
  63989. }
  63990. }
  63991. /**
  63992. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63993. * in several rendering techniques.
  63994. */
  63995. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63996. /**
  63997. * The component name helpful to identify the component in the list of scene components.
  63998. */
  63999. readonly name: string;
  64000. /**
  64001. * The scene the component belongs to.
  64002. */
  64003. scene: Scene;
  64004. /**
  64005. * Creates a new instance of the component for the given scene
  64006. * @param scene Defines the scene to register the component in
  64007. */
  64008. constructor(scene: Scene);
  64009. /**
  64010. * Registers the component in a given scene
  64011. */
  64012. register(): void;
  64013. /**
  64014. * Rebuilds the elements related to this component in case of
  64015. * context lost for instance.
  64016. */
  64017. rebuild(): void;
  64018. /**
  64019. * Disposes the component and the associated ressources
  64020. */
  64021. dispose(): void;
  64022. private _gatherRenderTargets;
  64023. }
  64024. }
  64025. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64026. /** @hidden */
  64027. export var motionBlurPixelShader: {
  64028. name: string;
  64029. shader: string;
  64030. };
  64031. }
  64032. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64033. import { Nullable } from "babylonjs/types";
  64034. import { Camera } from "babylonjs/Cameras/camera";
  64035. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64036. import { Scene } from "babylonjs/scene";
  64037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64038. import "babylonjs/Animations/animatable";
  64039. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64040. import "babylonjs/Shaders/motionBlur.fragment";
  64041. import { Engine } from "babylonjs/Engines/engine";
  64042. /**
  64043. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64044. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64045. * As an example, all you have to do is to create the post-process:
  64046. * var mb = new BABYLON.MotionBlurPostProcess(
  64047. * 'mb', // The name of the effect.
  64048. * scene, // The scene containing the objects to blur according to their velocity.
  64049. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64050. * camera // The camera to apply the render pass to.
  64051. * );
  64052. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64053. */
  64054. export class MotionBlurPostProcess extends PostProcess {
  64055. /**
  64056. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64057. */
  64058. motionStrength: number;
  64059. /**
  64060. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64061. */
  64062. /**
  64063. * Sets the number of iterations to be used for motion blur quality
  64064. */
  64065. motionBlurSamples: number;
  64066. private _motionBlurSamples;
  64067. private _geometryBufferRenderer;
  64068. /**
  64069. * Creates a new instance MotionBlurPostProcess
  64070. * @param name The name of the effect.
  64071. * @param scene The scene containing the objects to blur according to their velocity.
  64072. * @param options The required width/height ratio to downsize to before computing the render pass.
  64073. * @param camera The camera to apply the render pass to.
  64074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64075. * @param engine The engine which the post process will be applied. (default: current engine)
  64076. * @param reusable If the post process can be reused on the same frame. (default: false)
  64077. * @param textureType Type of textures used when performing the post process. (default: 0)
  64078. * @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)
  64079. */
  64080. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64081. /**
  64082. * Excludes the given skinned mesh from computing bones velocities.
  64083. * 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.
  64084. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64085. */
  64086. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64087. /**
  64088. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64089. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64090. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64091. */
  64092. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64093. /**
  64094. * Disposes the post process.
  64095. * @param camera The camera to dispose the post process on.
  64096. */
  64097. dispose(camera?: Camera): void;
  64098. }
  64099. }
  64100. declare module "babylonjs/Shaders/refraction.fragment" {
  64101. /** @hidden */
  64102. export var refractionPixelShader: {
  64103. name: string;
  64104. shader: string;
  64105. };
  64106. }
  64107. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64108. import { Color3 } from "babylonjs/Maths/math.color";
  64109. import { Camera } from "babylonjs/Cameras/camera";
  64110. import { Texture } from "babylonjs/Materials/Textures/texture";
  64111. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64112. import { Engine } from "babylonjs/Engines/engine";
  64113. import "babylonjs/Shaders/refraction.fragment";
  64114. /**
  64115. * Post process which applies a refractin texture
  64116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64117. */
  64118. export class RefractionPostProcess extends PostProcess {
  64119. /** the base color of the refraction (used to taint the rendering) */
  64120. color: Color3;
  64121. /** simulated refraction depth */
  64122. depth: number;
  64123. /** the coefficient of the base color (0 to remove base color tainting) */
  64124. colorLevel: number;
  64125. private _refTexture;
  64126. private _ownRefractionTexture;
  64127. /**
  64128. * Gets or sets the refraction texture
  64129. * Please note that you are responsible for disposing the texture if you set it manually
  64130. */
  64131. refractionTexture: Texture;
  64132. /**
  64133. * Initializes the RefractionPostProcess
  64134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64135. * @param name The name of the effect.
  64136. * @param refractionTextureUrl Url of the refraction texture to use
  64137. * @param color the base color of the refraction (used to taint the rendering)
  64138. * @param depth simulated refraction depth
  64139. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64140. * @param camera The camera to apply the render pass to.
  64141. * @param options The required width/height ratio to downsize to before computing the render pass.
  64142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64143. * @param engine The engine which the post process will be applied. (default: current engine)
  64144. * @param reusable If the post process can be reused on the same frame. (default: false)
  64145. */
  64146. constructor(name: string, refractionTextureUrl: string,
  64147. /** the base color of the refraction (used to taint the rendering) */
  64148. color: Color3,
  64149. /** simulated refraction depth */
  64150. depth: number,
  64151. /** the coefficient of the base color (0 to remove base color tainting) */
  64152. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64153. /**
  64154. * Disposes of the post process
  64155. * @param camera Camera to dispose post process on
  64156. */
  64157. dispose(camera: Camera): void;
  64158. }
  64159. }
  64160. declare module "babylonjs/Shaders/sharpen.fragment" {
  64161. /** @hidden */
  64162. export var sharpenPixelShader: {
  64163. name: string;
  64164. shader: string;
  64165. };
  64166. }
  64167. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64168. import { Nullable } from "babylonjs/types";
  64169. import { Camera } from "babylonjs/Cameras/camera";
  64170. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64171. import "babylonjs/Shaders/sharpen.fragment";
  64172. import { Engine } from "babylonjs/Engines/engine";
  64173. /**
  64174. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64175. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64176. */
  64177. export class SharpenPostProcess extends PostProcess {
  64178. /**
  64179. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64180. */
  64181. colorAmount: number;
  64182. /**
  64183. * How much sharpness should be applied (default: 0.3)
  64184. */
  64185. edgeAmount: number;
  64186. /**
  64187. * Creates a new instance ConvolutionPostProcess
  64188. * @param name The name of the effect.
  64189. * @param options The required width/height ratio to downsize to before computing the render pass.
  64190. * @param camera The camera to apply the render pass to.
  64191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64192. * @param engine The engine which the post process will be applied. (default: current engine)
  64193. * @param reusable If the post process can be reused on the same frame. (default: false)
  64194. * @param textureType Type of textures used when performing the post process. (default: 0)
  64195. * @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)
  64196. */
  64197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64198. }
  64199. }
  64200. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64201. import { Nullable } from "babylonjs/types";
  64202. import { Camera } from "babylonjs/Cameras/camera";
  64203. import { Engine } from "babylonjs/Engines/engine";
  64204. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64205. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64206. /**
  64207. * PostProcessRenderPipeline
  64208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64209. */
  64210. export class PostProcessRenderPipeline {
  64211. private engine;
  64212. private _renderEffects;
  64213. private _renderEffectsForIsolatedPass;
  64214. /**
  64215. * List of inspectable custom properties (used by the Inspector)
  64216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64217. */
  64218. inspectableCustomProperties: IInspectable[];
  64219. /**
  64220. * @hidden
  64221. */
  64222. protected _cameras: Camera[];
  64223. /** @hidden */
  64224. _name: string;
  64225. /**
  64226. * Gets pipeline name
  64227. */
  64228. readonly name: string;
  64229. /** Gets the list of attached cameras */
  64230. readonly cameras: Camera[];
  64231. /**
  64232. * Initializes a PostProcessRenderPipeline
  64233. * @param engine engine to add the pipeline to
  64234. * @param name name of the pipeline
  64235. */
  64236. constructor(engine: Engine, name: string);
  64237. /**
  64238. * Gets the class name
  64239. * @returns "PostProcessRenderPipeline"
  64240. */
  64241. getClassName(): string;
  64242. /**
  64243. * If all the render effects in the pipeline are supported
  64244. */
  64245. readonly isSupported: boolean;
  64246. /**
  64247. * Adds an effect to the pipeline
  64248. * @param renderEffect the effect to add
  64249. */
  64250. addEffect(renderEffect: PostProcessRenderEffect): void;
  64251. /** @hidden */
  64252. _rebuild(): void;
  64253. /** @hidden */
  64254. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64255. /** @hidden */
  64256. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64257. /** @hidden */
  64258. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64259. /** @hidden */
  64260. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64261. /** @hidden */
  64262. _attachCameras(cameras: Camera, unique: boolean): void;
  64263. /** @hidden */
  64264. _attachCameras(cameras: Camera[], unique: boolean): void;
  64265. /** @hidden */
  64266. _detachCameras(cameras: Camera): void;
  64267. /** @hidden */
  64268. _detachCameras(cameras: Nullable<Camera[]>): void;
  64269. /** @hidden */
  64270. _update(): void;
  64271. /** @hidden */
  64272. _reset(): void;
  64273. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64274. /**
  64275. * Disposes of the pipeline
  64276. */
  64277. dispose(): void;
  64278. }
  64279. }
  64280. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64281. import { Camera } from "babylonjs/Cameras/camera";
  64282. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64283. /**
  64284. * PostProcessRenderPipelineManager class
  64285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64286. */
  64287. export class PostProcessRenderPipelineManager {
  64288. private _renderPipelines;
  64289. /**
  64290. * Initializes a PostProcessRenderPipelineManager
  64291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64292. */
  64293. constructor();
  64294. /**
  64295. * Gets the list of supported render pipelines
  64296. */
  64297. readonly supportedPipelines: PostProcessRenderPipeline[];
  64298. /**
  64299. * Adds a pipeline to the manager
  64300. * @param renderPipeline The pipeline to add
  64301. */
  64302. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64303. /**
  64304. * Attaches a camera to the pipeline
  64305. * @param renderPipelineName The name of the pipeline to attach to
  64306. * @param cameras the camera to attach
  64307. * @param unique if the camera can be attached multiple times to the pipeline
  64308. */
  64309. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64310. /**
  64311. * Detaches a camera from the pipeline
  64312. * @param renderPipelineName The name of the pipeline to detach from
  64313. * @param cameras the camera to detach
  64314. */
  64315. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64316. /**
  64317. * Enables an effect by name on a pipeline
  64318. * @param renderPipelineName the name of the pipeline to enable the effect in
  64319. * @param renderEffectName the name of the effect to enable
  64320. * @param cameras the cameras that the effect should be enabled on
  64321. */
  64322. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64323. /**
  64324. * Disables an effect by name on a pipeline
  64325. * @param renderPipelineName the name of the pipeline to disable the effect in
  64326. * @param renderEffectName the name of the effect to disable
  64327. * @param cameras the cameras that the effect should be disabled on
  64328. */
  64329. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64330. /**
  64331. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64332. */
  64333. update(): void;
  64334. /** @hidden */
  64335. _rebuild(): void;
  64336. /**
  64337. * Disposes of the manager and pipelines
  64338. */
  64339. dispose(): void;
  64340. }
  64341. }
  64342. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64343. import { ISceneComponent } from "babylonjs/sceneComponent";
  64344. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64345. import { Scene } from "babylonjs/scene";
  64346. module "babylonjs/scene" {
  64347. interface Scene {
  64348. /** @hidden (Backing field) */
  64349. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64350. /**
  64351. * Gets the postprocess render pipeline manager
  64352. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64353. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64354. */
  64355. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64356. }
  64357. }
  64358. /**
  64359. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64360. */
  64361. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64362. /**
  64363. * The component name helpfull to identify the component in the list of scene components.
  64364. */
  64365. readonly name: string;
  64366. /**
  64367. * The scene the component belongs to.
  64368. */
  64369. scene: Scene;
  64370. /**
  64371. * Creates a new instance of the component for the given scene
  64372. * @param scene Defines the scene to register the component in
  64373. */
  64374. constructor(scene: Scene);
  64375. /**
  64376. * Registers the component in a given scene
  64377. */
  64378. register(): void;
  64379. /**
  64380. * Rebuilds the elements related to this component in case of
  64381. * context lost for instance.
  64382. */
  64383. rebuild(): void;
  64384. /**
  64385. * Disposes the component and the associated ressources
  64386. */
  64387. dispose(): void;
  64388. private _gatherRenderTargets;
  64389. }
  64390. }
  64391. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64392. import { Nullable } from "babylonjs/types";
  64393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64394. import { Camera } from "babylonjs/Cameras/camera";
  64395. import { IDisposable } from "babylonjs/scene";
  64396. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64397. import { Scene } from "babylonjs/scene";
  64398. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64399. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64400. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64401. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64402. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64403. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64404. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64405. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64406. import { Animation } from "babylonjs/Animations/animation";
  64407. /**
  64408. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64409. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64410. */
  64411. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64412. private _scene;
  64413. private _camerasToBeAttached;
  64414. /**
  64415. * ID of the sharpen post process,
  64416. */
  64417. private readonly SharpenPostProcessId;
  64418. /**
  64419. * @ignore
  64420. * ID of the image processing post process;
  64421. */
  64422. readonly ImageProcessingPostProcessId: string;
  64423. /**
  64424. * @ignore
  64425. * ID of the Fast Approximate Anti-Aliasing post process;
  64426. */
  64427. readonly FxaaPostProcessId: string;
  64428. /**
  64429. * ID of the chromatic aberration post process,
  64430. */
  64431. private readonly ChromaticAberrationPostProcessId;
  64432. /**
  64433. * ID of the grain post process
  64434. */
  64435. private readonly GrainPostProcessId;
  64436. /**
  64437. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64438. */
  64439. sharpen: SharpenPostProcess;
  64440. private _sharpenEffect;
  64441. private bloom;
  64442. /**
  64443. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64444. */
  64445. depthOfField: DepthOfFieldEffect;
  64446. /**
  64447. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64448. */
  64449. fxaa: FxaaPostProcess;
  64450. /**
  64451. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64452. */
  64453. imageProcessing: ImageProcessingPostProcess;
  64454. /**
  64455. * Chromatic aberration post process which will shift rgb colors in the image
  64456. */
  64457. chromaticAberration: ChromaticAberrationPostProcess;
  64458. private _chromaticAberrationEffect;
  64459. /**
  64460. * Grain post process which add noise to the image
  64461. */
  64462. grain: GrainPostProcess;
  64463. private _grainEffect;
  64464. /**
  64465. * Glow post process which adds a glow to emissive areas of the image
  64466. */
  64467. private _glowLayer;
  64468. /**
  64469. * Animations which can be used to tweak settings over a period of time
  64470. */
  64471. animations: Animation[];
  64472. private _imageProcessingConfigurationObserver;
  64473. private _sharpenEnabled;
  64474. private _bloomEnabled;
  64475. private _depthOfFieldEnabled;
  64476. private _depthOfFieldBlurLevel;
  64477. private _fxaaEnabled;
  64478. private _imageProcessingEnabled;
  64479. private _defaultPipelineTextureType;
  64480. private _bloomScale;
  64481. private _chromaticAberrationEnabled;
  64482. private _grainEnabled;
  64483. private _buildAllowed;
  64484. /**
  64485. * Gets active scene
  64486. */
  64487. readonly scene: Scene;
  64488. /**
  64489. * Enable or disable the sharpen process from the pipeline
  64490. */
  64491. sharpenEnabled: boolean;
  64492. private _resizeObserver;
  64493. private _hardwareScaleLevel;
  64494. private _bloomKernel;
  64495. /**
  64496. * Specifies the size of the bloom blur kernel, relative to the final output size
  64497. */
  64498. bloomKernel: number;
  64499. /**
  64500. * Specifies the weight of the bloom in the final rendering
  64501. */
  64502. private _bloomWeight;
  64503. /**
  64504. * Specifies the luma threshold for the area that will be blurred by the bloom
  64505. */
  64506. private _bloomThreshold;
  64507. private _hdr;
  64508. /**
  64509. * The strength of the bloom.
  64510. */
  64511. bloomWeight: number;
  64512. /**
  64513. * The strength of the bloom.
  64514. */
  64515. bloomThreshold: number;
  64516. /**
  64517. * The scale of the bloom, lower value will provide better performance.
  64518. */
  64519. bloomScale: number;
  64520. /**
  64521. * Enable or disable the bloom from the pipeline
  64522. */
  64523. bloomEnabled: boolean;
  64524. private _rebuildBloom;
  64525. /**
  64526. * If the depth of field is enabled.
  64527. */
  64528. depthOfFieldEnabled: boolean;
  64529. /**
  64530. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64531. */
  64532. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64533. /**
  64534. * If the anti aliasing is enabled.
  64535. */
  64536. fxaaEnabled: boolean;
  64537. private _samples;
  64538. /**
  64539. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64540. */
  64541. samples: number;
  64542. /**
  64543. * If image processing is enabled.
  64544. */
  64545. imageProcessingEnabled: boolean;
  64546. /**
  64547. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64548. */
  64549. glowLayerEnabled: boolean;
  64550. /**
  64551. * Gets the glow layer (or null if not defined)
  64552. */
  64553. readonly glowLayer: Nullable<GlowLayer>;
  64554. /**
  64555. * Enable or disable the chromaticAberration process from the pipeline
  64556. */
  64557. chromaticAberrationEnabled: boolean;
  64558. /**
  64559. * Enable or disable the grain process from the pipeline
  64560. */
  64561. grainEnabled: boolean;
  64562. /**
  64563. * @constructor
  64564. * @param name - The rendering pipeline name (default: "")
  64565. * @param hdr - If high dynamic range textures should be used (default: true)
  64566. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64567. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64568. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64569. */
  64570. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64571. /**
  64572. * Get the class name
  64573. * @returns "DefaultRenderingPipeline"
  64574. */
  64575. getClassName(): string;
  64576. /**
  64577. * Force the compilation of the entire pipeline.
  64578. */
  64579. prepare(): void;
  64580. private _hasCleared;
  64581. private _prevPostProcess;
  64582. private _prevPrevPostProcess;
  64583. private _setAutoClearAndTextureSharing;
  64584. private _depthOfFieldSceneObserver;
  64585. private _buildPipeline;
  64586. private _disposePostProcesses;
  64587. /**
  64588. * Adds a camera to the pipeline
  64589. * @param camera the camera to be added
  64590. */
  64591. addCamera(camera: Camera): void;
  64592. /**
  64593. * Removes a camera from the pipeline
  64594. * @param camera the camera to remove
  64595. */
  64596. removeCamera(camera: Camera): void;
  64597. /**
  64598. * Dispose of the pipeline and stop all post processes
  64599. */
  64600. dispose(): void;
  64601. /**
  64602. * Serialize the rendering pipeline (Used when exporting)
  64603. * @returns the serialized object
  64604. */
  64605. serialize(): any;
  64606. /**
  64607. * Parse the serialized pipeline
  64608. * @param source Source pipeline.
  64609. * @param scene The scene to load the pipeline to.
  64610. * @param rootUrl The URL of the serialized pipeline.
  64611. * @returns An instantiated pipeline from the serialized object.
  64612. */
  64613. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64614. }
  64615. }
  64616. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64617. /** @hidden */
  64618. export var lensHighlightsPixelShader: {
  64619. name: string;
  64620. shader: string;
  64621. };
  64622. }
  64623. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64624. /** @hidden */
  64625. export var depthOfFieldPixelShader: {
  64626. name: string;
  64627. shader: string;
  64628. };
  64629. }
  64630. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64631. import { Camera } from "babylonjs/Cameras/camera";
  64632. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64633. import { Scene } from "babylonjs/scene";
  64634. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64635. import "babylonjs/Shaders/chromaticAberration.fragment";
  64636. import "babylonjs/Shaders/lensHighlights.fragment";
  64637. import "babylonjs/Shaders/depthOfField.fragment";
  64638. /**
  64639. * BABYLON.JS Chromatic Aberration GLSL Shader
  64640. * Author: Olivier Guyot
  64641. * Separates very slightly R, G and B colors on the edges of the screen
  64642. * Inspired by Francois Tarlier & Martins Upitis
  64643. */
  64644. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64645. /**
  64646. * @ignore
  64647. * The chromatic aberration PostProcess id in the pipeline
  64648. */
  64649. LensChromaticAberrationEffect: string;
  64650. /**
  64651. * @ignore
  64652. * The highlights enhancing PostProcess id in the pipeline
  64653. */
  64654. HighlightsEnhancingEffect: string;
  64655. /**
  64656. * @ignore
  64657. * The depth-of-field PostProcess id in the pipeline
  64658. */
  64659. LensDepthOfFieldEffect: string;
  64660. private _scene;
  64661. private _depthTexture;
  64662. private _grainTexture;
  64663. private _chromaticAberrationPostProcess;
  64664. private _highlightsPostProcess;
  64665. private _depthOfFieldPostProcess;
  64666. private _edgeBlur;
  64667. private _grainAmount;
  64668. private _chromaticAberration;
  64669. private _distortion;
  64670. private _highlightsGain;
  64671. private _highlightsThreshold;
  64672. private _dofDistance;
  64673. private _dofAperture;
  64674. private _dofDarken;
  64675. private _dofPentagon;
  64676. private _blurNoise;
  64677. /**
  64678. * @constructor
  64679. *
  64680. * Effect parameters are as follow:
  64681. * {
  64682. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64683. * edge_blur: number; // from 0 to x (1 for realism)
  64684. * distortion: number; // from 0 to x (1 for realism)
  64685. * grain_amount: number; // from 0 to 1
  64686. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64687. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64688. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64689. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64690. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64691. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64692. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64693. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64694. * }
  64695. * Note: if an effect parameter is unset, effect is disabled
  64696. *
  64697. * @param name The rendering pipeline name
  64698. * @param parameters - An object containing all parameters (see above)
  64699. * @param scene The scene linked to this pipeline
  64700. * @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)
  64701. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64702. */
  64703. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64704. /**
  64705. * Get the class name
  64706. * @returns "LensRenderingPipeline"
  64707. */
  64708. getClassName(): string;
  64709. /**
  64710. * Gets associated scene
  64711. */
  64712. readonly scene: Scene;
  64713. /**
  64714. * Gets or sets the edge blur
  64715. */
  64716. edgeBlur: number;
  64717. /**
  64718. * Gets or sets the grain amount
  64719. */
  64720. grainAmount: number;
  64721. /**
  64722. * Gets or sets the chromatic aberration amount
  64723. */
  64724. chromaticAberration: number;
  64725. /**
  64726. * Gets or sets the depth of field aperture
  64727. */
  64728. dofAperture: number;
  64729. /**
  64730. * Gets or sets the edge distortion
  64731. */
  64732. edgeDistortion: number;
  64733. /**
  64734. * Gets or sets the depth of field distortion
  64735. */
  64736. dofDistortion: number;
  64737. /**
  64738. * Gets or sets the darken out of focus amount
  64739. */
  64740. darkenOutOfFocus: number;
  64741. /**
  64742. * Gets or sets a boolean indicating if blur noise is enabled
  64743. */
  64744. blurNoise: boolean;
  64745. /**
  64746. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64747. */
  64748. pentagonBokeh: boolean;
  64749. /**
  64750. * Gets or sets the highlight grain amount
  64751. */
  64752. highlightsGain: number;
  64753. /**
  64754. * Gets or sets the highlight threshold
  64755. */
  64756. highlightsThreshold: number;
  64757. /**
  64758. * Sets the amount of blur at the edges
  64759. * @param amount blur amount
  64760. */
  64761. setEdgeBlur(amount: number): void;
  64762. /**
  64763. * Sets edge blur to 0
  64764. */
  64765. disableEdgeBlur(): void;
  64766. /**
  64767. * Sets the amout of grain
  64768. * @param amount Amount of grain
  64769. */
  64770. setGrainAmount(amount: number): void;
  64771. /**
  64772. * Set grain amount to 0
  64773. */
  64774. disableGrain(): void;
  64775. /**
  64776. * Sets the chromatic aberration amount
  64777. * @param amount amount of chromatic aberration
  64778. */
  64779. setChromaticAberration(amount: number): void;
  64780. /**
  64781. * Sets chromatic aberration amount to 0
  64782. */
  64783. disableChromaticAberration(): void;
  64784. /**
  64785. * Sets the EdgeDistortion amount
  64786. * @param amount amount of EdgeDistortion
  64787. */
  64788. setEdgeDistortion(amount: number): void;
  64789. /**
  64790. * Sets edge distortion to 0
  64791. */
  64792. disableEdgeDistortion(): void;
  64793. /**
  64794. * Sets the FocusDistance amount
  64795. * @param amount amount of FocusDistance
  64796. */
  64797. setFocusDistance(amount: number): void;
  64798. /**
  64799. * Disables depth of field
  64800. */
  64801. disableDepthOfField(): void;
  64802. /**
  64803. * Sets the Aperture amount
  64804. * @param amount amount of Aperture
  64805. */
  64806. setAperture(amount: number): void;
  64807. /**
  64808. * Sets the DarkenOutOfFocus amount
  64809. * @param amount amount of DarkenOutOfFocus
  64810. */
  64811. setDarkenOutOfFocus(amount: number): void;
  64812. private _pentagonBokehIsEnabled;
  64813. /**
  64814. * Creates a pentagon bokeh effect
  64815. */
  64816. enablePentagonBokeh(): void;
  64817. /**
  64818. * Disables the pentagon bokeh effect
  64819. */
  64820. disablePentagonBokeh(): void;
  64821. /**
  64822. * Enables noise blur
  64823. */
  64824. enableNoiseBlur(): void;
  64825. /**
  64826. * Disables noise blur
  64827. */
  64828. disableNoiseBlur(): void;
  64829. /**
  64830. * Sets the HighlightsGain amount
  64831. * @param amount amount of HighlightsGain
  64832. */
  64833. setHighlightsGain(amount: number): void;
  64834. /**
  64835. * Sets the HighlightsThreshold amount
  64836. * @param amount amount of HighlightsThreshold
  64837. */
  64838. setHighlightsThreshold(amount: number): void;
  64839. /**
  64840. * Disables highlights
  64841. */
  64842. disableHighlights(): void;
  64843. /**
  64844. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64845. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64846. */
  64847. dispose(disableDepthRender?: boolean): void;
  64848. private _createChromaticAberrationPostProcess;
  64849. private _createHighlightsPostProcess;
  64850. private _createDepthOfFieldPostProcess;
  64851. private _createGrainTexture;
  64852. }
  64853. }
  64854. declare module "babylonjs/Shaders/ssao2.fragment" {
  64855. /** @hidden */
  64856. export var ssao2PixelShader: {
  64857. name: string;
  64858. shader: string;
  64859. };
  64860. }
  64861. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64862. /** @hidden */
  64863. export var ssaoCombinePixelShader: {
  64864. name: string;
  64865. shader: string;
  64866. };
  64867. }
  64868. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64869. import { Camera } from "babylonjs/Cameras/camera";
  64870. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64871. import { Scene } from "babylonjs/scene";
  64872. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64873. import "babylonjs/Shaders/ssao2.fragment";
  64874. import "babylonjs/Shaders/ssaoCombine.fragment";
  64875. /**
  64876. * Render pipeline to produce ssao effect
  64877. */
  64878. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64879. /**
  64880. * @ignore
  64881. * The PassPostProcess id in the pipeline that contains the original scene color
  64882. */
  64883. SSAOOriginalSceneColorEffect: string;
  64884. /**
  64885. * @ignore
  64886. * The SSAO PostProcess id in the pipeline
  64887. */
  64888. SSAORenderEffect: string;
  64889. /**
  64890. * @ignore
  64891. * The horizontal blur PostProcess id in the pipeline
  64892. */
  64893. SSAOBlurHRenderEffect: string;
  64894. /**
  64895. * @ignore
  64896. * The vertical blur PostProcess id in the pipeline
  64897. */
  64898. SSAOBlurVRenderEffect: string;
  64899. /**
  64900. * @ignore
  64901. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64902. */
  64903. SSAOCombineRenderEffect: string;
  64904. /**
  64905. * The output strength of the SSAO post-process. Default value is 1.0.
  64906. */
  64907. totalStrength: number;
  64908. /**
  64909. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64910. */
  64911. maxZ: number;
  64912. /**
  64913. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64914. */
  64915. minZAspect: number;
  64916. private _samples;
  64917. /**
  64918. * Number of samples used for the SSAO calculations. Default value is 8
  64919. */
  64920. samples: number;
  64921. private _textureSamples;
  64922. /**
  64923. * Number of samples to use for antialiasing
  64924. */
  64925. textureSamples: number;
  64926. /**
  64927. * Ratio object used for SSAO ratio and blur ratio
  64928. */
  64929. private _ratio;
  64930. /**
  64931. * Dynamically generated sphere sampler.
  64932. */
  64933. private _sampleSphere;
  64934. /**
  64935. * Blur filter offsets
  64936. */
  64937. private _samplerOffsets;
  64938. private _expensiveBlur;
  64939. /**
  64940. * If bilateral blur should be used
  64941. */
  64942. expensiveBlur: boolean;
  64943. /**
  64944. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64945. */
  64946. radius: number;
  64947. /**
  64948. * The base color of the SSAO post-process
  64949. * The final result is "base + ssao" between [0, 1]
  64950. */
  64951. base: number;
  64952. /**
  64953. * Support test.
  64954. */
  64955. static readonly IsSupported: boolean;
  64956. private _scene;
  64957. private _depthTexture;
  64958. private _normalTexture;
  64959. private _randomTexture;
  64960. private _originalColorPostProcess;
  64961. private _ssaoPostProcess;
  64962. private _blurHPostProcess;
  64963. private _blurVPostProcess;
  64964. private _ssaoCombinePostProcess;
  64965. private _firstUpdate;
  64966. /**
  64967. * Gets active scene
  64968. */
  64969. readonly scene: Scene;
  64970. /**
  64971. * @constructor
  64972. * @param name The rendering pipeline name
  64973. * @param scene The scene linked to this pipeline
  64974. * @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 }
  64975. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64976. */
  64977. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64978. /**
  64979. * Get the class name
  64980. * @returns "SSAO2RenderingPipeline"
  64981. */
  64982. getClassName(): string;
  64983. /**
  64984. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64985. */
  64986. dispose(disableGeometryBufferRenderer?: boolean): void;
  64987. private _createBlurPostProcess;
  64988. /** @hidden */
  64989. _rebuild(): void;
  64990. private _bits;
  64991. private _radicalInverse_VdC;
  64992. private _hammersley;
  64993. private _hemisphereSample_uniform;
  64994. private _generateHemisphere;
  64995. private _createSSAOPostProcess;
  64996. private _createSSAOCombinePostProcess;
  64997. private _createRandomTexture;
  64998. /**
  64999. * Serialize the rendering pipeline (Used when exporting)
  65000. * @returns the serialized object
  65001. */
  65002. serialize(): any;
  65003. /**
  65004. * Parse the serialized pipeline
  65005. * @param source Source pipeline.
  65006. * @param scene The scene to load the pipeline to.
  65007. * @param rootUrl The URL of the serialized pipeline.
  65008. * @returns An instantiated pipeline from the serialized object.
  65009. */
  65010. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65011. }
  65012. }
  65013. declare module "babylonjs/Shaders/ssao.fragment" {
  65014. /** @hidden */
  65015. export var ssaoPixelShader: {
  65016. name: string;
  65017. shader: string;
  65018. };
  65019. }
  65020. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65021. import { Camera } from "babylonjs/Cameras/camera";
  65022. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65023. import { Scene } from "babylonjs/scene";
  65024. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65025. import "babylonjs/Shaders/ssao.fragment";
  65026. import "babylonjs/Shaders/ssaoCombine.fragment";
  65027. /**
  65028. * Render pipeline to produce ssao effect
  65029. */
  65030. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65031. /**
  65032. * @ignore
  65033. * The PassPostProcess id in the pipeline that contains the original scene color
  65034. */
  65035. SSAOOriginalSceneColorEffect: string;
  65036. /**
  65037. * @ignore
  65038. * The SSAO PostProcess id in the pipeline
  65039. */
  65040. SSAORenderEffect: string;
  65041. /**
  65042. * @ignore
  65043. * The horizontal blur PostProcess id in the pipeline
  65044. */
  65045. SSAOBlurHRenderEffect: string;
  65046. /**
  65047. * @ignore
  65048. * The vertical blur PostProcess id in the pipeline
  65049. */
  65050. SSAOBlurVRenderEffect: string;
  65051. /**
  65052. * @ignore
  65053. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65054. */
  65055. SSAOCombineRenderEffect: string;
  65056. /**
  65057. * The output strength of the SSAO post-process. Default value is 1.0.
  65058. */
  65059. totalStrength: number;
  65060. /**
  65061. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65062. */
  65063. radius: number;
  65064. /**
  65065. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65066. * Must not be equal to fallOff and superior to fallOff.
  65067. * Default value is 0.0075
  65068. */
  65069. area: number;
  65070. /**
  65071. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65072. * Must not be equal to area and inferior to area.
  65073. * Default value is 0.000001
  65074. */
  65075. fallOff: number;
  65076. /**
  65077. * The base color of the SSAO post-process
  65078. * The final result is "base + ssao" between [0, 1]
  65079. */
  65080. base: number;
  65081. private _scene;
  65082. private _depthTexture;
  65083. private _randomTexture;
  65084. private _originalColorPostProcess;
  65085. private _ssaoPostProcess;
  65086. private _blurHPostProcess;
  65087. private _blurVPostProcess;
  65088. private _ssaoCombinePostProcess;
  65089. private _firstUpdate;
  65090. /**
  65091. * Gets active scene
  65092. */
  65093. readonly scene: Scene;
  65094. /**
  65095. * @constructor
  65096. * @param name - The rendering pipeline name
  65097. * @param scene - The scene linked to this pipeline
  65098. * @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 }
  65099. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65100. */
  65101. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65102. /**
  65103. * Get the class name
  65104. * @returns "SSAORenderingPipeline"
  65105. */
  65106. getClassName(): string;
  65107. /**
  65108. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65109. */
  65110. dispose(disableDepthRender?: boolean): void;
  65111. private _createBlurPostProcess;
  65112. /** @hidden */
  65113. _rebuild(): void;
  65114. private _createSSAOPostProcess;
  65115. private _createSSAOCombinePostProcess;
  65116. private _createRandomTexture;
  65117. }
  65118. }
  65119. declare module "babylonjs/Shaders/standard.fragment" {
  65120. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65121. /** @hidden */
  65122. export var standardPixelShader: {
  65123. name: string;
  65124. shader: string;
  65125. };
  65126. }
  65127. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65128. import { Nullable } from "babylonjs/types";
  65129. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65130. import { Camera } from "babylonjs/Cameras/camera";
  65131. import { Texture } from "babylonjs/Materials/Textures/texture";
  65132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65133. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65134. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65135. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65136. import { IDisposable } from "babylonjs/scene";
  65137. import { SpotLight } from "babylonjs/Lights/spotLight";
  65138. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65139. import { Scene } from "babylonjs/scene";
  65140. import { Animation } from "babylonjs/Animations/animation";
  65141. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65142. import "babylonjs/Shaders/standard.fragment";
  65143. /**
  65144. * Standard rendering pipeline
  65145. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65146. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65147. */
  65148. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65149. /**
  65150. * Public members
  65151. */
  65152. /**
  65153. * Post-process which contains the original scene color before the pipeline applies all the effects
  65154. */
  65155. originalPostProcess: Nullable<PostProcess>;
  65156. /**
  65157. * Post-process used to down scale an image x4
  65158. */
  65159. downSampleX4PostProcess: Nullable<PostProcess>;
  65160. /**
  65161. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65162. */
  65163. brightPassPostProcess: Nullable<PostProcess>;
  65164. /**
  65165. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65166. */
  65167. blurHPostProcesses: PostProcess[];
  65168. /**
  65169. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65170. */
  65171. blurVPostProcesses: PostProcess[];
  65172. /**
  65173. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65174. */
  65175. textureAdderPostProcess: Nullable<PostProcess>;
  65176. /**
  65177. * Post-process used to create volumetric lighting effect
  65178. */
  65179. volumetricLightPostProcess: Nullable<PostProcess>;
  65180. /**
  65181. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65182. */
  65183. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65184. /**
  65185. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65186. */
  65187. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65188. /**
  65189. * Post-process used to merge the volumetric light effect and the real scene color
  65190. */
  65191. volumetricLightMergePostProces: Nullable<PostProcess>;
  65192. /**
  65193. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65194. */
  65195. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65196. /**
  65197. * Base post-process used to calculate the average luminance of the final image for HDR
  65198. */
  65199. luminancePostProcess: Nullable<PostProcess>;
  65200. /**
  65201. * Post-processes used to create down sample post-processes in order to get
  65202. * the average luminance of the final image for HDR
  65203. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65204. */
  65205. luminanceDownSamplePostProcesses: PostProcess[];
  65206. /**
  65207. * Post-process used to create a HDR effect (light adaptation)
  65208. */
  65209. hdrPostProcess: Nullable<PostProcess>;
  65210. /**
  65211. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65212. */
  65213. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65214. /**
  65215. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65216. */
  65217. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65218. /**
  65219. * Post-process used to merge the final HDR post-process and the real scene color
  65220. */
  65221. hdrFinalPostProcess: Nullable<PostProcess>;
  65222. /**
  65223. * Post-process used to create a lens flare effect
  65224. */
  65225. lensFlarePostProcess: Nullable<PostProcess>;
  65226. /**
  65227. * Post-process that merges the result of the lens flare post-process and the real scene color
  65228. */
  65229. lensFlareComposePostProcess: Nullable<PostProcess>;
  65230. /**
  65231. * Post-process used to create a motion blur effect
  65232. */
  65233. motionBlurPostProcess: Nullable<PostProcess>;
  65234. /**
  65235. * Post-process used to create a depth of field effect
  65236. */
  65237. depthOfFieldPostProcess: Nullable<PostProcess>;
  65238. /**
  65239. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65240. */
  65241. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65242. /**
  65243. * Represents the brightness threshold in order to configure the illuminated surfaces
  65244. */
  65245. brightThreshold: number;
  65246. /**
  65247. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65248. */
  65249. blurWidth: number;
  65250. /**
  65251. * Sets if the blur for highlighted surfaces must be only horizontal
  65252. */
  65253. horizontalBlur: boolean;
  65254. /**
  65255. * Gets the overall exposure used by the pipeline
  65256. */
  65257. /**
  65258. * Sets the overall exposure used by the pipeline
  65259. */
  65260. exposure: number;
  65261. /**
  65262. * Texture used typically to simulate "dirty" on camera lens
  65263. */
  65264. lensTexture: Nullable<Texture>;
  65265. /**
  65266. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65267. */
  65268. volumetricLightCoefficient: number;
  65269. /**
  65270. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65271. */
  65272. volumetricLightPower: number;
  65273. /**
  65274. * Used the set the blur intensity to smooth the volumetric lights
  65275. */
  65276. volumetricLightBlurScale: number;
  65277. /**
  65278. * Light (spot or directional) used to generate the volumetric lights rays
  65279. * The source light must have a shadow generate so the pipeline can get its
  65280. * depth map
  65281. */
  65282. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65283. /**
  65284. * For eye adaptation, represents the minimum luminance the eye can see
  65285. */
  65286. hdrMinimumLuminance: number;
  65287. /**
  65288. * For eye adaptation, represents the decrease luminance speed
  65289. */
  65290. hdrDecreaseRate: number;
  65291. /**
  65292. * For eye adaptation, represents the increase luminance speed
  65293. */
  65294. hdrIncreaseRate: number;
  65295. /**
  65296. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65297. */
  65298. /**
  65299. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65300. */
  65301. hdrAutoExposure: boolean;
  65302. /**
  65303. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65304. */
  65305. lensColorTexture: Nullable<Texture>;
  65306. /**
  65307. * The overall strengh for the lens flare effect
  65308. */
  65309. lensFlareStrength: number;
  65310. /**
  65311. * Dispersion coefficient for lens flare ghosts
  65312. */
  65313. lensFlareGhostDispersal: number;
  65314. /**
  65315. * Main lens flare halo width
  65316. */
  65317. lensFlareHaloWidth: number;
  65318. /**
  65319. * Based on the lens distortion effect, defines how much the lens flare result
  65320. * is distorted
  65321. */
  65322. lensFlareDistortionStrength: number;
  65323. /**
  65324. * Configures the blur intensity used for for lens flare (halo)
  65325. */
  65326. lensFlareBlurWidth: number;
  65327. /**
  65328. * Lens star texture must be used to simulate rays on the flares and is available
  65329. * in the documentation
  65330. */
  65331. lensStarTexture: Nullable<Texture>;
  65332. /**
  65333. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65334. * flare effect by taking account of the dirt texture
  65335. */
  65336. lensFlareDirtTexture: Nullable<Texture>;
  65337. /**
  65338. * Represents the focal length for the depth of field effect
  65339. */
  65340. depthOfFieldDistance: number;
  65341. /**
  65342. * Represents the blur intensity for the blurred part of the depth of field effect
  65343. */
  65344. depthOfFieldBlurWidth: number;
  65345. /**
  65346. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65347. */
  65348. /**
  65349. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65350. */
  65351. motionStrength: number;
  65352. /**
  65353. * Gets wether or not the motion blur post-process is object based or screen based.
  65354. */
  65355. /**
  65356. * Sets wether or not the motion blur post-process should be object based or screen based
  65357. */
  65358. objectBasedMotionBlur: boolean;
  65359. /**
  65360. * List of animations for the pipeline (IAnimatable implementation)
  65361. */
  65362. animations: Animation[];
  65363. /**
  65364. * Private members
  65365. */
  65366. private _scene;
  65367. private _currentDepthOfFieldSource;
  65368. private _basePostProcess;
  65369. private _fixedExposure;
  65370. private _currentExposure;
  65371. private _hdrAutoExposure;
  65372. private _hdrCurrentLuminance;
  65373. private _motionStrength;
  65374. private _isObjectBasedMotionBlur;
  65375. private _floatTextureType;
  65376. private _camerasToBeAttached;
  65377. private _ratio;
  65378. private _bloomEnabled;
  65379. private _depthOfFieldEnabled;
  65380. private _vlsEnabled;
  65381. private _lensFlareEnabled;
  65382. private _hdrEnabled;
  65383. private _motionBlurEnabled;
  65384. private _fxaaEnabled;
  65385. private _motionBlurSamples;
  65386. private _volumetricLightStepsCount;
  65387. private _samples;
  65388. /**
  65389. * @ignore
  65390. * Specifies if the bloom pipeline is enabled
  65391. */
  65392. BloomEnabled: boolean;
  65393. /**
  65394. * @ignore
  65395. * Specifies if the depth of field pipeline is enabed
  65396. */
  65397. DepthOfFieldEnabled: boolean;
  65398. /**
  65399. * @ignore
  65400. * Specifies if the lens flare pipeline is enabed
  65401. */
  65402. LensFlareEnabled: boolean;
  65403. /**
  65404. * @ignore
  65405. * Specifies if the HDR pipeline is enabled
  65406. */
  65407. HDREnabled: boolean;
  65408. /**
  65409. * @ignore
  65410. * Specifies if the volumetric lights scattering effect is enabled
  65411. */
  65412. VLSEnabled: boolean;
  65413. /**
  65414. * @ignore
  65415. * Specifies if the motion blur effect is enabled
  65416. */
  65417. MotionBlurEnabled: boolean;
  65418. /**
  65419. * Specifies if anti-aliasing is enabled
  65420. */
  65421. fxaaEnabled: boolean;
  65422. /**
  65423. * Specifies the number of steps used to calculate the volumetric lights
  65424. * Typically in interval [50, 200]
  65425. */
  65426. volumetricLightStepsCount: number;
  65427. /**
  65428. * Specifies the number of samples used for the motion blur effect
  65429. * Typically in interval [16, 64]
  65430. */
  65431. motionBlurSamples: number;
  65432. /**
  65433. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65434. */
  65435. samples: number;
  65436. /**
  65437. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65438. * @constructor
  65439. * @param name The rendering pipeline name
  65440. * @param scene The scene linked to this pipeline
  65441. * @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)
  65442. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65443. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65444. */
  65445. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65446. private _buildPipeline;
  65447. private _createDownSampleX4PostProcess;
  65448. private _createBrightPassPostProcess;
  65449. private _createBlurPostProcesses;
  65450. private _createTextureAdderPostProcess;
  65451. private _createVolumetricLightPostProcess;
  65452. private _createLuminancePostProcesses;
  65453. private _createHdrPostProcess;
  65454. private _createLensFlarePostProcess;
  65455. private _createDepthOfFieldPostProcess;
  65456. private _createMotionBlurPostProcess;
  65457. private _getDepthTexture;
  65458. private _disposePostProcesses;
  65459. /**
  65460. * Dispose of the pipeline and stop all post processes
  65461. */
  65462. dispose(): void;
  65463. /**
  65464. * Serialize the rendering pipeline (Used when exporting)
  65465. * @returns the serialized object
  65466. */
  65467. serialize(): any;
  65468. /**
  65469. * Parse the serialized pipeline
  65470. * @param source Source pipeline.
  65471. * @param scene The scene to load the pipeline to.
  65472. * @param rootUrl The URL of the serialized pipeline.
  65473. * @returns An instantiated pipeline from the serialized object.
  65474. */
  65475. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65476. /**
  65477. * Luminance steps
  65478. */
  65479. static LuminanceSteps: number;
  65480. }
  65481. }
  65482. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65483. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65484. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65485. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65486. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65487. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65488. }
  65489. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65490. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65491. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65492. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65493. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65494. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65495. }
  65496. declare module "babylonjs/Shaders/tonemap.fragment" {
  65497. /** @hidden */
  65498. export var tonemapPixelShader: {
  65499. name: string;
  65500. shader: string;
  65501. };
  65502. }
  65503. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65504. import { Camera } from "babylonjs/Cameras/camera";
  65505. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65506. import "babylonjs/Shaders/tonemap.fragment";
  65507. import { Engine } from "babylonjs/Engines/engine";
  65508. /** Defines operator used for tonemapping */
  65509. export enum TonemappingOperator {
  65510. /** Hable */
  65511. Hable = 0,
  65512. /** Reinhard */
  65513. Reinhard = 1,
  65514. /** HejiDawson */
  65515. HejiDawson = 2,
  65516. /** Photographic */
  65517. Photographic = 3
  65518. }
  65519. /**
  65520. * Defines a post process to apply tone mapping
  65521. */
  65522. export class TonemapPostProcess extends PostProcess {
  65523. private _operator;
  65524. /** Defines the required exposure adjustement */
  65525. exposureAdjustment: number;
  65526. /**
  65527. * Creates a new TonemapPostProcess
  65528. * @param name defines the name of the postprocess
  65529. * @param _operator defines the operator to use
  65530. * @param exposureAdjustment defines the required exposure adjustement
  65531. * @param camera defines the camera to use (can be null)
  65532. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65533. * @param engine defines the hosting engine (can be ignore if camera is set)
  65534. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65535. */
  65536. constructor(name: string, _operator: TonemappingOperator,
  65537. /** Defines the required exposure adjustement */
  65538. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65539. }
  65540. }
  65541. declare module "babylonjs/Shaders/depth.vertex" {
  65542. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65545. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65549. /** @hidden */
  65550. export var depthVertexShader: {
  65551. name: string;
  65552. shader: string;
  65553. };
  65554. }
  65555. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65556. /** @hidden */
  65557. export var volumetricLightScatteringPixelShader: {
  65558. name: string;
  65559. shader: string;
  65560. };
  65561. }
  65562. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65563. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65564. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65566. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65567. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65568. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65569. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65570. /** @hidden */
  65571. export var volumetricLightScatteringPassVertexShader: {
  65572. name: string;
  65573. shader: string;
  65574. };
  65575. }
  65576. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65577. /** @hidden */
  65578. export var volumetricLightScatteringPassPixelShader: {
  65579. name: string;
  65580. shader: string;
  65581. };
  65582. }
  65583. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65584. import { Vector3 } from "babylonjs/Maths/math.vector";
  65585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65586. import { Mesh } from "babylonjs/Meshes/mesh";
  65587. import { Camera } from "babylonjs/Cameras/camera";
  65588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65589. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65590. import { Scene } from "babylonjs/scene";
  65591. import "babylonjs/Meshes/Builders/planeBuilder";
  65592. import "babylonjs/Shaders/depth.vertex";
  65593. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65594. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65595. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65596. import { Engine } from "babylonjs/Engines/engine";
  65597. /**
  65598. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65599. */
  65600. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65601. private _volumetricLightScatteringPass;
  65602. private _volumetricLightScatteringRTT;
  65603. private _viewPort;
  65604. private _screenCoordinates;
  65605. private _cachedDefines;
  65606. /**
  65607. * If not undefined, the mesh position is computed from the attached node position
  65608. */
  65609. attachedNode: {
  65610. position: Vector3;
  65611. };
  65612. /**
  65613. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65614. */
  65615. customMeshPosition: Vector3;
  65616. /**
  65617. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65618. */
  65619. useCustomMeshPosition: boolean;
  65620. /**
  65621. * If the post-process should inverse the light scattering direction
  65622. */
  65623. invert: boolean;
  65624. /**
  65625. * The internal mesh used by the post-process
  65626. */
  65627. mesh: Mesh;
  65628. /**
  65629. * @hidden
  65630. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65631. */
  65632. useDiffuseColor: boolean;
  65633. /**
  65634. * Array containing the excluded meshes not rendered in the internal pass
  65635. */
  65636. excludedMeshes: AbstractMesh[];
  65637. /**
  65638. * Controls the overall intensity of the post-process
  65639. */
  65640. exposure: number;
  65641. /**
  65642. * Dissipates each sample's contribution in range [0, 1]
  65643. */
  65644. decay: number;
  65645. /**
  65646. * Controls the overall intensity of each sample
  65647. */
  65648. weight: number;
  65649. /**
  65650. * Controls the density of each sample
  65651. */
  65652. density: number;
  65653. /**
  65654. * @constructor
  65655. * @param name The post-process name
  65656. * @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)
  65657. * @param camera The camera that the post-process will be attached to
  65658. * @param mesh The mesh used to create the light scattering
  65659. * @param samples The post-process quality, default 100
  65660. * @param samplingModeThe post-process filtering mode
  65661. * @param engine The babylon engine
  65662. * @param reusable If the post-process is reusable
  65663. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65664. */
  65665. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65666. /**
  65667. * Returns the string "VolumetricLightScatteringPostProcess"
  65668. * @returns "VolumetricLightScatteringPostProcess"
  65669. */
  65670. getClassName(): string;
  65671. private _isReady;
  65672. /**
  65673. * Sets the new light position for light scattering effect
  65674. * @param position The new custom light position
  65675. */
  65676. setCustomMeshPosition(position: Vector3): void;
  65677. /**
  65678. * Returns the light position for light scattering effect
  65679. * @return Vector3 The custom light position
  65680. */
  65681. getCustomMeshPosition(): Vector3;
  65682. /**
  65683. * Disposes the internal assets and detaches the post-process from the camera
  65684. */
  65685. dispose(camera: Camera): void;
  65686. /**
  65687. * Returns the render target texture used by the post-process
  65688. * @return the render target texture used by the post-process
  65689. */
  65690. getPass(): RenderTargetTexture;
  65691. private _meshExcluded;
  65692. private _createPass;
  65693. private _updateMeshScreenCoordinates;
  65694. /**
  65695. * Creates a default mesh for the Volumeric Light Scattering post-process
  65696. * @param name The mesh name
  65697. * @param scene The scene where to create the mesh
  65698. * @return the default mesh
  65699. */
  65700. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65701. }
  65702. }
  65703. declare module "babylonjs/PostProcesses/index" {
  65704. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65705. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65706. export * from "babylonjs/PostProcesses/bloomEffect";
  65707. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65708. export * from "babylonjs/PostProcesses/blurPostProcess";
  65709. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65710. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65711. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65712. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65713. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65714. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65715. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65716. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65717. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65718. export * from "babylonjs/PostProcesses/filterPostProcess";
  65719. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65720. export * from "babylonjs/PostProcesses/grainPostProcess";
  65721. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65722. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65723. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65724. export * from "babylonjs/PostProcesses/passPostProcess";
  65725. export * from "babylonjs/PostProcesses/postProcess";
  65726. export * from "babylonjs/PostProcesses/postProcessManager";
  65727. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65728. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65729. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65730. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65731. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65732. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65733. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65734. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65735. }
  65736. declare module "babylonjs/Probes/index" {
  65737. export * from "babylonjs/Probes/reflectionProbe";
  65738. }
  65739. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65740. import { Scene } from "babylonjs/scene";
  65741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65742. import { SmartArray } from "babylonjs/Misc/smartArray";
  65743. import { ISceneComponent } from "babylonjs/sceneComponent";
  65744. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65745. import "babylonjs/Meshes/Builders/boxBuilder";
  65746. import "babylonjs/Shaders/color.fragment";
  65747. import "babylonjs/Shaders/color.vertex";
  65748. import { Color3 } from "babylonjs/Maths/math.color";
  65749. module "babylonjs/scene" {
  65750. interface Scene {
  65751. /** @hidden (Backing field) */
  65752. _boundingBoxRenderer: BoundingBoxRenderer;
  65753. /** @hidden (Backing field) */
  65754. _forceShowBoundingBoxes: boolean;
  65755. /**
  65756. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65757. */
  65758. forceShowBoundingBoxes: boolean;
  65759. /**
  65760. * Gets the bounding box renderer associated with the scene
  65761. * @returns a BoundingBoxRenderer
  65762. */
  65763. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65764. }
  65765. }
  65766. module "babylonjs/Meshes/abstractMesh" {
  65767. interface AbstractMesh {
  65768. /** @hidden (Backing field) */
  65769. _showBoundingBox: boolean;
  65770. /**
  65771. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65772. */
  65773. showBoundingBox: boolean;
  65774. }
  65775. }
  65776. /**
  65777. * Component responsible of rendering the bounding box of the meshes in a scene.
  65778. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65779. */
  65780. export class BoundingBoxRenderer implements ISceneComponent {
  65781. /**
  65782. * The component name helpfull to identify the component in the list of scene components.
  65783. */
  65784. readonly name: string;
  65785. /**
  65786. * The scene the component belongs to.
  65787. */
  65788. scene: Scene;
  65789. /**
  65790. * Color of the bounding box lines placed in front of an object
  65791. */
  65792. frontColor: Color3;
  65793. /**
  65794. * Color of the bounding box lines placed behind an object
  65795. */
  65796. backColor: Color3;
  65797. /**
  65798. * Defines if the renderer should show the back lines or not
  65799. */
  65800. showBackLines: boolean;
  65801. /**
  65802. * @hidden
  65803. */
  65804. renderList: SmartArray<BoundingBox>;
  65805. private _colorShader;
  65806. private _vertexBuffers;
  65807. private _indexBuffer;
  65808. private _fillIndexBuffer;
  65809. private _fillIndexData;
  65810. /**
  65811. * Instantiates a new bounding box renderer in a scene.
  65812. * @param scene the scene the renderer renders in
  65813. */
  65814. constructor(scene: Scene);
  65815. /**
  65816. * Registers the component in a given scene
  65817. */
  65818. register(): void;
  65819. private _evaluateSubMesh;
  65820. private _activeMesh;
  65821. private _prepareRessources;
  65822. private _createIndexBuffer;
  65823. /**
  65824. * Rebuilds the elements related to this component in case of
  65825. * context lost for instance.
  65826. */
  65827. rebuild(): void;
  65828. /**
  65829. * @hidden
  65830. */
  65831. reset(): void;
  65832. /**
  65833. * Render the bounding boxes of a specific rendering group
  65834. * @param renderingGroupId defines the rendering group to render
  65835. */
  65836. render(renderingGroupId: number): void;
  65837. /**
  65838. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65839. * @param mesh Define the mesh to render the occlusion bounding box for
  65840. */
  65841. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65842. /**
  65843. * Dispose and release the resources attached to this renderer.
  65844. */
  65845. dispose(): void;
  65846. }
  65847. }
  65848. declare module "babylonjs/Shaders/depth.fragment" {
  65849. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65850. /** @hidden */
  65851. export var depthPixelShader: {
  65852. name: string;
  65853. shader: string;
  65854. };
  65855. }
  65856. declare module "babylonjs/Rendering/depthRenderer" {
  65857. import { Nullable } from "babylonjs/types";
  65858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65859. import { Scene } from "babylonjs/scene";
  65860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65861. import { Camera } from "babylonjs/Cameras/camera";
  65862. import "babylonjs/Shaders/depth.fragment";
  65863. import "babylonjs/Shaders/depth.vertex";
  65864. /**
  65865. * This represents a depth renderer in Babylon.
  65866. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65867. */
  65868. export class DepthRenderer {
  65869. private _scene;
  65870. private _depthMap;
  65871. private _effect;
  65872. private readonly _storeNonLinearDepth;
  65873. private readonly _clearColor;
  65874. /** Get if the depth renderer is using packed depth or not */
  65875. readonly isPacked: boolean;
  65876. private _cachedDefines;
  65877. private _camera;
  65878. /**
  65879. * Specifiess that the depth renderer will only be used within
  65880. * the camera it is created for.
  65881. * This can help forcing its rendering during the camera processing.
  65882. */
  65883. useOnlyInActiveCamera: boolean;
  65884. /** @hidden */
  65885. static _SceneComponentInitialization: (scene: Scene) => void;
  65886. /**
  65887. * Instantiates a depth renderer
  65888. * @param scene The scene the renderer belongs to
  65889. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65890. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65891. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65892. */
  65893. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65894. /**
  65895. * Creates the depth rendering effect and checks if the effect is ready.
  65896. * @param subMesh The submesh to be used to render the depth map of
  65897. * @param useInstances If multiple world instances should be used
  65898. * @returns if the depth renderer is ready to render the depth map
  65899. */
  65900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65901. /**
  65902. * Gets the texture which the depth map will be written to.
  65903. * @returns The depth map texture
  65904. */
  65905. getDepthMap(): RenderTargetTexture;
  65906. /**
  65907. * Disposes of the depth renderer.
  65908. */
  65909. dispose(): void;
  65910. }
  65911. }
  65912. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65913. import { Nullable } from "babylonjs/types";
  65914. import { Scene } from "babylonjs/scene";
  65915. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65916. import { Camera } from "babylonjs/Cameras/camera";
  65917. import { ISceneComponent } from "babylonjs/sceneComponent";
  65918. module "babylonjs/scene" {
  65919. interface Scene {
  65920. /** @hidden (Backing field) */
  65921. _depthRenderer: {
  65922. [id: string]: DepthRenderer;
  65923. };
  65924. /**
  65925. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65926. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65927. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65928. * @returns the created depth renderer
  65929. */
  65930. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65931. /**
  65932. * Disables a depth renderer for a given camera
  65933. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65934. */
  65935. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65936. }
  65937. }
  65938. /**
  65939. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65940. * in several rendering techniques.
  65941. */
  65942. export class DepthRendererSceneComponent implements ISceneComponent {
  65943. /**
  65944. * The component name helpfull to identify the component in the list of scene components.
  65945. */
  65946. readonly name: string;
  65947. /**
  65948. * The scene the component belongs to.
  65949. */
  65950. scene: Scene;
  65951. /**
  65952. * Creates a new instance of the component for the given scene
  65953. * @param scene Defines the scene to register the component in
  65954. */
  65955. constructor(scene: Scene);
  65956. /**
  65957. * Registers the component in a given scene
  65958. */
  65959. register(): void;
  65960. /**
  65961. * Rebuilds the elements related to this component in case of
  65962. * context lost for instance.
  65963. */
  65964. rebuild(): void;
  65965. /**
  65966. * Disposes the component and the associated ressources
  65967. */
  65968. dispose(): void;
  65969. private _gatherRenderTargets;
  65970. private _gatherActiveCameraRenderTargets;
  65971. }
  65972. }
  65973. declare module "babylonjs/Shaders/outline.fragment" {
  65974. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65975. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65976. /** @hidden */
  65977. export var outlinePixelShader: {
  65978. name: string;
  65979. shader: string;
  65980. };
  65981. }
  65982. declare module "babylonjs/Shaders/outline.vertex" {
  65983. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65984. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65986. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65987. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65989. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65990. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65991. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65992. /** @hidden */
  65993. export var outlineVertexShader: {
  65994. name: string;
  65995. shader: string;
  65996. };
  65997. }
  65998. declare module "babylonjs/Rendering/outlineRenderer" {
  65999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66000. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66001. import { Scene } from "babylonjs/scene";
  66002. import { ISceneComponent } from "babylonjs/sceneComponent";
  66003. import "babylonjs/Shaders/outline.fragment";
  66004. import "babylonjs/Shaders/outline.vertex";
  66005. module "babylonjs/scene" {
  66006. interface Scene {
  66007. /** @hidden */
  66008. _outlineRenderer: OutlineRenderer;
  66009. /**
  66010. * Gets the outline renderer associated with the scene
  66011. * @returns a OutlineRenderer
  66012. */
  66013. getOutlineRenderer(): OutlineRenderer;
  66014. }
  66015. }
  66016. module "babylonjs/Meshes/abstractMesh" {
  66017. interface AbstractMesh {
  66018. /** @hidden (Backing field) */
  66019. _renderOutline: boolean;
  66020. /**
  66021. * Gets or sets a boolean indicating if the outline must be rendered as well
  66022. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66023. */
  66024. renderOutline: boolean;
  66025. /** @hidden (Backing field) */
  66026. _renderOverlay: boolean;
  66027. /**
  66028. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66029. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66030. */
  66031. renderOverlay: boolean;
  66032. }
  66033. }
  66034. /**
  66035. * This class is responsible to draw bothe outline/overlay of meshes.
  66036. * It should not be used directly but through the available method on mesh.
  66037. */
  66038. export class OutlineRenderer implements ISceneComponent {
  66039. /**
  66040. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66041. */
  66042. private static _StencilReference;
  66043. /**
  66044. * The name of the component. Each component must have a unique name.
  66045. */
  66046. name: string;
  66047. /**
  66048. * The scene the component belongs to.
  66049. */
  66050. scene: Scene;
  66051. /**
  66052. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66053. */
  66054. zOffset: number;
  66055. private _engine;
  66056. private _effect;
  66057. private _cachedDefines;
  66058. private _savedDepthWrite;
  66059. /**
  66060. * Instantiates a new outline renderer. (There could be only one per scene).
  66061. * @param scene Defines the scene it belongs to
  66062. */
  66063. constructor(scene: Scene);
  66064. /**
  66065. * Register the component to one instance of a scene.
  66066. */
  66067. register(): void;
  66068. /**
  66069. * Rebuilds the elements related to this component in case of
  66070. * context lost for instance.
  66071. */
  66072. rebuild(): void;
  66073. /**
  66074. * Disposes the component and the associated ressources.
  66075. */
  66076. dispose(): void;
  66077. /**
  66078. * Renders the outline in the canvas.
  66079. * @param subMesh Defines the sumesh to render
  66080. * @param batch Defines the batch of meshes in case of instances
  66081. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66082. */
  66083. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66084. /**
  66085. * Returns whether or not the outline renderer is ready for a given submesh.
  66086. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66087. * @param subMesh Defines the submesh to check readyness for
  66088. * @param useInstances Defines wheter wee are trying to render instances or not
  66089. * @returns true if ready otherwise false
  66090. */
  66091. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66092. private _beforeRenderingMesh;
  66093. private _afterRenderingMesh;
  66094. }
  66095. }
  66096. declare module "babylonjs/Rendering/index" {
  66097. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66098. export * from "babylonjs/Rendering/depthRenderer";
  66099. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66100. export * from "babylonjs/Rendering/edgesRenderer";
  66101. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66102. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66103. export * from "babylonjs/Rendering/outlineRenderer";
  66104. export * from "babylonjs/Rendering/renderingGroup";
  66105. export * from "babylonjs/Rendering/renderingManager";
  66106. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66107. }
  66108. declare module "babylonjs/Sprites/spritePackedManager" {
  66109. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66110. import { Scene } from "babylonjs/scene";
  66111. /**
  66112. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66113. * @see http://doc.babylonjs.com/babylon101/sprites
  66114. */
  66115. export class SpritePackedManager extends SpriteManager {
  66116. /** defines the packed manager's name */
  66117. name: string;
  66118. /**
  66119. * Creates a new sprite manager from a packed sprite sheet
  66120. * @param name defines the manager's name
  66121. * @param imgUrl defines the sprite sheet url
  66122. * @param capacity defines the maximum allowed number of sprites
  66123. * @param scene defines the hosting scene
  66124. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66125. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66126. * @param samplingMode defines the smapling mode to use with spritesheet
  66127. * @param fromPacked set to true; do not alter
  66128. */
  66129. constructor(
  66130. /** defines the packed manager's name */
  66131. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66132. }
  66133. }
  66134. declare module "babylonjs/Sprites/index" {
  66135. export * from "babylonjs/Sprites/sprite";
  66136. export * from "babylonjs/Sprites/spriteManager";
  66137. export * from "babylonjs/Sprites/spritePackedManager";
  66138. export * from "babylonjs/Sprites/spriteSceneComponent";
  66139. }
  66140. declare module "babylonjs/States/index" {
  66141. export * from "babylonjs/States/alphaCullingState";
  66142. export * from "babylonjs/States/depthCullingState";
  66143. export * from "babylonjs/States/stencilState";
  66144. }
  66145. declare module "babylonjs/Misc/assetsManager" {
  66146. import { Scene } from "babylonjs/scene";
  66147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66148. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66149. import { Skeleton } from "babylonjs/Bones/skeleton";
  66150. import { Observable } from "babylonjs/Misc/observable";
  66151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66152. import { Texture } from "babylonjs/Materials/Textures/texture";
  66153. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66154. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66155. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66156. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66157. /**
  66158. * Defines the list of states available for a task inside a AssetsManager
  66159. */
  66160. export enum AssetTaskState {
  66161. /**
  66162. * Initialization
  66163. */
  66164. INIT = 0,
  66165. /**
  66166. * Running
  66167. */
  66168. RUNNING = 1,
  66169. /**
  66170. * Done
  66171. */
  66172. DONE = 2,
  66173. /**
  66174. * Error
  66175. */
  66176. ERROR = 3
  66177. }
  66178. /**
  66179. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66180. */
  66181. export abstract class AbstractAssetTask {
  66182. /**
  66183. * Task name
  66184. */ name: string;
  66185. /**
  66186. * Callback called when the task is successful
  66187. */
  66188. onSuccess: (task: any) => void;
  66189. /**
  66190. * Callback called when the task is not successful
  66191. */
  66192. onError: (task: any, message?: string, exception?: any) => void;
  66193. /**
  66194. * Creates a new AssetsManager
  66195. * @param name defines the name of the task
  66196. */
  66197. constructor(
  66198. /**
  66199. * Task name
  66200. */ name: string);
  66201. private _isCompleted;
  66202. private _taskState;
  66203. private _errorObject;
  66204. /**
  66205. * Get if the task is completed
  66206. */
  66207. readonly isCompleted: boolean;
  66208. /**
  66209. * Gets the current state of the task
  66210. */
  66211. readonly taskState: AssetTaskState;
  66212. /**
  66213. * Gets the current error object (if task is in error)
  66214. */
  66215. readonly errorObject: {
  66216. message?: string;
  66217. exception?: any;
  66218. };
  66219. /**
  66220. * Internal only
  66221. * @hidden
  66222. */
  66223. _setErrorObject(message?: string, exception?: any): void;
  66224. /**
  66225. * Execute the current task
  66226. * @param scene defines the scene where you want your assets to be loaded
  66227. * @param onSuccess is a callback called when the task is successfully executed
  66228. * @param onError is a callback called if an error occurs
  66229. */
  66230. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66231. /**
  66232. * Execute the current task
  66233. * @param scene defines the scene where you want your assets to be loaded
  66234. * @param onSuccess is a callback called when the task is successfully executed
  66235. * @param onError is a callback called if an error occurs
  66236. */
  66237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66238. /**
  66239. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66240. * This can be used with failed tasks that have the reason for failure fixed.
  66241. */
  66242. reset(): void;
  66243. private onErrorCallback;
  66244. private onDoneCallback;
  66245. }
  66246. /**
  66247. * Define the interface used by progress events raised during assets loading
  66248. */
  66249. export interface IAssetsProgressEvent {
  66250. /**
  66251. * Defines the number of remaining tasks to process
  66252. */
  66253. remainingCount: number;
  66254. /**
  66255. * Defines the total number of tasks
  66256. */
  66257. totalCount: number;
  66258. /**
  66259. * Defines the task that was just processed
  66260. */
  66261. task: AbstractAssetTask;
  66262. }
  66263. /**
  66264. * Class used to share progress information about assets loading
  66265. */
  66266. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66267. /**
  66268. * Defines the number of remaining tasks to process
  66269. */
  66270. remainingCount: number;
  66271. /**
  66272. * Defines the total number of tasks
  66273. */
  66274. totalCount: number;
  66275. /**
  66276. * Defines the task that was just processed
  66277. */
  66278. task: AbstractAssetTask;
  66279. /**
  66280. * Creates a AssetsProgressEvent
  66281. * @param remainingCount defines the number of remaining tasks to process
  66282. * @param totalCount defines the total number of tasks
  66283. * @param task defines the task that was just processed
  66284. */
  66285. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66286. }
  66287. /**
  66288. * Define a task used by AssetsManager to load meshes
  66289. */
  66290. export class MeshAssetTask extends AbstractAssetTask {
  66291. /**
  66292. * Defines the name of the task
  66293. */
  66294. name: string;
  66295. /**
  66296. * Defines the list of mesh's names you want to load
  66297. */
  66298. meshesNames: any;
  66299. /**
  66300. * Defines the root url to use as a base to load your meshes and associated resources
  66301. */
  66302. rootUrl: string;
  66303. /**
  66304. * Defines the filename of the scene to load from
  66305. */
  66306. sceneFilename: string;
  66307. /**
  66308. * Gets the list of loaded meshes
  66309. */
  66310. loadedMeshes: Array<AbstractMesh>;
  66311. /**
  66312. * Gets the list of loaded particle systems
  66313. */
  66314. loadedParticleSystems: Array<IParticleSystem>;
  66315. /**
  66316. * Gets the list of loaded skeletons
  66317. */
  66318. loadedSkeletons: Array<Skeleton>;
  66319. /**
  66320. * Gets the list of loaded animation groups
  66321. */
  66322. loadedAnimationGroups: Array<AnimationGroup>;
  66323. /**
  66324. * Callback called when the task is successful
  66325. */
  66326. onSuccess: (task: MeshAssetTask) => void;
  66327. /**
  66328. * Callback called when the task is successful
  66329. */
  66330. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66331. /**
  66332. * Creates a new MeshAssetTask
  66333. * @param name defines the name of the task
  66334. * @param meshesNames defines the list of mesh's names you want to load
  66335. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66336. * @param sceneFilename defines the filename of the scene to load from
  66337. */
  66338. constructor(
  66339. /**
  66340. * Defines the name of the task
  66341. */
  66342. name: string,
  66343. /**
  66344. * Defines the list of mesh's names you want to load
  66345. */
  66346. meshesNames: any,
  66347. /**
  66348. * Defines the root url to use as a base to load your meshes and associated resources
  66349. */
  66350. rootUrl: string,
  66351. /**
  66352. * Defines the filename of the scene to load from
  66353. */
  66354. sceneFilename: string);
  66355. /**
  66356. * Execute the current task
  66357. * @param scene defines the scene where you want your assets to be loaded
  66358. * @param onSuccess is a callback called when the task is successfully executed
  66359. * @param onError is a callback called if an error occurs
  66360. */
  66361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66362. }
  66363. /**
  66364. * Define a task used by AssetsManager to load text content
  66365. */
  66366. export class TextFileAssetTask extends AbstractAssetTask {
  66367. /**
  66368. * Defines the name of the task
  66369. */
  66370. name: string;
  66371. /**
  66372. * Defines the location of the file to load
  66373. */
  66374. url: string;
  66375. /**
  66376. * Gets the loaded text string
  66377. */
  66378. text: string;
  66379. /**
  66380. * Callback called when the task is successful
  66381. */
  66382. onSuccess: (task: TextFileAssetTask) => void;
  66383. /**
  66384. * Callback called when the task is successful
  66385. */
  66386. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66387. /**
  66388. * Creates a new TextFileAssetTask object
  66389. * @param name defines the name of the task
  66390. * @param url defines the location of the file to load
  66391. */
  66392. constructor(
  66393. /**
  66394. * Defines the name of the task
  66395. */
  66396. name: string,
  66397. /**
  66398. * Defines the location of the file to load
  66399. */
  66400. url: string);
  66401. /**
  66402. * Execute the current task
  66403. * @param scene defines the scene where you want your assets to be loaded
  66404. * @param onSuccess is a callback called when the task is successfully executed
  66405. * @param onError is a callback called if an error occurs
  66406. */
  66407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66408. }
  66409. /**
  66410. * Define a task used by AssetsManager to load binary data
  66411. */
  66412. export class BinaryFileAssetTask extends AbstractAssetTask {
  66413. /**
  66414. * Defines the name of the task
  66415. */
  66416. name: string;
  66417. /**
  66418. * Defines the location of the file to load
  66419. */
  66420. url: string;
  66421. /**
  66422. * Gets the lodaded data (as an array buffer)
  66423. */
  66424. data: ArrayBuffer;
  66425. /**
  66426. * Callback called when the task is successful
  66427. */
  66428. onSuccess: (task: BinaryFileAssetTask) => void;
  66429. /**
  66430. * Callback called when the task is successful
  66431. */
  66432. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66433. /**
  66434. * Creates a new BinaryFileAssetTask object
  66435. * @param name defines the name of the new task
  66436. * @param url defines the location of the file to load
  66437. */
  66438. constructor(
  66439. /**
  66440. * Defines the name of the task
  66441. */
  66442. name: string,
  66443. /**
  66444. * Defines the location of the file to load
  66445. */
  66446. url: string);
  66447. /**
  66448. * Execute the current task
  66449. * @param scene defines the scene where you want your assets to be loaded
  66450. * @param onSuccess is a callback called when the task is successfully executed
  66451. * @param onError is a callback called if an error occurs
  66452. */
  66453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66454. }
  66455. /**
  66456. * Define a task used by AssetsManager to load images
  66457. */
  66458. export class ImageAssetTask extends AbstractAssetTask {
  66459. /**
  66460. * Defines the name of the task
  66461. */
  66462. name: string;
  66463. /**
  66464. * Defines the location of the image to load
  66465. */
  66466. url: string;
  66467. /**
  66468. * Gets the loaded images
  66469. */
  66470. image: HTMLImageElement;
  66471. /**
  66472. * Callback called when the task is successful
  66473. */
  66474. onSuccess: (task: ImageAssetTask) => void;
  66475. /**
  66476. * Callback called when the task is successful
  66477. */
  66478. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66479. /**
  66480. * Creates a new ImageAssetTask
  66481. * @param name defines the name of the task
  66482. * @param url defines the location of the image to load
  66483. */
  66484. constructor(
  66485. /**
  66486. * Defines the name of the task
  66487. */
  66488. name: string,
  66489. /**
  66490. * Defines the location of the image to load
  66491. */
  66492. url: string);
  66493. /**
  66494. * Execute the current task
  66495. * @param scene defines the scene where you want your assets to be loaded
  66496. * @param onSuccess is a callback called when the task is successfully executed
  66497. * @param onError is a callback called if an error occurs
  66498. */
  66499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66500. }
  66501. /**
  66502. * Defines the interface used by texture loading tasks
  66503. */
  66504. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66505. /**
  66506. * Gets the loaded texture
  66507. */
  66508. texture: TEX;
  66509. }
  66510. /**
  66511. * Define a task used by AssetsManager to load 2D textures
  66512. */
  66513. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66514. /**
  66515. * Defines the name of the task
  66516. */
  66517. name: string;
  66518. /**
  66519. * Defines the location of the file to load
  66520. */
  66521. url: string;
  66522. /**
  66523. * Defines if mipmap should not be generated (default is false)
  66524. */
  66525. noMipmap?: boolean | undefined;
  66526. /**
  66527. * Defines if texture must be inverted on Y axis (default is false)
  66528. */
  66529. invertY?: boolean | undefined;
  66530. /**
  66531. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66532. */
  66533. samplingMode: number;
  66534. /**
  66535. * Gets the loaded texture
  66536. */
  66537. texture: Texture;
  66538. /**
  66539. * Callback called when the task is successful
  66540. */
  66541. onSuccess: (task: TextureAssetTask) => void;
  66542. /**
  66543. * Callback called when the task is successful
  66544. */
  66545. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66546. /**
  66547. * Creates a new TextureAssetTask object
  66548. * @param name defines the name of the task
  66549. * @param url defines the location of the file to load
  66550. * @param noMipmap defines if mipmap should not be generated (default is false)
  66551. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66552. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66553. */
  66554. constructor(
  66555. /**
  66556. * Defines the name of the task
  66557. */
  66558. name: string,
  66559. /**
  66560. * Defines the location of the file to load
  66561. */
  66562. url: string,
  66563. /**
  66564. * Defines if mipmap should not be generated (default is false)
  66565. */
  66566. noMipmap?: boolean | undefined,
  66567. /**
  66568. * Defines if texture must be inverted on Y axis (default is false)
  66569. */
  66570. invertY?: boolean | undefined,
  66571. /**
  66572. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66573. */
  66574. samplingMode?: number);
  66575. /**
  66576. * Execute the current task
  66577. * @param scene defines the scene where you want your assets to be loaded
  66578. * @param onSuccess is a callback called when the task is successfully executed
  66579. * @param onError is a callback called if an error occurs
  66580. */
  66581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66582. }
  66583. /**
  66584. * Define a task used by AssetsManager to load cube textures
  66585. */
  66586. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66587. /**
  66588. * Defines the name of the task
  66589. */
  66590. name: string;
  66591. /**
  66592. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66593. */
  66594. url: string;
  66595. /**
  66596. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66597. */
  66598. extensions?: string[] | undefined;
  66599. /**
  66600. * Defines if mipmaps should not be generated (default is false)
  66601. */
  66602. noMipmap?: boolean | undefined;
  66603. /**
  66604. * Defines the explicit list of files (undefined by default)
  66605. */
  66606. files?: string[] | undefined;
  66607. /**
  66608. * Gets the loaded texture
  66609. */
  66610. texture: CubeTexture;
  66611. /**
  66612. * Callback called when the task is successful
  66613. */
  66614. onSuccess: (task: CubeTextureAssetTask) => void;
  66615. /**
  66616. * Callback called when the task is successful
  66617. */
  66618. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66619. /**
  66620. * Creates a new CubeTextureAssetTask
  66621. * @param name defines the name of the task
  66622. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66623. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66624. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66625. * @param files defines the explicit list of files (undefined by default)
  66626. */
  66627. constructor(
  66628. /**
  66629. * Defines the name of the task
  66630. */
  66631. name: string,
  66632. /**
  66633. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66634. */
  66635. url: string,
  66636. /**
  66637. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66638. */
  66639. extensions?: string[] | undefined,
  66640. /**
  66641. * Defines if mipmaps should not be generated (default is false)
  66642. */
  66643. noMipmap?: boolean | undefined,
  66644. /**
  66645. * Defines the explicit list of files (undefined by default)
  66646. */
  66647. files?: string[] | undefined);
  66648. /**
  66649. * Execute the current task
  66650. * @param scene defines the scene where you want your assets to be loaded
  66651. * @param onSuccess is a callback called when the task is successfully executed
  66652. * @param onError is a callback called if an error occurs
  66653. */
  66654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66655. }
  66656. /**
  66657. * Define a task used by AssetsManager to load HDR cube textures
  66658. */
  66659. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66660. /**
  66661. * Defines the name of the task
  66662. */
  66663. name: string;
  66664. /**
  66665. * Defines the location of the file to load
  66666. */
  66667. url: string;
  66668. /**
  66669. * Defines the desired size (the more it increases the longer the generation will be)
  66670. */
  66671. size: number;
  66672. /**
  66673. * Defines if mipmaps should not be generated (default is false)
  66674. */
  66675. noMipmap: boolean;
  66676. /**
  66677. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66678. */
  66679. generateHarmonics: boolean;
  66680. /**
  66681. * 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)
  66682. */
  66683. gammaSpace: boolean;
  66684. /**
  66685. * Internal Use Only
  66686. */
  66687. reserved: boolean;
  66688. /**
  66689. * Gets the loaded texture
  66690. */
  66691. texture: HDRCubeTexture;
  66692. /**
  66693. * Callback called when the task is successful
  66694. */
  66695. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66696. /**
  66697. * Callback called when the task is successful
  66698. */
  66699. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66700. /**
  66701. * Creates a new HDRCubeTextureAssetTask object
  66702. * @param name defines the name of the task
  66703. * @param url defines the location of the file to load
  66704. * @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.
  66705. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66706. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66707. * @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)
  66708. * @param reserved Internal use only
  66709. */
  66710. constructor(
  66711. /**
  66712. * Defines the name of the task
  66713. */
  66714. name: string,
  66715. /**
  66716. * Defines the location of the file to load
  66717. */
  66718. url: string,
  66719. /**
  66720. * Defines the desired size (the more it increases the longer the generation will be)
  66721. */
  66722. size: number,
  66723. /**
  66724. * Defines if mipmaps should not be generated (default is false)
  66725. */
  66726. noMipmap?: boolean,
  66727. /**
  66728. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66729. */
  66730. generateHarmonics?: boolean,
  66731. /**
  66732. * 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)
  66733. */
  66734. gammaSpace?: boolean,
  66735. /**
  66736. * Internal Use Only
  66737. */
  66738. reserved?: boolean);
  66739. /**
  66740. * Execute the current task
  66741. * @param scene defines the scene where you want your assets to be loaded
  66742. * @param onSuccess is a callback called when the task is successfully executed
  66743. * @param onError is a callback called if an error occurs
  66744. */
  66745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66746. }
  66747. /**
  66748. * Define a task used by AssetsManager to load Equirectangular cube textures
  66749. */
  66750. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66751. /**
  66752. * Defines the name of the task
  66753. */
  66754. name: string;
  66755. /**
  66756. * Defines the location of the file to load
  66757. */
  66758. url: string;
  66759. /**
  66760. * Defines the desired size (the more it increases the longer the generation will be)
  66761. */
  66762. size: number;
  66763. /**
  66764. * Defines if mipmaps should not be generated (default is false)
  66765. */
  66766. noMipmap: boolean;
  66767. /**
  66768. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66769. * but the standard material would require them in Gamma space) (default is true)
  66770. */
  66771. gammaSpace: boolean;
  66772. /**
  66773. * Gets the loaded texture
  66774. */
  66775. texture: EquiRectangularCubeTexture;
  66776. /**
  66777. * Callback called when the task is successful
  66778. */
  66779. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66780. /**
  66781. * Callback called when the task is successful
  66782. */
  66783. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66784. /**
  66785. * Creates a new EquiRectangularCubeTextureAssetTask object
  66786. * @param name defines the name of the task
  66787. * @param url defines the location of the file to load
  66788. * @param size defines the desired size (the more it increases the longer the generation will be)
  66789. * If the size is omitted this implies you are using a preprocessed cubemap.
  66790. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66791. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66792. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66793. * (default is true)
  66794. */
  66795. constructor(
  66796. /**
  66797. * Defines the name of the task
  66798. */
  66799. name: string,
  66800. /**
  66801. * Defines the location of the file to load
  66802. */
  66803. url: string,
  66804. /**
  66805. * Defines the desired size (the more it increases the longer the generation will be)
  66806. */
  66807. size: number,
  66808. /**
  66809. * Defines if mipmaps should not be generated (default is false)
  66810. */
  66811. noMipmap?: boolean,
  66812. /**
  66813. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66814. * but the standard material would require them in Gamma space) (default is true)
  66815. */
  66816. gammaSpace?: boolean);
  66817. /**
  66818. * Execute the current task
  66819. * @param scene defines the scene where you want your assets to be loaded
  66820. * @param onSuccess is a callback called when the task is successfully executed
  66821. * @param onError is a callback called if an error occurs
  66822. */
  66823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66824. }
  66825. /**
  66826. * This class can be used to easily import assets into a scene
  66827. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66828. */
  66829. export class AssetsManager {
  66830. private _scene;
  66831. private _isLoading;
  66832. protected _tasks: AbstractAssetTask[];
  66833. protected _waitingTasksCount: number;
  66834. protected _totalTasksCount: number;
  66835. /**
  66836. * Callback called when all tasks are processed
  66837. */
  66838. onFinish: (tasks: AbstractAssetTask[]) => void;
  66839. /**
  66840. * Callback called when a task is successful
  66841. */
  66842. onTaskSuccess: (task: AbstractAssetTask) => void;
  66843. /**
  66844. * Callback called when a task had an error
  66845. */
  66846. onTaskError: (task: AbstractAssetTask) => void;
  66847. /**
  66848. * Callback called when a task is done (whatever the result is)
  66849. */
  66850. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66851. /**
  66852. * Observable called when all tasks are processed
  66853. */
  66854. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66855. /**
  66856. * Observable called when a task had an error
  66857. */
  66858. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66859. /**
  66860. * Observable called when all tasks were executed
  66861. */
  66862. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66863. /**
  66864. * Observable called when a task is done (whatever the result is)
  66865. */
  66866. onProgressObservable: Observable<IAssetsProgressEvent>;
  66867. /**
  66868. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66870. */
  66871. useDefaultLoadingScreen: boolean;
  66872. /**
  66873. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66874. * when all assets have been downloaded.
  66875. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66876. */
  66877. autoHideLoadingUI: boolean;
  66878. /**
  66879. * Creates a new AssetsManager
  66880. * @param scene defines the scene to work on
  66881. */
  66882. constructor(scene: Scene);
  66883. /**
  66884. * Add a MeshAssetTask to the list of active tasks
  66885. * @param taskName defines the name of the new task
  66886. * @param meshesNames defines the name of meshes to load
  66887. * @param rootUrl defines the root url to use to locate files
  66888. * @param sceneFilename defines the filename of the scene file
  66889. * @returns a new MeshAssetTask object
  66890. */
  66891. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66892. /**
  66893. * Add a TextFileAssetTask to the list of active tasks
  66894. * @param taskName defines the name of the new task
  66895. * @param url defines the url of the file to load
  66896. * @returns a new TextFileAssetTask object
  66897. */
  66898. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66899. /**
  66900. * Add a BinaryFileAssetTask to the list of active tasks
  66901. * @param taskName defines the name of the new task
  66902. * @param url defines the url of the file to load
  66903. * @returns a new BinaryFileAssetTask object
  66904. */
  66905. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66906. /**
  66907. * Add a ImageAssetTask to the list of active tasks
  66908. * @param taskName defines the name of the new task
  66909. * @param url defines the url of the file to load
  66910. * @returns a new ImageAssetTask object
  66911. */
  66912. addImageTask(taskName: string, url: string): ImageAssetTask;
  66913. /**
  66914. * Add a TextureAssetTask to the list of active tasks
  66915. * @param taskName defines the name of the new task
  66916. * @param url defines the url of the file to load
  66917. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66918. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66919. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66920. * @returns a new TextureAssetTask object
  66921. */
  66922. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66923. /**
  66924. * Add a CubeTextureAssetTask to the list of active tasks
  66925. * @param taskName defines the name of the new task
  66926. * @param url defines the url of the file to load
  66927. * @param extensions defines the extension to use to load the cube map (can be null)
  66928. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66929. * @param files defines the list of files to load (can be null)
  66930. * @returns a new CubeTextureAssetTask object
  66931. */
  66932. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66933. /**
  66934. *
  66935. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66936. * @param taskName defines the name of the new task
  66937. * @param url defines the url of the file to load
  66938. * @param size defines the size you want for the cubemap (can be null)
  66939. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66940. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66941. * @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)
  66942. * @param reserved Internal use only
  66943. * @returns a new HDRCubeTextureAssetTask object
  66944. */
  66945. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66946. /**
  66947. *
  66948. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66949. * @param taskName defines the name of the new task
  66950. * @param url defines the url of the file to load
  66951. * @param size defines the size you want for the cubemap (can be null)
  66952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66953. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66954. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66955. * @returns a new EquiRectangularCubeTextureAssetTask object
  66956. */
  66957. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66958. /**
  66959. * Remove a task from the assets manager.
  66960. * @param task the task to remove
  66961. */
  66962. removeTask(task: AbstractAssetTask): void;
  66963. private _decreaseWaitingTasksCount;
  66964. private _runTask;
  66965. /**
  66966. * Reset the AssetsManager and remove all tasks
  66967. * @return the current instance of the AssetsManager
  66968. */
  66969. reset(): AssetsManager;
  66970. /**
  66971. * Start the loading process
  66972. * @return the current instance of the AssetsManager
  66973. */
  66974. load(): AssetsManager;
  66975. /**
  66976. * Start the loading process as an async operation
  66977. * @return a promise returning the list of failed tasks
  66978. */
  66979. loadAsync(): Promise<void>;
  66980. }
  66981. }
  66982. declare module "babylonjs/Misc/deferred" {
  66983. /**
  66984. * Wrapper class for promise with external resolve and reject.
  66985. */
  66986. export class Deferred<T> {
  66987. /**
  66988. * The promise associated with this deferred object.
  66989. */
  66990. readonly promise: Promise<T>;
  66991. private _resolve;
  66992. private _reject;
  66993. /**
  66994. * The resolve method of the promise associated with this deferred object.
  66995. */
  66996. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66997. /**
  66998. * The reject method of the promise associated with this deferred object.
  66999. */
  67000. readonly reject: (reason?: any) => void;
  67001. /**
  67002. * Constructor for this deferred object.
  67003. */
  67004. constructor();
  67005. }
  67006. }
  67007. declare module "babylonjs/Misc/meshExploder" {
  67008. import { Mesh } from "babylonjs/Meshes/mesh";
  67009. /**
  67010. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67011. */
  67012. export class MeshExploder {
  67013. private _centerMesh;
  67014. private _meshes;
  67015. private _meshesOrigins;
  67016. private _toCenterVectors;
  67017. private _scaledDirection;
  67018. private _newPosition;
  67019. private _centerPosition;
  67020. /**
  67021. * Explodes meshes from a center mesh.
  67022. * @param meshes The meshes to explode.
  67023. * @param centerMesh The mesh to be center of explosion.
  67024. */
  67025. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67026. private _setCenterMesh;
  67027. /**
  67028. * Get class name
  67029. * @returns "MeshExploder"
  67030. */
  67031. getClassName(): string;
  67032. /**
  67033. * "Exploded meshes"
  67034. * @returns Array of meshes with the centerMesh at index 0.
  67035. */
  67036. getMeshes(): Array<Mesh>;
  67037. /**
  67038. * Explodes meshes giving a specific direction
  67039. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67040. */
  67041. explode(direction?: number): void;
  67042. }
  67043. }
  67044. declare module "babylonjs/Misc/filesInput" {
  67045. import { Engine } from "babylonjs/Engines/engine";
  67046. import { Scene } from "babylonjs/scene";
  67047. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67048. /**
  67049. * Class used to help managing file picking and drag'n'drop
  67050. */
  67051. export class FilesInput {
  67052. /**
  67053. * List of files ready to be loaded
  67054. */
  67055. static readonly FilesToLoad: {
  67056. [key: string]: File;
  67057. };
  67058. /**
  67059. * Callback called when a file is processed
  67060. */
  67061. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67062. private _engine;
  67063. private _currentScene;
  67064. private _sceneLoadedCallback;
  67065. private _progressCallback;
  67066. private _additionalRenderLoopLogicCallback;
  67067. private _textureLoadingCallback;
  67068. private _startingProcessingFilesCallback;
  67069. private _onReloadCallback;
  67070. private _errorCallback;
  67071. private _elementToMonitor;
  67072. private _sceneFileToLoad;
  67073. private _filesToLoad;
  67074. /**
  67075. * Creates a new FilesInput
  67076. * @param engine defines the rendering engine
  67077. * @param scene defines the hosting scene
  67078. * @param sceneLoadedCallback callback called when scene is loaded
  67079. * @param progressCallback callback called to track progress
  67080. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67081. * @param textureLoadingCallback callback called when a texture is loading
  67082. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67083. * @param onReloadCallback callback called when a reload is requested
  67084. * @param errorCallback callback call if an error occurs
  67085. */
  67086. 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);
  67087. private _dragEnterHandler;
  67088. private _dragOverHandler;
  67089. private _dropHandler;
  67090. /**
  67091. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67092. * @param elementToMonitor defines the DOM element to track
  67093. */
  67094. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67095. /**
  67096. * Release all associated resources
  67097. */
  67098. dispose(): void;
  67099. private renderFunction;
  67100. private drag;
  67101. private drop;
  67102. private _traverseFolder;
  67103. private _processFiles;
  67104. /**
  67105. * Load files from a drop event
  67106. * @param event defines the drop event to use as source
  67107. */
  67108. loadFiles(event: any): void;
  67109. private _processReload;
  67110. /**
  67111. * Reload the current scene from the loaded files
  67112. */
  67113. reload(): void;
  67114. }
  67115. }
  67116. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67117. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67118. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67119. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67120. }
  67121. declare module "babylonjs/Misc/sceneOptimizer" {
  67122. import { Scene, IDisposable } from "babylonjs/scene";
  67123. import { Observable } from "babylonjs/Misc/observable";
  67124. /**
  67125. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67127. */
  67128. export class SceneOptimization {
  67129. /**
  67130. * Defines the priority of this optimization (0 by default which means first in the list)
  67131. */
  67132. priority: number;
  67133. /**
  67134. * Gets a string describing the action executed by the current optimization
  67135. * @returns description string
  67136. */
  67137. getDescription(): string;
  67138. /**
  67139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67140. * @param scene defines the current scene where to apply this optimization
  67141. * @param optimizer defines the current optimizer
  67142. * @returns true if everything that can be done was applied
  67143. */
  67144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67145. /**
  67146. * Creates the SceneOptimization object
  67147. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67148. * @param desc defines the description associated with the optimization
  67149. */
  67150. constructor(
  67151. /**
  67152. * Defines the priority of this optimization (0 by default which means first in the list)
  67153. */
  67154. priority?: number);
  67155. }
  67156. /**
  67157. * Defines an optimization used to reduce the size of render target textures
  67158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67159. */
  67160. export class TextureOptimization extends SceneOptimization {
  67161. /**
  67162. * Defines the priority of this optimization (0 by default which means first in the list)
  67163. */
  67164. priority: number;
  67165. /**
  67166. * 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
  67167. */
  67168. maximumSize: number;
  67169. /**
  67170. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67171. */
  67172. step: number;
  67173. /**
  67174. * Gets a string describing the action executed by the current optimization
  67175. * @returns description string
  67176. */
  67177. getDescription(): string;
  67178. /**
  67179. * Creates the TextureOptimization object
  67180. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67181. * @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
  67182. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67183. */
  67184. constructor(
  67185. /**
  67186. * Defines the priority of this optimization (0 by default which means first in the list)
  67187. */
  67188. priority?: number,
  67189. /**
  67190. * 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
  67191. */
  67192. maximumSize?: number,
  67193. /**
  67194. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67195. */
  67196. step?: number);
  67197. /**
  67198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67199. * @param scene defines the current scene where to apply this optimization
  67200. * @param optimizer defines the current optimizer
  67201. * @returns true if everything that can be done was applied
  67202. */
  67203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67204. }
  67205. /**
  67206. * Defines an optimization used to increase or decrease the rendering resolution
  67207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67208. */
  67209. export class HardwareScalingOptimization extends SceneOptimization {
  67210. /**
  67211. * Defines the priority of this optimization (0 by default which means first in the list)
  67212. */
  67213. priority: number;
  67214. /**
  67215. * Defines the maximum scale to use (2 by default)
  67216. */
  67217. maximumScale: number;
  67218. /**
  67219. * Defines the step to use between two passes (0.5 by default)
  67220. */
  67221. step: number;
  67222. private _currentScale;
  67223. private _directionOffset;
  67224. /**
  67225. * Gets a string describing the action executed by the current optimization
  67226. * @return description string
  67227. */
  67228. getDescription(): string;
  67229. /**
  67230. * Creates the HardwareScalingOptimization object
  67231. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67232. * @param maximumScale defines the maximum scale to use (2 by default)
  67233. * @param step defines the step to use between two passes (0.5 by default)
  67234. */
  67235. constructor(
  67236. /**
  67237. * Defines the priority of this optimization (0 by default which means first in the list)
  67238. */
  67239. priority?: number,
  67240. /**
  67241. * Defines the maximum scale to use (2 by default)
  67242. */
  67243. maximumScale?: number,
  67244. /**
  67245. * Defines the step to use between two passes (0.5 by default)
  67246. */
  67247. step?: number);
  67248. /**
  67249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67250. * @param scene defines the current scene where to apply this optimization
  67251. * @param optimizer defines the current optimizer
  67252. * @returns true if everything that can be done was applied
  67253. */
  67254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67255. }
  67256. /**
  67257. * Defines an optimization used to remove shadows
  67258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67259. */
  67260. export class ShadowsOptimization extends SceneOptimization {
  67261. /**
  67262. * Gets a string describing the action executed by the current optimization
  67263. * @return description string
  67264. */
  67265. getDescription(): string;
  67266. /**
  67267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67268. * @param scene defines the current scene where to apply this optimization
  67269. * @param optimizer defines the current optimizer
  67270. * @returns true if everything that can be done was applied
  67271. */
  67272. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67273. }
  67274. /**
  67275. * Defines an optimization used to turn post-processes off
  67276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67277. */
  67278. export class PostProcessesOptimization extends SceneOptimization {
  67279. /**
  67280. * Gets a string describing the action executed by the current optimization
  67281. * @return description string
  67282. */
  67283. getDescription(): string;
  67284. /**
  67285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67286. * @param scene defines the current scene where to apply this optimization
  67287. * @param optimizer defines the current optimizer
  67288. * @returns true if everything that can be done was applied
  67289. */
  67290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67291. }
  67292. /**
  67293. * Defines an optimization used to turn lens flares off
  67294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67295. */
  67296. export class LensFlaresOptimization extends SceneOptimization {
  67297. /**
  67298. * Gets a string describing the action executed by the current optimization
  67299. * @return description string
  67300. */
  67301. getDescription(): string;
  67302. /**
  67303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67304. * @param scene defines the current scene where to apply this optimization
  67305. * @param optimizer defines the current optimizer
  67306. * @returns true if everything that can be done was applied
  67307. */
  67308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67309. }
  67310. /**
  67311. * Defines an optimization based on user defined callback.
  67312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67313. */
  67314. export class CustomOptimization extends SceneOptimization {
  67315. /**
  67316. * Callback called to apply the custom optimization.
  67317. */
  67318. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67319. /**
  67320. * Callback called to get custom description
  67321. */
  67322. onGetDescription: () => string;
  67323. /**
  67324. * Gets a string describing the action executed by the current optimization
  67325. * @returns description string
  67326. */
  67327. getDescription(): string;
  67328. /**
  67329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67330. * @param scene defines the current scene where to apply this optimization
  67331. * @param optimizer defines the current optimizer
  67332. * @returns true if everything that can be done was applied
  67333. */
  67334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67335. }
  67336. /**
  67337. * Defines an optimization used to turn particles off
  67338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67339. */
  67340. export class ParticlesOptimization extends SceneOptimization {
  67341. /**
  67342. * Gets a string describing the action executed by the current optimization
  67343. * @return description string
  67344. */
  67345. getDescription(): string;
  67346. /**
  67347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67348. * @param scene defines the current scene where to apply this optimization
  67349. * @param optimizer defines the current optimizer
  67350. * @returns true if everything that can be done was applied
  67351. */
  67352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67353. }
  67354. /**
  67355. * Defines an optimization used to turn render targets off
  67356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67357. */
  67358. export class RenderTargetsOptimization extends SceneOptimization {
  67359. /**
  67360. * Gets a string describing the action executed by the current optimization
  67361. * @return description string
  67362. */
  67363. getDescription(): string;
  67364. /**
  67365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67366. * @param scene defines the current scene where to apply this optimization
  67367. * @param optimizer defines the current optimizer
  67368. * @returns true if everything that can be done was applied
  67369. */
  67370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67371. }
  67372. /**
  67373. * Defines an optimization used to merge meshes with compatible materials
  67374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67375. */
  67376. export class MergeMeshesOptimization extends SceneOptimization {
  67377. private static _UpdateSelectionTree;
  67378. /**
  67379. * Gets or sets a boolean which defines if optimization octree has to be updated
  67380. */
  67381. /**
  67382. * Gets or sets a boolean which defines if optimization octree has to be updated
  67383. */
  67384. static UpdateSelectionTree: boolean;
  67385. /**
  67386. * Gets a string describing the action executed by the current optimization
  67387. * @return description string
  67388. */
  67389. getDescription(): string;
  67390. private _canBeMerged;
  67391. /**
  67392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67393. * @param scene defines the current scene where to apply this optimization
  67394. * @param optimizer defines the current optimizer
  67395. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67396. * @returns true if everything that can be done was applied
  67397. */
  67398. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67399. }
  67400. /**
  67401. * Defines a list of options used by SceneOptimizer
  67402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67403. */
  67404. export class SceneOptimizerOptions {
  67405. /**
  67406. * Defines the target frame rate to reach (60 by default)
  67407. */
  67408. targetFrameRate: number;
  67409. /**
  67410. * Defines the interval between two checkes (2000ms by default)
  67411. */
  67412. trackerDuration: number;
  67413. /**
  67414. * Gets the list of optimizations to apply
  67415. */
  67416. optimizations: SceneOptimization[];
  67417. /**
  67418. * Creates a new list of options used by SceneOptimizer
  67419. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67420. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67421. */
  67422. constructor(
  67423. /**
  67424. * Defines the target frame rate to reach (60 by default)
  67425. */
  67426. targetFrameRate?: number,
  67427. /**
  67428. * Defines the interval between two checkes (2000ms by default)
  67429. */
  67430. trackerDuration?: number);
  67431. /**
  67432. * Add a new optimization
  67433. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67434. * @returns the current SceneOptimizerOptions
  67435. */
  67436. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67437. /**
  67438. * Add a new custom optimization
  67439. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67440. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67442. * @returns the current SceneOptimizerOptions
  67443. */
  67444. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67445. /**
  67446. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67447. * @param targetFrameRate defines the target frame rate (60 by default)
  67448. * @returns a SceneOptimizerOptions object
  67449. */
  67450. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67451. /**
  67452. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67453. * @param targetFrameRate defines the target frame rate (60 by default)
  67454. * @returns a SceneOptimizerOptions object
  67455. */
  67456. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67457. /**
  67458. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67459. * @param targetFrameRate defines the target frame rate (60 by default)
  67460. * @returns a SceneOptimizerOptions object
  67461. */
  67462. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67463. }
  67464. /**
  67465. * Class used to run optimizations in order to reach a target frame rate
  67466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67467. */
  67468. export class SceneOptimizer implements IDisposable {
  67469. private _isRunning;
  67470. private _options;
  67471. private _scene;
  67472. private _currentPriorityLevel;
  67473. private _targetFrameRate;
  67474. private _trackerDuration;
  67475. private _currentFrameRate;
  67476. private _sceneDisposeObserver;
  67477. private _improvementMode;
  67478. /**
  67479. * Defines an observable called when the optimizer reaches the target frame rate
  67480. */
  67481. onSuccessObservable: Observable<SceneOptimizer>;
  67482. /**
  67483. * Defines an observable called when the optimizer enables an optimization
  67484. */
  67485. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67486. /**
  67487. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67488. */
  67489. onFailureObservable: Observable<SceneOptimizer>;
  67490. /**
  67491. * Gets a boolean indicating if the optimizer is in improvement mode
  67492. */
  67493. readonly isInImprovementMode: boolean;
  67494. /**
  67495. * Gets the current priority level (0 at start)
  67496. */
  67497. readonly currentPriorityLevel: number;
  67498. /**
  67499. * Gets the current frame rate checked by the SceneOptimizer
  67500. */
  67501. readonly currentFrameRate: number;
  67502. /**
  67503. * Gets or sets the current target frame rate (60 by default)
  67504. */
  67505. /**
  67506. * Gets or sets the current target frame rate (60 by default)
  67507. */
  67508. targetFrameRate: number;
  67509. /**
  67510. * Gets or sets the current interval between two checks (every 2000ms by default)
  67511. */
  67512. /**
  67513. * Gets or sets the current interval between two checks (every 2000ms by default)
  67514. */
  67515. trackerDuration: number;
  67516. /**
  67517. * Gets the list of active optimizations
  67518. */
  67519. readonly optimizations: SceneOptimization[];
  67520. /**
  67521. * Creates a new SceneOptimizer
  67522. * @param scene defines the scene to work on
  67523. * @param options defines the options to use with the SceneOptimizer
  67524. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67525. * @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)
  67526. */
  67527. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67528. /**
  67529. * Stops the current optimizer
  67530. */
  67531. stop(): void;
  67532. /**
  67533. * Reset the optimizer to initial step (current priority level = 0)
  67534. */
  67535. reset(): void;
  67536. /**
  67537. * Start the optimizer. By default it will try to reach a specific framerate
  67538. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67539. */
  67540. start(): void;
  67541. private _checkCurrentState;
  67542. /**
  67543. * Release all resources
  67544. */
  67545. dispose(): void;
  67546. /**
  67547. * Helper function to create a SceneOptimizer with one single line of code
  67548. * @param scene defines the scene to work on
  67549. * @param options defines the options to use with the SceneOptimizer
  67550. * @param onSuccess defines a callback to call on success
  67551. * @param onFailure defines a callback to call on failure
  67552. * @returns the new SceneOptimizer object
  67553. */
  67554. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67555. }
  67556. }
  67557. declare module "babylonjs/Misc/sceneSerializer" {
  67558. import { Scene } from "babylonjs/scene";
  67559. /**
  67560. * Class used to serialize a scene into a string
  67561. */
  67562. export class SceneSerializer {
  67563. /**
  67564. * Clear cache used by a previous serialization
  67565. */
  67566. static ClearCache(): void;
  67567. /**
  67568. * Serialize a scene into a JSON compatible object
  67569. * @param scene defines the scene to serialize
  67570. * @returns a JSON compatible object
  67571. */
  67572. static Serialize(scene: Scene): any;
  67573. /**
  67574. * Serialize a mesh into a JSON compatible object
  67575. * @param toSerialize defines the mesh to serialize
  67576. * @param withParents defines if parents must be serialized as well
  67577. * @param withChildren defines if children must be serialized as well
  67578. * @returns a JSON compatible object
  67579. */
  67580. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67581. }
  67582. }
  67583. declare module "babylonjs/Misc/textureTools" {
  67584. import { Texture } from "babylonjs/Materials/Textures/texture";
  67585. /**
  67586. * Class used to host texture specific utilities
  67587. */
  67588. export class TextureTools {
  67589. /**
  67590. * Uses the GPU to create a copy texture rescaled at a given size
  67591. * @param texture Texture to copy from
  67592. * @param width defines the desired width
  67593. * @param height defines the desired height
  67594. * @param useBilinearMode defines if bilinear mode has to be used
  67595. * @return the generated texture
  67596. */
  67597. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67598. }
  67599. }
  67600. declare module "babylonjs/Misc/videoRecorder" {
  67601. import { Nullable } from "babylonjs/types";
  67602. import { Engine } from "babylonjs/Engines/engine";
  67603. /**
  67604. * This represents the different options available for the video capture.
  67605. */
  67606. export interface VideoRecorderOptions {
  67607. /** Defines the mime type of the video. */
  67608. mimeType: string;
  67609. /** Defines the FPS the video should be recorded at. */
  67610. fps: number;
  67611. /** Defines the chunk size for the recording data. */
  67612. recordChunckSize: number;
  67613. /** The audio tracks to attach to the recording. */
  67614. audioTracks?: MediaStreamTrack[];
  67615. }
  67616. /**
  67617. * This can help with recording videos from BabylonJS.
  67618. * This is based on the available WebRTC functionalities of the browser.
  67619. *
  67620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67621. */
  67622. export class VideoRecorder {
  67623. private static readonly _defaultOptions;
  67624. /**
  67625. * Returns whether or not the VideoRecorder is available in your browser.
  67626. * @param engine Defines the Babylon Engine.
  67627. * @returns true if supported otherwise false.
  67628. */
  67629. static IsSupported(engine: Engine): boolean;
  67630. private readonly _options;
  67631. private _canvas;
  67632. private _mediaRecorder;
  67633. private _recordedChunks;
  67634. private _fileName;
  67635. private _resolve;
  67636. private _reject;
  67637. /**
  67638. * True when a recording is already in progress.
  67639. */
  67640. readonly isRecording: boolean;
  67641. /**
  67642. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67643. * @param engine Defines the BabylonJS Engine you wish to record.
  67644. * @param options Defines options that can be used to customize the capture.
  67645. */
  67646. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67647. /**
  67648. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67649. */
  67650. stopRecording(): void;
  67651. /**
  67652. * Starts recording the canvas for a max duration specified in parameters.
  67653. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67654. * If null no automatic download will start and you can rely on the promise to get the data back.
  67655. * @param maxDuration Defines the maximum recording time in seconds.
  67656. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67657. * @return A promise callback at the end of the recording with the video data in Blob.
  67658. */
  67659. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67660. /**
  67661. * Releases internal resources used during the recording.
  67662. */
  67663. dispose(): void;
  67664. private _handleDataAvailable;
  67665. private _handleError;
  67666. private _handleStop;
  67667. }
  67668. }
  67669. declare module "babylonjs/Misc/screenshotTools" {
  67670. import { Camera } from "babylonjs/Cameras/camera";
  67671. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67672. import { Engine } from "babylonjs/Engines/engine";
  67673. /**
  67674. * Class containing a set of static utilities functions for screenshots
  67675. */
  67676. export class ScreenshotTools {
  67677. /**
  67678. * Captures a screenshot of the current rendering
  67679. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67680. * @param engine defines the rendering engine
  67681. * @param camera defines the source camera
  67682. * @param size This parameter can be set to a single number or to an object with the
  67683. * following (optional) properties: precision, width, height. If a single number is passed,
  67684. * it will be used for both width and height. If an object is passed, the screenshot size
  67685. * will be derived from the parameters. The precision property is a multiplier allowing
  67686. * rendering at a higher or lower resolution
  67687. * @param successCallback defines the callback receives a single parameter which contains the
  67688. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67689. * src parameter of an <img> to display it
  67690. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67691. * Check your browser for supported MIME types
  67692. */
  67693. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67694. /**
  67695. * Captures a screenshot of the current rendering
  67696. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67697. * @param engine defines the rendering engine
  67698. * @param camera defines the source camera
  67699. * @param size This parameter can be set to a single number or to an object with the
  67700. * following (optional) properties: precision, width, height. If a single number is passed,
  67701. * it will be used for both width and height. If an object is passed, the screenshot size
  67702. * will be derived from the parameters. The precision property is a multiplier allowing
  67703. * rendering at a higher or lower resolution
  67704. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67705. * Check your browser for supported MIME types
  67706. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67707. * to the src parameter of an <img> to display it
  67708. */
  67709. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67710. /**
  67711. * Generates an image screenshot from the specified camera.
  67712. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67713. * @param engine The engine to use for rendering
  67714. * @param camera The camera to use for rendering
  67715. * @param size This parameter can be set to a single number or to an object with the
  67716. * following (optional) properties: precision, width, height. If a single number is passed,
  67717. * it will be used for both width and height. If an object is passed, the screenshot size
  67718. * will be derived from the parameters. The precision property is a multiplier allowing
  67719. * rendering at a higher or lower resolution
  67720. * @param successCallback The callback receives a single parameter which contains the
  67721. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67722. * src parameter of an <img> to display it
  67723. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67724. * Check your browser for supported MIME types
  67725. * @param samples Texture samples (default: 1)
  67726. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67727. * @param fileName A name for for the downloaded file.
  67728. */
  67729. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67730. /**
  67731. * Generates an image screenshot from the specified camera.
  67732. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67733. * @param engine The engine to use for rendering
  67734. * @param camera The camera to use for rendering
  67735. * @param size This parameter can be set to a single number or to an object with the
  67736. * following (optional) properties: precision, width, height. If a single number is passed,
  67737. * it will be used for both width and height. If an object is passed, the screenshot size
  67738. * will be derived from the parameters. The precision property is a multiplier allowing
  67739. * rendering at a higher or lower resolution
  67740. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67741. * Check your browser for supported MIME types
  67742. * @param samples Texture samples (default: 1)
  67743. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67744. * @param fileName A name for for the downloaded file.
  67745. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67746. * to the src parameter of an <img> to display it
  67747. */
  67748. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67749. /**
  67750. * Gets height and width for screenshot size
  67751. * @private
  67752. */
  67753. private static _getScreenshotSize;
  67754. }
  67755. }
  67756. declare module "babylonjs/Misc/dataReader" {
  67757. /**
  67758. * Interface for a data buffer
  67759. */
  67760. export interface IDataBuffer {
  67761. /**
  67762. * Reads bytes from the data buffer.
  67763. * @param byteOffset The byte offset to read
  67764. * @param byteLength The byte length to read
  67765. * @returns A promise that resolves when the bytes are read
  67766. */
  67767. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67768. /**
  67769. * The byte length of the buffer.
  67770. */
  67771. readonly byteLength: number;
  67772. }
  67773. /**
  67774. * Utility class for reading from a data buffer
  67775. */
  67776. export class DataReader {
  67777. /**
  67778. * The data buffer associated with this data reader.
  67779. */
  67780. readonly buffer: IDataBuffer;
  67781. /**
  67782. * The current byte offset from the beginning of the data buffer.
  67783. */
  67784. byteOffset: number;
  67785. private _dataView;
  67786. private _dataByteOffset;
  67787. /**
  67788. * Constructor
  67789. * @param buffer The buffer to read
  67790. */
  67791. constructor(buffer: IDataBuffer);
  67792. /**
  67793. * Loads the given byte length.
  67794. * @param byteLength The byte length to load
  67795. * @returns A promise that resolves when the load is complete
  67796. */
  67797. loadAsync(byteLength: number): Promise<void>;
  67798. /**
  67799. * Read a unsigned 32-bit integer from the currently loaded data range.
  67800. * @returns The 32-bit integer read
  67801. */
  67802. readUint32(): number;
  67803. /**
  67804. * Read a byte array from the currently loaded data range.
  67805. * @param byteLength The byte length to read
  67806. * @returns The byte array read
  67807. */
  67808. readUint8Array(byteLength: number): Uint8Array;
  67809. /**
  67810. * Read a string from the currently loaded data range.
  67811. * @param byteLength The byte length to read
  67812. * @returns The string read
  67813. */
  67814. readString(byteLength: number): string;
  67815. /**
  67816. * Skips the given byte length the currently loaded data range.
  67817. * @param byteLength The byte length to skip
  67818. */
  67819. skipBytes(byteLength: number): void;
  67820. }
  67821. }
  67822. declare module "babylonjs/Misc/index" {
  67823. export * from "babylonjs/Misc/andOrNotEvaluator";
  67824. export * from "babylonjs/Misc/assetsManager";
  67825. export * from "babylonjs/Misc/dds";
  67826. export * from "babylonjs/Misc/decorators";
  67827. export * from "babylonjs/Misc/deferred";
  67828. export * from "babylonjs/Misc/environmentTextureTools";
  67829. export * from "babylonjs/Misc/meshExploder";
  67830. export * from "babylonjs/Misc/filesInput";
  67831. export * from "babylonjs/Misc/HighDynamicRange/index";
  67832. export * from "babylonjs/Misc/khronosTextureContainer";
  67833. export * from "babylonjs/Misc/observable";
  67834. export * from "babylonjs/Misc/performanceMonitor";
  67835. export * from "babylonjs/Misc/promise";
  67836. export * from "babylonjs/Misc/sceneOptimizer";
  67837. export * from "babylonjs/Misc/sceneSerializer";
  67838. export * from "babylonjs/Misc/smartArray";
  67839. export * from "babylonjs/Misc/stringDictionary";
  67840. export * from "babylonjs/Misc/tags";
  67841. export * from "babylonjs/Misc/textureTools";
  67842. export * from "babylonjs/Misc/tga";
  67843. export * from "babylonjs/Misc/tools";
  67844. export * from "babylonjs/Misc/videoRecorder";
  67845. export * from "babylonjs/Misc/virtualJoystick";
  67846. export * from "babylonjs/Misc/workerPool";
  67847. export * from "babylonjs/Misc/logger";
  67848. export * from "babylonjs/Misc/typeStore";
  67849. export * from "babylonjs/Misc/filesInputStore";
  67850. export * from "babylonjs/Misc/deepCopier";
  67851. export * from "babylonjs/Misc/pivotTools";
  67852. export * from "babylonjs/Misc/precisionDate";
  67853. export * from "babylonjs/Misc/screenshotTools";
  67854. export * from "babylonjs/Misc/typeStore";
  67855. export * from "babylonjs/Misc/webRequest";
  67856. export * from "babylonjs/Misc/iInspectable";
  67857. export * from "babylonjs/Misc/brdfTextureTools";
  67858. export * from "babylonjs/Misc/rgbdTextureTools";
  67859. export * from "babylonjs/Misc/gradients";
  67860. export * from "babylonjs/Misc/perfCounter";
  67861. export * from "babylonjs/Misc/fileRequest";
  67862. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67863. export * from "babylonjs/Misc/retryStrategy";
  67864. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67865. export * from "babylonjs/Misc/canvasGenerator";
  67866. export * from "babylonjs/Misc/fileTools";
  67867. export * from "babylonjs/Misc/stringTools";
  67868. export * from "babylonjs/Misc/dataReader";
  67869. }
  67870. declare module "babylonjs/index" {
  67871. export * from "babylonjs/abstractScene";
  67872. export * from "babylonjs/Actions/index";
  67873. export * from "babylonjs/Animations/index";
  67874. export * from "babylonjs/assetContainer";
  67875. export * from "babylonjs/Audio/index";
  67876. export * from "babylonjs/Behaviors/index";
  67877. export * from "babylonjs/Bones/index";
  67878. export * from "babylonjs/Cameras/index";
  67879. export * from "babylonjs/Collisions/index";
  67880. export * from "babylonjs/Culling/index";
  67881. export * from "babylonjs/Debug/index";
  67882. export * from "babylonjs/Engines/index";
  67883. export * from "babylonjs/Events/index";
  67884. export * from "babylonjs/Gamepads/index";
  67885. export * from "babylonjs/Gizmos/index";
  67886. export * from "babylonjs/Helpers/index";
  67887. export * from "babylonjs/Instrumentation/index";
  67888. export * from "babylonjs/Layers/index";
  67889. export * from "babylonjs/LensFlares/index";
  67890. export * from "babylonjs/Lights/index";
  67891. export * from "babylonjs/Loading/index";
  67892. export * from "babylonjs/Materials/index";
  67893. export * from "babylonjs/Maths/index";
  67894. export * from "babylonjs/Meshes/index";
  67895. export * from "babylonjs/Morph/index";
  67896. export * from "babylonjs/Navigation/index";
  67897. export * from "babylonjs/node";
  67898. export * from "babylonjs/Offline/index";
  67899. export * from "babylonjs/Particles/index";
  67900. export * from "babylonjs/Physics/index";
  67901. export * from "babylonjs/PostProcesses/index";
  67902. export * from "babylonjs/Probes/index";
  67903. export * from "babylonjs/Rendering/index";
  67904. export * from "babylonjs/scene";
  67905. export * from "babylonjs/sceneComponent";
  67906. export * from "babylonjs/Sprites/index";
  67907. export * from "babylonjs/States/index";
  67908. export * from "babylonjs/Misc/index";
  67909. export * from "babylonjs/types";
  67910. }
  67911. declare module "babylonjs/Animations/pathCursor" {
  67912. import { Vector3 } from "babylonjs/Maths/math.vector";
  67913. import { Path2 } from "babylonjs/Maths/math.path";
  67914. /**
  67915. * A cursor which tracks a point on a path
  67916. */
  67917. export class PathCursor {
  67918. private path;
  67919. /**
  67920. * Stores path cursor callbacks for when an onchange event is triggered
  67921. */
  67922. private _onchange;
  67923. /**
  67924. * The value of the path cursor
  67925. */
  67926. value: number;
  67927. /**
  67928. * The animation array of the path cursor
  67929. */
  67930. animations: Animation[];
  67931. /**
  67932. * Initializes the path cursor
  67933. * @param path The path to track
  67934. */
  67935. constructor(path: Path2);
  67936. /**
  67937. * Gets the cursor point on the path
  67938. * @returns A point on the path cursor at the cursor location
  67939. */
  67940. getPoint(): Vector3;
  67941. /**
  67942. * Moves the cursor ahead by the step amount
  67943. * @param step The amount to move the cursor forward
  67944. * @returns This path cursor
  67945. */
  67946. moveAhead(step?: number): PathCursor;
  67947. /**
  67948. * Moves the cursor behind by the step amount
  67949. * @param step The amount to move the cursor back
  67950. * @returns This path cursor
  67951. */
  67952. moveBack(step?: number): PathCursor;
  67953. /**
  67954. * Moves the cursor by the step amount
  67955. * If the step amount is greater than one, an exception is thrown
  67956. * @param step The amount to move the cursor
  67957. * @returns This path cursor
  67958. */
  67959. move(step: number): PathCursor;
  67960. /**
  67961. * Ensures that the value is limited between zero and one
  67962. * @returns This path cursor
  67963. */
  67964. private ensureLimits;
  67965. /**
  67966. * Runs onchange callbacks on change (used by the animation engine)
  67967. * @returns This path cursor
  67968. */
  67969. private raiseOnChange;
  67970. /**
  67971. * Executes a function on change
  67972. * @param f A path cursor onchange callback
  67973. * @returns This path cursor
  67974. */
  67975. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67976. }
  67977. }
  67978. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67979. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67980. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67981. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67982. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67983. }
  67984. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67985. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67986. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67987. }
  67988. declare module "babylonjs/Engines/Processors/index" {
  67989. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67990. export * from "babylonjs/Engines/Processors/Expressions/index";
  67991. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67992. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67993. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67994. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67995. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67996. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67997. }
  67998. declare module "babylonjs/Legacy/legacy" {
  67999. import * as Babylon from "babylonjs/index";
  68000. export * from "babylonjs/index";
  68001. }
  68002. declare module "babylonjs/Shaders/blur.fragment" {
  68003. /** @hidden */
  68004. export var blurPixelShader: {
  68005. name: string;
  68006. shader: string;
  68007. };
  68008. }
  68009. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68010. /** @hidden */
  68011. export var pointCloudVertexDeclaration: {
  68012. name: string;
  68013. shader: string;
  68014. };
  68015. }
  68016. declare module "babylonjs" {
  68017. export * from "babylonjs/Legacy/legacy";
  68018. }
  68019. declare module BABYLON {
  68020. /** Alias type for value that can be null */
  68021. export type Nullable<T> = T | null;
  68022. /**
  68023. * Alias type for number that are floats
  68024. * @ignorenaming
  68025. */
  68026. export type float = number;
  68027. /**
  68028. * Alias type for number that are doubles.
  68029. * @ignorenaming
  68030. */
  68031. export type double = number;
  68032. /**
  68033. * Alias type for number that are integer
  68034. * @ignorenaming
  68035. */
  68036. export type int = number;
  68037. /** Alias type for number array or Float32Array */
  68038. export type FloatArray = number[] | Float32Array;
  68039. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68040. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68041. /**
  68042. * Alias for types that can be used by a Buffer or VertexBuffer.
  68043. */
  68044. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68045. /**
  68046. * Alias type for primitive types
  68047. * @ignorenaming
  68048. */
  68049. type Primitive = undefined | null | boolean | string | number | Function;
  68050. /**
  68051. * Type modifier to make all the properties of an object Readonly
  68052. */
  68053. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68054. /**
  68055. * Type modifier to make all the properties of an object Readonly recursively
  68056. */
  68057. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68058. /**
  68059. * Type modifier to make object properties readonly.
  68060. */
  68061. export type DeepImmutableObject<T> = {
  68062. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68063. };
  68064. /** @hidden */
  68065. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68066. }
  68067. }
  68068. declare module BABYLON {
  68069. /**
  68070. * A class serves as a medium between the observable and its observers
  68071. */
  68072. export class EventState {
  68073. /**
  68074. * Create a new EventState
  68075. * @param mask defines the mask associated with this state
  68076. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68077. * @param target defines the original target of the state
  68078. * @param currentTarget defines the current target of the state
  68079. */
  68080. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68081. /**
  68082. * Initialize the current event state
  68083. * @param mask defines the mask associated with this state
  68084. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68085. * @param target defines the original target of the state
  68086. * @param currentTarget defines the current target of the state
  68087. * @returns the current event state
  68088. */
  68089. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68090. /**
  68091. * An Observer can set this property to true to prevent subsequent observers of being notified
  68092. */
  68093. skipNextObservers: boolean;
  68094. /**
  68095. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68096. */
  68097. mask: number;
  68098. /**
  68099. * The object that originally notified the event
  68100. */
  68101. target?: any;
  68102. /**
  68103. * The current object in the bubbling phase
  68104. */
  68105. currentTarget?: any;
  68106. /**
  68107. * This will be populated with the return value of the last function that was executed.
  68108. * If it is the first function in the callback chain it will be the event data.
  68109. */
  68110. lastReturnValue?: any;
  68111. }
  68112. /**
  68113. * Represent an Observer registered to a given Observable object.
  68114. */
  68115. export class Observer<T> {
  68116. /**
  68117. * Defines the callback to call when the observer is notified
  68118. */
  68119. callback: (eventData: T, eventState: EventState) => void;
  68120. /**
  68121. * Defines the mask of the observer (used to filter notifications)
  68122. */
  68123. mask: number;
  68124. /**
  68125. * Defines the current scope used to restore the JS context
  68126. */
  68127. scope: any;
  68128. /** @hidden */
  68129. _willBeUnregistered: boolean;
  68130. /**
  68131. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68132. */
  68133. unregisterOnNextCall: boolean;
  68134. /**
  68135. * Creates a new observer
  68136. * @param callback defines the callback to call when the observer is notified
  68137. * @param mask defines the mask of the observer (used to filter notifications)
  68138. * @param scope defines the current scope used to restore the JS context
  68139. */
  68140. constructor(
  68141. /**
  68142. * Defines the callback to call when the observer is notified
  68143. */
  68144. callback: (eventData: T, eventState: EventState) => void,
  68145. /**
  68146. * Defines the mask of the observer (used to filter notifications)
  68147. */
  68148. mask: number,
  68149. /**
  68150. * Defines the current scope used to restore the JS context
  68151. */
  68152. scope?: any);
  68153. }
  68154. /**
  68155. * Represent a list of observers registered to multiple Observables object.
  68156. */
  68157. export class MultiObserver<T> {
  68158. private _observers;
  68159. private _observables;
  68160. /**
  68161. * Release associated resources
  68162. */
  68163. dispose(): void;
  68164. /**
  68165. * Raise a callback when one of the observable will notify
  68166. * @param observables defines a list of observables to watch
  68167. * @param callback defines the callback to call on notification
  68168. * @param mask defines the mask used to filter notifications
  68169. * @param scope defines the current scope used to restore the JS context
  68170. * @returns the new MultiObserver
  68171. */
  68172. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68173. }
  68174. /**
  68175. * The Observable class is a simple implementation of the Observable pattern.
  68176. *
  68177. * 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.
  68178. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68179. * 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).
  68180. * 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.
  68181. */
  68182. export class Observable<T> {
  68183. private _observers;
  68184. private _eventState;
  68185. private _onObserverAdded;
  68186. /**
  68187. * Gets the list of observers
  68188. */
  68189. readonly observers: Array<Observer<T>>;
  68190. /**
  68191. * Creates a new observable
  68192. * @param onObserverAdded defines a callback to call when a new observer is added
  68193. */
  68194. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68195. /**
  68196. * Create a new Observer with the specified callback
  68197. * @param callback the callback that will be executed for that Observer
  68198. * @param mask the mask used to filter observers
  68199. * @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.
  68200. * @param scope optional scope for the callback to be called from
  68201. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68202. * @returns the new observer created for the callback
  68203. */
  68204. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68205. /**
  68206. * Create a new Observer with the specified callback and unregisters after the next notification
  68207. * @param callback the callback that will be executed for that Observer
  68208. * @returns the new observer created for the callback
  68209. */
  68210. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68211. /**
  68212. * Remove an Observer from the Observable object
  68213. * @param observer the instance of the Observer to remove
  68214. * @returns false if it doesn't belong to this Observable
  68215. */
  68216. remove(observer: Nullable<Observer<T>>): boolean;
  68217. /**
  68218. * Remove a callback from the Observable object
  68219. * @param callback the callback to remove
  68220. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68221. * @returns false if it doesn't belong to this Observable
  68222. */
  68223. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68224. private _deferUnregister;
  68225. private _remove;
  68226. /**
  68227. * Moves the observable to the top of the observer list making it get called first when notified
  68228. * @param observer the observer to move
  68229. */
  68230. makeObserverTopPriority(observer: Observer<T>): void;
  68231. /**
  68232. * Moves the observable to the bottom of the observer list making it get called last when notified
  68233. * @param observer the observer to move
  68234. */
  68235. makeObserverBottomPriority(observer: Observer<T>): void;
  68236. /**
  68237. * Notify all Observers by calling their respective callback with the given data
  68238. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68239. * @param eventData defines the data to send to all observers
  68240. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68241. * @param target defines the original target of the state
  68242. * @param currentTarget defines the current target of the state
  68243. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68244. */
  68245. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68246. /**
  68247. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68248. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68249. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68250. * and it is crucial that all callbacks will be executed.
  68251. * The order of the callbacks is kept, callbacks are not executed parallel.
  68252. *
  68253. * @param eventData The data to be sent to each callback
  68254. * @param mask is used to filter observers defaults to -1
  68255. * @param target defines the callback target (see EventState)
  68256. * @param currentTarget defines he current object in the bubbling phase
  68257. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68258. */
  68259. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68260. /**
  68261. * Notify a specific observer
  68262. * @param observer defines the observer to notify
  68263. * @param eventData defines the data to be sent to each callback
  68264. * @param mask is used to filter observers defaults to -1
  68265. */
  68266. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68267. /**
  68268. * Gets a boolean indicating if the observable has at least one observer
  68269. * @returns true is the Observable has at least one Observer registered
  68270. */
  68271. hasObservers(): boolean;
  68272. /**
  68273. * Clear the list of observers
  68274. */
  68275. clear(): void;
  68276. /**
  68277. * Clone the current observable
  68278. * @returns a new observable
  68279. */
  68280. clone(): Observable<T>;
  68281. /**
  68282. * Does this observable handles observer registered with a given mask
  68283. * @param mask defines the mask to be tested
  68284. * @return whether or not one observer registered with the given mask is handeled
  68285. **/
  68286. hasSpecificMask(mask?: number): boolean;
  68287. }
  68288. }
  68289. declare module BABYLON {
  68290. /**
  68291. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68292. * Babylon.js
  68293. */
  68294. export class DomManagement {
  68295. /**
  68296. * Checks if the window object exists
  68297. * @returns true if the window object exists
  68298. */
  68299. static IsWindowObjectExist(): boolean;
  68300. /**
  68301. * Checks if the navigator object exists
  68302. * @returns true if the navigator object exists
  68303. */
  68304. static IsNavigatorAvailable(): boolean;
  68305. /**
  68306. * Extracts text content from a DOM element hierarchy
  68307. * @param element defines the root element
  68308. * @returns a string
  68309. */
  68310. static GetDOMTextContent(element: HTMLElement): string;
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /**
  68315. * Logger used througouht the application to allow configuration of
  68316. * the log level required for the messages.
  68317. */
  68318. export class Logger {
  68319. /**
  68320. * No log
  68321. */
  68322. static readonly NoneLogLevel: number;
  68323. /**
  68324. * Only message logs
  68325. */
  68326. static readonly MessageLogLevel: number;
  68327. /**
  68328. * Only warning logs
  68329. */
  68330. static readonly WarningLogLevel: number;
  68331. /**
  68332. * Only error logs
  68333. */
  68334. static readonly ErrorLogLevel: number;
  68335. /**
  68336. * All logs
  68337. */
  68338. static readonly AllLogLevel: number;
  68339. private static _LogCache;
  68340. /**
  68341. * Gets a value indicating the number of loading errors
  68342. * @ignorenaming
  68343. */
  68344. static errorsCount: number;
  68345. /**
  68346. * Callback called when a new log is added
  68347. */
  68348. static OnNewCacheEntry: (entry: string) => void;
  68349. private static _AddLogEntry;
  68350. private static _FormatMessage;
  68351. private static _LogDisabled;
  68352. private static _LogEnabled;
  68353. private static _WarnDisabled;
  68354. private static _WarnEnabled;
  68355. private static _ErrorDisabled;
  68356. private static _ErrorEnabled;
  68357. /**
  68358. * Log a message to the console
  68359. */
  68360. static Log: (message: string) => void;
  68361. /**
  68362. * Write a warning message to the console
  68363. */
  68364. static Warn: (message: string) => void;
  68365. /**
  68366. * Write an error message to the console
  68367. */
  68368. static Error: (message: string) => void;
  68369. /**
  68370. * Gets current log cache (list of logs)
  68371. */
  68372. static readonly LogCache: string;
  68373. /**
  68374. * Clears the log cache
  68375. */
  68376. static ClearLogCache(): void;
  68377. /**
  68378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68379. */
  68380. static LogLevels: number;
  68381. }
  68382. }
  68383. declare module BABYLON {
  68384. /** @hidden */
  68385. export class _TypeStore {
  68386. /** @hidden */
  68387. static RegisteredTypes: {
  68388. [key: string]: Object;
  68389. };
  68390. /** @hidden */
  68391. static GetClass(fqdn: string): any;
  68392. }
  68393. }
  68394. declare module BABYLON {
  68395. /**
  68396. * Helper to manipulate strings
  68397. */
  68398. export class StringTools {
  68399. /**
  68400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68401. * @param str Source string
  68402. * @param suffix Suffix to search for in the source string
  68403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68404. */
  68405. static EndsWith(str: string, suffix: string): boolean;
  68406. /**
  68407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68408. * @param str Source string
  68409. * @param suffix Suffix to search for in the source string
  68410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68411. */
  68412. static StartsWith(str: string, suffix: string): boolean;
  68413. /**
  68414. * Decodes a buffer into a string
  68415. * @param buffer The buffer to decode
  68416. * @returns The decoded string
  68417. */
  68418. static Decode(buffer: Uint8Array | Uint16Array): string;
  68419. /**
  68420. * Encode a buffer to a base64 string
  68421. * @param buffer defines the buffer to encode
  68422. * @returns the encoded string
  68423. */
  68424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68425. }
  68426. }
  68427. declare module BABYLON {
  68428. /**
  68429. * Class containing a set of static utilities functions for deep copy.
  68430. */
  68431. export class DeepCopier {
  68432. /**
  68433. * Tries to copy an object by duplicating every property
  68434. * @param source defines the source object
  68435. * @param destination defines the target object
  68436. * @param doNotCopyList defines a list of properties to avoid
  68437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68438. */
  68439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68440. }
  68441. }
  68442. declare module BABYLON {
  68443. /**
  68444. * Class containing a set of static utilities functions for precision date
  68445. */
  68446. export class PrecisionDate {
  68447. /**
  68448. * Gets either window.performance.now() if supported or Date.now() else
  68449. */
  68450. static readonly Now: number;
  68451. }
  68452. }
  68453. declare module BABYLON {
  68454. /** @hidden */
  68455. export class _DevTools {
  68456. static WarnImport(name: string): string;
  68457. }
  68458. }
  68459. declare module BABYLON {
  68460. /**
  68461. * Interface used to define the mechanism to get data from the network
  68462. */
  68463. export interface IWebRequest {
  68464. /**
  68465. * Returns client's response url
  68466. */
  68467. responseURL: string;
  68468. /**
  68469. * Returns client's status
  68470. */
  68471. status: number;
  68472. /**
  68473. * Returns client's status as a text
  68474. */
  68475. statusText: string;
  68476. }
  68477. }
  68478. declare module BABYLON {
  68479. /**
  68480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68481. */
  68482. export class WebRequest implements IWebRequest {
  68483. private _xhr;
  68484. /**
  68485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68486. * i.e. when loading files, where the server/service expects an Authorization header
  68487. */
  68488. static CustomRequestHeaders: {
  68489. [key: string]: string;
  68490. };
  68491. /**
  68492. * Add callback functions in this array to update all the requests before they get sent to the network
  68493. */
  68494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68495. private _injectCustomRequestHeaders;
  68496. /**
  68497. * Gets or sets a function to be called when loading progress changes
  68498. */
  68499. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68500. /**
  68501. * Returns client's state
  68502. */
  68503. readonly readyState: number;
  68504. /**
  68505. * Returns client's status
  68506. */
  68507. readonly status: number;
  68508. /**
  68509. * Returns client's status as a text
  68510. */
  68511. readonly statusText: string;
  68512. /**
  68513. * Returns client's response
  68514. */
  68515. readonly response: any;
  68516. /**
  68517. * Returns client's response url
  68518. */
  68519. readonly responseURL: string;
  68520. /**
  68521. * Returns client's response as text
  68522. */
  68523. readonly responseText: string;
  68524. /**
  68525. * Gets or sets the expected response type
  68526. */
  68527. responseType: XMLHttpRequestResponseType;
  68528. /** @hidden */
  68529. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68530. /** @hidden */
  68531. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68532. /**
  68533. * Cancels any network activity
  68534. */
  68535. abort(): void;
  68536. /**
  68537. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68538. * @param body defines an optional request body
  68539. */
  68540. send(body?: Document | BodyInit | null): void;
  68541. /**
  68542. * Sets the request method, request URL
  68543. * @param method defines the method to use (GET, POST, etc..)
  68544. * @param url defines the url to connect with
  68545. */
  68546. open(method: string, url: string): void;
  68547. /**
  68548. * Sets the value of a request header.
  68549. * @param name The name of the header whose value is to be set
  68550. * @param value The value to set as the body of the header
  68551. */
  68552. setRequestHeader(name: string, value: string): void;
  68553. /**
  68554. * Get the string containing the text of a particular header's value.
  68555. * @param name The name of the header
  68556. * @returns The string containing the text of the given header name
  68557. */
  68558. getResponseHeader(name: string): Nullable<string>;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * File request interface
  68564. */
  68565. export interface IFileRequest {
  68566. /**
  68567. * Raised when the request is complete (success or error).
  68568. */
  68569. onCompleteObservable: Observable<IFileRequest>;
  68570. /**
  68571. * Aborts the request for a file.
  68572. */
  68573. abort: () => void;
  68574. }
  68575. }
  68576. declare module BABYLON {
  68577. /**
  68578. * Define options used to create a render target texture
  68579. */
  68580. export class RenderTargetCreationOptions {
  68581. /**
  68582. * Specifies is mipmaps must be generated
  68583. */
  68584. generateMipMaps?: boolean;
  68585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68586. generateDepthBuffer?: boolean;
  68587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68588. generateStencilBuffer?: boolean;
  68589. /** Defines texture type (int by default) */
  68590. type?: number;
  68591. /** Defines sampling mode (trilinear by default) */
  68592. samplingMode?: number;
  68593. /** Defines format (RGBA by default) */
  68594. format?: number;
  68595. }
  68596. }
  68597. declare module BABYLON {
  68598. /**
  68599. * @hidden
  68600. **/
  68601. export class _TimeToken {
  68602. _startTimeQuery: Nullable<WebGLQuery>;
  68603. _endTimeQuery: Nullable<WebGLQuery>;
  68604. _timeElapsedQuery: Nullable<WebGLQuery>;
  68605. _timeElapsedQueryEnded: boolean;
  68606. }
  68607. }
  68608. declare module BABYLON {
  68609. /** Defines the cross module used constants to avoid circular dependncies */
  68610. export class Constants {
  68611. /** Defines that alpha blending is disabled */
  68612. static readonly ALPHA_DISABLE: number;
  68613. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68614. static readonly ALPHA_ADD: number;
  68615. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68616. static readonly ALPHA_COMBINE: number;
  68617. /** Defines that alpha blending to DEST - SRC * DEST */
  68618. static readonly ALPHA_SUBTRACT: number;
  68619. /** Defines that alpha blending to SRC * DEST */
  68620. static readonly ALPHA_MULTIPLY: number;
  68621. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68622. static readonly ALPHA_MAXIMIZED: number;
  68623. /** Defines that alpha blending to SRC + DEST */
  68624. static readonly ALPHA_ONEONE: number;
  68625. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68626. static readonly ALPHA_PREMULTIPLIED: number;
  68627. /**
  68628. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68629. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68630. */
  68631. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68632. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68633. static readonly ALPHA_INTERPOLATE: number;
  68634. /**
  68635. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68636. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68637. */
  68638. static readonly ALPHA_SCREENMODE: number;
  68639. /**
  68640. * Defines that alpha blending to SRC + DST
  68641. * Alpha will be set to SRC ALPHA + DST ALPHA
  68642. */
  68643. static readonly ALPHA_ONEONE_ONEONE: number;
  68644. /**
  68645. * Defines that alpha blending to SRC * DST ALPHA + DST
  68646. * Alpha will be set to 0
  68647. */
  68648. static readonly ALPHA_ALPHATOCOLOR: number;
  68649. /**
  68650. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68651. */
  68652. static readonly ALPHA_REVERSEONEMINUS: number;
  68653. /**
  68654. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68655. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68656. */
  68657. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68658. /**
  68659. * Defines that alpha blending to SRC + DST
  68660. * Alpha will be set to SRC ALPHA
  68661. */
  68662. static readonly ALPHA_ONEONE_ONEZERO: number;
  68663. /** Defines that alpha blending equation a SUM */
  68664. static readonly ALPHA_EQUATION_ADD: number;
  68665. /** Defines that alpha blending equation a SUBSTRACTION */
  68666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68669. /** Defines that alpha blending equation a MAX operation */
  68670. static readonly ALPHA_EQUATION_MAX: number;
  68671. /** Defines that alpha blending equation a MIN operation */
  68672. static readonly ALPHA_EQUATION_MIN: number;
  68673. /**
  68674. * Defines that alpha blending equation a DARKEN operation:
  68675. * It takes the min of the src and sums the alpha channels.
  68676. */
  68677. static readonly ALPHA_EQUATION_DARKEN: number;
  68678. /** Defines that the ressource is not delayed*/
  68679. static readonly DELAYLOADSTATE_NONE: number;
  68680. /** Defines that the ressource was successfully delay loaded */
  68681. static readonly DELAYLOADSTATE_LOADED: number;
  68682. /** Defines that the ressource is currently delay loading */
  68683. static readonly DELAYLOADSTATE_LOADING: number;
  68684. /** Defines that the ressource is delayed and has not started loading */
  68685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68687. static readonly NEVER: number;
  68688. /** 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 */
  68689. static readonly ALWAYS: number;
  68690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68691. static readonly LESS: number;
  68692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68693. static readonly EQUAL: number;
  68694. /** 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 */
  68695. static readonly LEQUAL: number;
  68696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68697. static readonly GREATER: number;
  68698. /** 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 */
  68699. static readonly GEQUAL: number;
  68700. /** 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 */
  68701. static readonly NOTEQUAL: number;
  68702. /** Passed to stencilOperation to specify that stencil value must be kept */
  68703. static readonly KEEP: number;
  68704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68705. static readonly REPLACE: number;
  68706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68707. static readonly INCR: number;
  68708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68709. static readonly DECR: number;
  68710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68711. static readonly INVERT: number;
  68712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68713. static readonly INCR_WRAP: number;
  68714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68715. static readonly DECR_WRAP: number;
  68716. /** Texture is not repeating outside of 0..1 UVs */
  68717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68718. /** Texture is repeating outside of 0..1 UVs */
  68719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68720. /** Texture is repeating and mirrored */
  68721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68722. /** ALPHA */
  68723. static readonly TEXTUREFORMAT_ALPHA: number;
  68724. /** LUMINANCE */
  68725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68726. /** LUMINANCE_ALPHA */
  68727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68728. /** RGB */
  68729. static readonly TEXTUREFORMAT_RGB: number;
  68730. /** RGBA */
  68731. static readonly TEXTUREFORMAT_RGBA: number;
  68732. /** RED */
  68733. static readonly TEXTUREFORMAT_RED: number;
  68734. /** RED (2nd reference) */
  68735. static readonly TEXTUREFORMAT_R: number;
  68736. /** RG */
  68737. static readonly TEXTUREFORMAT_RG: number;
  68738. /** RED_INTEGER */
  68739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68740. /** RED_INTEGER (2nd reference) */
  68741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68742. /** RG_INTEGER */
  68743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68744. /** RGB_INTEGER */
  68745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68746. /** RGBA_INTEGER */
  68747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68748. /** UNSIGNED_BYTE */
  68749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68750. /** UNSIGNED_BYTE (2nd reference) */
  68751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68752. /** FLOAT */
  68753. static readonly TEXTURETYPE_FLOAT: number;
  68754. /** HALF_FLOAT */
  68755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68756. /** BYTE */
  68757. static readonly TEXTURETYPE_BYTE: number;
  68758. /** SHORT */
  68759. static readonly TEXTURETYPE_SHORT: number;
  68760. /** UNSIGNED_SHORT */
  68761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68762. /** INT */
  68763. static readonly TEXTURETYPE_INT: number;
  68764. /** UNSIGNED_INT */
  68765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68766. /** UNSIGNED_SHORT_4_4_4_4 */
  68767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68768. /** UNSIGNED_SHORT_5_5_5_1 */
  68769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68770. /** UNSIGNED_SHORT_5_6_5 */
  68771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68772. /** UNSIGNED_INT_2_10_10_10_REV */
  68773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68774. /** UNSIGNED_INT_24_8 */
  68775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68776. /** UNSIGNED_INT_10F_11F_11F_REV */
  68777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68778. /** UNSIGNED_INT_5_9_9_9_REV */
  68779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68782. /** nearest is mag = nearest and min = nearest and mip = linear */
  68783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68785. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68786. /** Trilinear is mag = linear and min = linear and mip = linear */
  68787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68788. /** nearest is mag = nearest and min = nearest and mip = linear */
  68789. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68792. /** Trilinear is mag = linear and min = linear and mip = linear */
  68793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68794. /** mag = nearest and min = nearest and mip = nearest */
  68795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68796. /** mag = nearest and min = linear and mip = nearest */
  68797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68798. /** mag = nearest and min = linear and mip = linear */
  68799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68800. /** mag = nearest and min = linear and mip = none */
  68801. static readonly TEXTURE_NEAREST_LINEAR: number;
  68802. /** mag = nearest and min = nearest and mip = none */
  68803. static readonly TEXTURE_NEAREST_NEAREST: number;
  68804. /** mag = linear and min = nearest and mip = nearest */
  68805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68806. /** mag = linear and min = nearest and mip = linear */
  68807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68808. /** mag = linear and min = linear and mip = none */
  68809. static readonly TEXTURE_LINEAR_LINEAR: number;
  68810. /** mag = linear and min = nearest and mip = none */
  68811. static readonly TEXTURE_LINEAR_NEAREST: number;
  68812. /** Explicit coordinates mode */
  68813. static readonly TEXTURE_EXPLICIT_MODE: number;
  68814. /** Spherical coordinates mode */
  68815. static readonly TEXTURE_SPHERICAL_MODE: number;
  68816. /** Planar coordinates mode */
  68817. static readonly TEXTURE_PLANAR_MODE: number;
  68818. /** Cubic coordinates mode */
  68819. static readonly TEXTURE_CUBIC_MODE: number;
  68820. /** Projection coordinates mode */
  68821. static readonly TEXTURE_PROJECTION_MODE: number;
  68822. /** Skybox coordinates mode */
  68823. static readonly TEXTURE_SKYBOX_MODE: number;
  68824. /** Inverse Cubic coordinates mode */
  68825. static readonly TEXTURE_INVCUBIC_MODE: number;
  68826. /** Equirectangular coordinates mode */
  68827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68828. /** Equirectangular Fixed coordinates mode */
  68829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68830. /** Equirectangular Fixed Mirrored coordinates mode */
  68831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68832. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68833. static readonly SCALEMODE_FLOOR: number;
  68834. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68835. static readonly SCALEMODE_NEAREST: number;
  68836. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68837. static readonly SCALEMODE_CEILING: number;
  68838. /**
  68839. * The dirty texture flag value
  68840. */
  68841. static readonly MATERIAL_TextureDirtyFlag: number;
  68842. /**
  68843. * The dirty light flag value
  68844. */
  68845. static readonly MATERIAL_LightDirtyFlag: number;
  68846. /**
  68847. * The dirty fresnel flag value
  68848. */
  68849. static readonly MATERIAL_FresnelDirtyFlag: number;
  68850. /**
  68851. * The dirty attribute flag value
  68852. */
  68853. static readonly MATERIAL_AttributesDirtyFlag: number;
  68854. /**
  68855. * The dirty misc flag value
  68856. */
  68857. static readonly MATERIAL_MiscDirtyFlag: number;
  68858. /**
  68859. * The all dirty flag value
  68860. */
  68861. static readonly MATERIAL_AllDirtyFlag: number;
  68862. /**
  68863. * Returns the triangle fill mode
  68864. */
  68865. static readonly MATERIAL_TriangleFillMode: number;
  68866. /**
  68867. * Returns the wireframe mode
  68868. */
  68869. static readonly MATERIAL_WireFrameFillMode: number;
  68870. /**
  68871. * Returns the point fill mode
  68872. */
  68873. static readonly MATERIAL_PointFillMode: number;
  68874. /**
  68875. * Returns the point list draw mode
  68876. */
  68877. static readonly MATERIAL_PointListDrawMode: number;
  68878. /**
  68879. * Returns the line list draw mode
  68880. */
  68881. static readonly MATERIAL_LineListDrawMode: number;
  68882. /**
  68883. * Returns the line loop draw mode
  68884. */
  68885. static readonly MATERIAL_LineLoopDrawMode: number;
  68886. /**
  68887. * Returns the line strip draw mode
  68888. */
  68889. static readonly MATERIAL_LineStripDrawMode: number;
  68890. /**
  68891. * Returns the triangle strip draw mode
  68892. */
  68893. static readonly MATERIAL_TriangleStripDrawMode: number;
  68894. /**
  68895. * Returns the triangle fan draw mode
  68896. */
  68897. static readonly MATERIAL_TriangleFanDrawMode: number;
  68898. /**
  68899. * Stores the clock-wise side orientation
  68900. */
  68901. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68902. /**
  68903. * Stores the counter clock-wise side orientation
  68904. */
  68905. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68906. /**
  68907. * Nothing
  68908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68909. */
  68910. static readonly ACTION_NothingTrigger: number;
  68911. /**
  68912. * On pick
  68913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68914. */
  68915. static readonly ACTION_OnPickTrigger: number;
  68916. /**
  68917. * On left pick
  68918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68919. */
  68920. static readonly ACTION_OnLeftPickTrigger: number;
  68921. /**
  68922. * On right pick
  68923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68924. */
  68925. static readonly ACTION_OnRightPickTrigger: number;
  68926. /**
  68927. * On center pick
  68928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68929. */
  68930. static readonly ACTION_OnCenterPickTrigger: number;
  68931. /**
  68932. * On pick down
  68933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68934. */
  68935. static readonly ACTION_OnPickDownTrigger: number;
  68936. /**
  68937. * On double pick
  68938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68939. */
  68940. static readonly ACTION_OnDoublePickTrigger: number;
  68941. /**
  68942. * On pick up
  68943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68944. */
  68945. static readonly ACTION_OnPickUpTrigger: number;
  68946. /**
  68947. * On pick out.
  68948. * This trigger will only be raised if you also declared a OnPickDown
  68949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68950. */
  68951. static readonly ACTION_OnPickOutTrigger: number;
  68952. /**
  68953. * On long press
  68954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68955. */
  68956. static readonly ACTION_OnLongPressTrigger: number;
  68957. /**
  68958. * On pointer over
  68959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68960. */
  68961. static readonly ACTION_OnPointerOverTrigger: number;
  68962. /**
  68963. * On pointer out
  68964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68965. */
  68966. static readonly ACTION_OnPointerOutTrigger: number;
  68967. /**
  68968. * On every frame
  68969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68970. */
  68971. static readonly ACTION_OnEveryFrameTrigger: number;
  68972. /**
  68973. * On intersection enter
  68974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68975. */
  68976. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68977. /**
  68978. * On intersection exit
  68979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68980. */
  68981. static readonly ACTION_OnIntersectionExitTrigger: number;
  68982. /**
  68983. * On key down
  68984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68985. */
  68986. static readonly ACTION_OnKeyDownTrigger: number;
  68987. /**
  68988. * On key up
  68989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68990. */
  68991. static readonly ACTION_OnKeyUpTrigger: number;
  68992. /**
  68993. * Billboard mode will only apply to Y axis
  68994. */
  68995. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68996. /**
  68997. * Billboard mode will apply to all axes
  68998. */
  68999. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69000. /**
  69001. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69002. */
  69003. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69004. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69005. * Test order :
  69006. * Is the bounding sphere outside the frustum ?
  69007. * If not, are the bounding box vertices outside the frustum ?
  69008. * It not, then the cullable object is in the frustum.
  69009. */
  69010. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69011. /** Culling strategy : Bounding Sphere Only.
  69012. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69013. * It's also less accurate than the standard because some not visible objects can still be selected.
  69014. * Test : is the bounding sphere outside the frustum ?
  69015. * If not, then the cullable object is in the frustum.
  69016. */
  69017. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69018. /** Culling strategy : Optimistic Inclusion.
  69019. * This in an inclusion test first, then the standard exclusion test.
  69020. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69021. * 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.
  69022. * Anyway, it's as accurate as the standard strategy.
  69023. * Test :
  69024. * Is the cullable object bounding sphere center in the frustum ?
  69025. * If not, apply the default culling strategy.
  69026. */
  69027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69028. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69029. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69030. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69031. * 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.
  69032. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69033. * Test :
  69034. * Is the cullable object bounding sphere center in the frustum ?
  69035. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69036. */
  69037. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69038. /**
  69039. * No logging while loading
  69040. */
  69041. static readonly SCENELOADER_NO_LOGGING: number;
  69042. /**
  69043. * Minimal logging while loading
  69044. */
  69045. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69046. /**
  69047. * Summary logging while loading
  69048. */
  69049. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69050. /**
  69051. * Detailled logging while loading
  69052. */
  69053. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69054. }
  69055. }
  69056. declare module BABYLON {
  69057. /**
  69058. * This represents the required contract to create a new type of texture loader.
  69059. */
  69060. export interface IInternalTextureLoader {
  69061. /**
  69062. * Defines wether the loader supports cascade loading the different faces.
  69063. */
  69064. supportCascades: boolean;
  69065. /**
  69066. * This returns if the loader support the current file information.
  69067. * @param extension defines the file extension of the file being loaded
  69068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69069. * @param fallback defines the fallback internal texture if any
  69070. * @param isBase64 defines whether the texture is encoded as a base64
  69071. * @param isBuffer defines whether the texture data are stored as a buffer
  69072. * @returns true if the loader can load the specified file
  69073. */
  69074. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69075. /**
  69076. * Transform the url before loading if required.
  69077. * @param rootUrl the url of the texture
  69078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69079. * @returns the transformed texture
  69080. */
  69081. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69082. /**
  69083. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69084. * @param rootUrl the url of the texture
  69085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69086. * @returns the fallback texture
  69087. */
  69088. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69089. /**
  69090. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69091. * @param data contains the texture data
  69092. * @param texture defines the BabylonJS internal texture
  69093. * @param createPolynomials will be true if polynomials have been requested
  69094. * @param onLoad defines the callback to trigger once the texture is ready
  69095. * @param onError defines the callback to trigger in case of error
  69096. */
  69097. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69098. /**
  69099. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69100. * @param data contains the texture data
  69101. * @param texture defines the BabylonJS internal texture
  69102. * @param callback defines the method to call once ready to upload
  69103. */
  69104. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69105. }
  69106. }
  69107. declare module BABYLON {
  69108. /**
  69109. * Class used to store and describe the pipeline context associated with an effect
  69110. */
  69111. export interface IPipelineContext {
  69112. /**
  69113. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69114. */
  69115. isAsync: boolean;
  69116. /**
  69117. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69118. */
  69119. isReady: boolean;
  69120. /** @hidden */
  69121. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69122. }
  69123. }
  69124. declare module BABYLON {
  69125. /**
  69126. * Class used to store gfx data (like WebGLBuffer)
  69127. */
  69128. export class DataBuffer {
  69129. /**
  69130. * Gets or sets the number of objects referencing this buffer
  69131. */
  69132. references: number;
  69133. /** Gets or sets the size of the underlying buffer */
  69134. capacity: number;
  69135. /**
  69136. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69137. */
  69138. is32Bits: boolean;
  69139. /**
  69140. * Gets the underlying buffer
  69141. */
  69142. readonly underlyingResource: any;
  69143. }
  69144. }
  69145. declare module BABYLON {
  69146. /** @hidden */
  69147. export interface IShaderProcessor {
  69148. attributeProcessor?: (attribute: string) => string;
  69149. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69150. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69151. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69152. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69153. lineProcessor?: (line: string, isFragment: boolean) => string;
  69154. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69155. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69156. }
  69157. }
  69158. declare module BABYLON {
  69159. /** @hidden */
  69160. export interface ProcessingOptions {
  69161. defines: string[];
  69162. indexParameters: any;
  69163. isFragment: boolean;
  69164. shouldUseHighPrecisionShader: boolean;
  69165. supportsUniformBuffers: boolean;
  69166. shadersRepository: string;
  69167. includesShadersStore: {
  69168. [key: string]: string;
  69169. };
  69170. processor?: IShaderProcessor;
  69171. version: string;
  69172. platformName: string;
  69173. lookForClosingBracketForUniformBuffer?: boolean;
  69174. }
  69175. }
  69176. declare module BABYLON {
  69177. /** @hidden */
  69178. export class ShaderCodeNode {
  69179. line: string;
  69180. children: ShaderCodeNode[];
  69181. additionalDefineKey?: string;
  69182. additionalDefineValue?: string;
  69183. isValid(preprocessors: {
  69184. [key: string]: string;
  69185. }): boolean;
  69186. process(preprocessors: {
  69187. [key: string]: string;
  69188. }, options: ProcessingOptions): string;
  69189. }
  69190. }
  69191. declare module BABYLON {
  69192. /** @hidden */
  69193. export class ShaderCodeCursor {
  69194. private _lines;
  69195. lineIndex: number;
  69196. readonly currentLine: string;
  69197. readonly canRead: boolean;
  69198. lines: string[];
  69199. }
  69200. }
  69201. declare module BABYLON {
  69202. /** @hidden */
  69203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69204. process(preprocessors: {
  69205. [key: string]: string;
  69206. }, options: ProcessingOptions): string;
  69207. }
  69208. }
  69209. declare module BABYLON {
  69210. /** @hidden */
  69211. export class ShaderDefineExpression {
  69212. isTrue(preprocessors: {
  69213. [key: string]: string;
  69214. }): boolean;
  69215. }
  69216. }
  69217. declare module BABYLON {
  69218. /** @hidden */
  69219. export class ShaderCodeTestNode extends ShaderCodeNode {
  69220. testExpression: ShaderDefineExpression;
  69221. isValid(preprocessors: {
  69222. [key: string]: string;
  69223. }): boolean;
  69224. }
  69225. }
  69226. declare module BABYLON {
  69227. /** @hidden */
  69228. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69229. define: string;
  69230. not: boolean;
  69231. constructor(define: string, not?: boolean);
  69232. isTrue(preprocessors: {
  69233. [key: string]: string;
  69234. }): boolean;
  69235. }
  69236. }
  69237. declare module BABYLON {
  69238. /** @hidden */
  69239. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69240. leftOperand: ShaderDefineExpression;
  69241. rightOperand: ShaderDefineExpression;
  69242. isTrue(preprocessors: {
  69243. [key: string]: string;
  69244. }): boolean;
  69245. }
  69246. }
  69247. declare module BABYLON {
  69248. /** @hidden */
  69249. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69250. leftOperand: ShaderDefineExpression;
  69251. rightOperand: ShaderDefineExpression;
  69252. isTrue(preprocessors: {
  69253. [key: string]: string;
  69254. }): boolean;
  69255. }
  69256. }
  69257. declare module BABYLON {
  69258. /** @hidden */
  69259. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69260. define: string;
  69261. operand: string;
  69262. testValue: string;
  69263. constructor(define: string, operand: string, testValue: string);
  69264. isTrue(preprocessors: {
  69265. [key: string]: string;
  69266. }): boolean;
  69267. }
  69268. }
  69269. declare module BABYLON {
  69270. /**
  69271. * Class used to enable access to offline support
  69272. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69273. */
  69274. export interface IOfflineProvider {
  69275. /**
  69276. * Gets a boolean indicating if scene must be saved in the database
  69277. */
  69278. enableSceneOffline: boolean;
  69279. /**
  69280. * Gets a boolean indicating if textures must be saved in the database
  69281. */
  69282. enableTexturesOffline: boolean;
  69283. /**
  69284. * Open the offline support and make it available
  69285. * @param successCallback defines the callback to call on success
  69286. * @param errorCallback defines the callback to call on error
  69287. */
  69288. open(successCallback: () => void, errorCallback: () => void): void;
  69289. /**
  69290. * Loads an image from the offline support
  69291. * @param url defines the url to load from
  69292. * @param image defines the target DOM image
  69293. */
  69294. loadImage(url: string, image: HTMLImageElement): void;
  69295. /**
  69296. * Loads a file from offline support
  69297. * @param url defines the URL to load from
  69298. * @param sceneLoaded defines a callback to call on success
  69299. * @param progressCallBack defines a callback to call when progress changed
  69300. * @param errorCallback defines a callback to call on error
  69301. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69302. */
  69303. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69304. }
  69305. }
  69306. declare module BABYLON {
  69307. /**
  69308. * Class used to help managing file picking and drag'n'drop
  69309. * File Storage
  69310. */
  69311. export class FilesInputStore {
  69312. /**
  69313. * List of files ready to be loaded
  69314. */
  69315. static FilesToLoad: {
  69316. [key: string]: File;
  69317. };
  69318. }
  69319. }
  69320. declare module BABYLON {
  69321. /**
  69322. * Class used to define a retry strategy when error happens while loading assets
  69323. */
  69324. export class RetryStrategy {
  69325. /**
  69326. * Function used to defines an exponential back off strategy
  69327. * @param maxRetries defines the maximum number of retries (3 by default)
  69328. * @param baseInterval defines the interval between retries
  69329. * @returns the strategy function to use
  69330. */
  69331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69332. }
  69333. }
  69334. declare module BABYLON {
  69335. /**
  69336. * @ignore
  69337. * Application error to support additional information when loading a file
  69338. */
  69339. export abstract class BaseError extends Error {
  69340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69341. }
  69342. }
  69343. declare module BABYLON {
  69344. /** @ignore */
  69345. export class LoadFileError extends BaseError {
  69346. request?: WebRequest;
  69347. file?: File;
  69348. /**
  69349. * Creates a new LoadFileError
  69350. * @param message defines the message of the error
  69351. * @param request defines the optional web request
  69352. * @param file defines the optional file
  69353. */
  69354. constructor(message: string, object?: WebRequest | File);
  69355. }
  69356. /** @ignore */
  69357. export class RequestFileError extends BaseError {
  69358. request: WebRequest;
  69359. /**
  69360. * Creates a new LoadFileError
  69361. * @param message defines the message of the error
  69362. * @param request defines the optional web request
  69363. */
  69364. constructor(message: string, request: WebRequest);
  69365. }
  69366. /** @ignore */
  69367. export class ReadFileError extends BaseError {
  69368. file: File;
  69369. /**
  69370. * Creates a new ReadFileError
  69371. * @param message defines the message of the error
  69372. * @param file defines the optional file
  69373. */
  69374. constructor(message: string, file: File);
  69375. }
  69376. /**
  69377. * @hidden
  69378. */
  69379. export class FileTools {
  69380. /**
  69381. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69382. */
  69383. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69384. /**
  69385. * Gets or sets the base URL to use to load assets
  69386. */
  69387. static BaseUrl: string;
  69388. /**
  69389. * Default behaviour for cors in the application.
  69390. * It can be a string if the expected behavior is identical in the entire app.
  69391. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69392. */
  69393. static CorsBehavior: string | ((url: string | string[]) => string);
  69394. /**
  69395. * Gets or sets a function used to pre-process url before using them to load assets
  69396. */
  69397. static PreprocessUrl: (url: string) => string;
  69398. /**
  69399. * Removes unwanted characters from an url
  69400. * @param url defines the url to clean
  69401. * @returns the cleaned url
  69402. */
  69403. private static _CleanUrl;
  69404. /**
  69405. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69406. * @param url define the url we are trying
  69407. * @param element define the dom element where to configure the cors policy
  69408. */
  69409. static SetCorsBehavior(url: string | string[], element: {
  69410. crossOrigin: string | null;
  69411. }): void;
  69412. /**
  69413. * Loads an image as an HTMLImageElement.
  69414. * @param input url string, ArrayBuffer, or Blob to load
  69415. * @param onLoad callback called when the image successfully loads
  69416. * @param onError callback called when the image fails to load
  69417. * @param offlineProvider offline provider for caching
  69418. * @param mimeType optional mime type
  69419. * @returns the HTMLImageElement of the loaded image
  69420. */
  69421. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  69422. /**
  69423. * Reads a file from a File object
  69424. * @param file defines the file to load
  69425. * @param onSuccess defines the callback to call when data is loaded
  69426. * @param onProgress defines the callback to call during loading process
  69427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69428. * @param onError defines the callback to call when an error occurs
  69429. * @returns a file request object
  69430. */
  69431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69432. /**
  69433. * Loads a file from a url
  69434. * @param url url to load
  69435. * @param onSuccess callback called when the file successfully loads
  69436. * @param onProgress callback called while file is loading (if the server supports this mode)
  69437. * @param offlineProvider defines the offline provider for caching
  69438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69439. * @param onError callback called when the file fails to load
  69440. * @returns a file request object
  69441. */
  69442. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  69443. /**
  69444. * Loads a file
  69445. * @param url url to load
  69446. * @param onSuccess callback called when the file successfully loads
  69447. * @param onProgress callback called while file is loading (if the server supports this mode)
  69448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69449. * @param onError callback called when the file fails to load
  69450. * @param onOpened callback called when the web request is opened
  69451. * @returns a file request object
  69452. */
  69453. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  69454. /**
  69455. * Checks if the loaded document was accessed via `file:`-Protocol.
  69456. * @returns boolean
  69457. */
  69458. static IsFileURL(): boolean;
  69459. }
  69460. }
  69461. declare module BABYLON {
  69462. /** @hidden */
  69463. export class ShaderProcessor {
  69464. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69465. private static _ProcessPrecision;
  69466. private static _ExtractOperation;
  69467. private static _BuildSubExpression;
  69468. private static _BuildExpression;
  69469. private static _MoveCursorWithinIf;
  69470. private static _MoveCursor;
  69471. private static _EvaluatePreProcessors;
  69472. private static _PreparePreProcessors;
  69473. private static _ProcessShaderConversion;
  69474. private static _ProcessIncludes;
  69475. }
  69476. }
  69477. declare module BABYLON {
  69478. /**
  69479. * @hidden
  69480. */
  69481. export interface IColor4Like {
  69482. r: float;
  69483. g: float;
  69484. b: float;
  69485. a: float;
  69486. }
  69487. /**
  69488. * @hidden
  69489. */
  69490. export interface IColor3Like {
  69491. r: float;
  69492. g: float;
  69493. b: float;
  69494. }
  69495. /**
  69496. * @hidden
  69497. */
  69498. export interface IVector4Like {
  69499. x: float;
  69500. y: float;
  69501. z: float;
  69502. w: float;
  69503. }
  69504. /**
  69505. * @hidden
  69506. */
  69507. export interface IVector3Like {
  69508. x: float;
  69509. y: float;
  69510. z: float;
  69511. }
  69512. /**
  69513. * @hidden
  69514. */
  69515. export interface IVector2Like {
  69516. x: float;
  69517. y: float;
  69518. }
  69519. /**
  69520. * @hidden
  69521. */
  69522. export interface IMatrixLike {
  69523. toArray(): DeepImmutable<Float32Array>;
  69524. updateFlag: int;
  69525. }
  69526. /**
  69527. * @hidden
  69528. */
  69529. export interface IViewportLike {
  69530. x: float;
  69531. y: float;
  69532. width: float;
  69533. height: float;
  69534. }
  69535. /**
  69536. * @hidden
  69537. */
  69538. export interface IPlaneLike {
  69539. normal: IVector3Like;
  69540. d: float;
  69541. normalize(): void;
  69542. }
  69543. }
  69544. declare module BABYLON {
  69545. /**
  69546. * Interface used to define common properties for effect fallbacks
  69547. */
  69548. export interface IEffectFallbacks {
  69549. /**
  69550. * Removes the defines that should be removed when falling back.
  69551. * @param currentDefines defines the current define statements for the shader.
  69552. * @param effect defines the current effect we try to compile
  69553. * @returns The resulting defines with defines of the current rank removed.
  69554. */
  69555. reduce(currentDefines: string, effect: Effect): string;
  69556. /**
  69557. * Removes the fallback from the bound mesh.
  69558. */
  69559. unBindMesh(): void;
  69560. /**
  69561. * Checks to see if more fallbacks are still availible.
  69562. */
  69563. hasMoreFallbacks: boolean;
  69564. }
  69565. }
  69566. declare module BABYLON {
  69567. /**
  69568. * Class used to evalaute queries containing `and` and `or` operators
  69569. */
  69570. export class AndOrNotEvaluator {
  69571. /**
  69572. * Evaluate a query
  69573. * @param query defines the query to evaluate
  69574. * @param evaluateCallback defines the callback used to filter result
  69575. * @returns true if the query matches
  69576. */
  69577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69578. private static _HandleParenthesisContent;
  69579. private static _SimplifyNegation;
  69580. }
  69581. }
  69582. declare module BABYLON {
  69583. /**
  69584. * Class used to store custom tags
  69585. */
  69586. export class Tags {
  69587. /**
  69588. * Adds support for tags on the given object
  69589. * @param obj defines the object to use
  69590. */
  69591. static EnableFor(obj: any): void;
  69592. /**
  69593. * Removes tags support
  69594. * @param obj defines the object to use
  69595. */
  69596. static DisableFor(obj: any): void;
  69597. /**
  69598. * Gets a boolean indicating if the given object has tags
  69599. * @param obj defines the object to use
  69600. * @returns a boolean
  69601. */
  69602. static HasTags(obj: any): boolean;
  69603. /**
  69604. * Gets the tags available on a given object
  69605. * @param obj defines the object to use
  69606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69607. * @returns the tags
  69608. */
  69609. static GetTags(obj: any, asString?: boolean): any;
  69610. /**
  69611. * Adds tags to an object
  69612. * @param obj defines the object to use
  69613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69615. */
  69616. static AddTagsTo(obj: any, tagsString: string): void;
  69617. /**
  69618. * @hidden
  69619. */
  69620. static _AddTagTo(obj: any, tag: string): void;
  69621. /**
  69622. * Removes specific tags from a specific object
  69623. * @param obj defines the object to use
  69624. * @param tagsString defines the tags to remove
  69625. */
  69626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69627. /**
  69628. * @hidden
  69629. */
  69630. static _RemoveTagFrom(obj: any, tag: string): void;
  69631. /**
  69632. * Defines if tags hosted on an object match a given query
  69633. * @param obj defines the object to use
  69634. * @param tagsQuery defines the tag query
  69635. * @returns a boolean
  69636. */
  69637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69638. }
  69639. }
  69640. declare module BABYLON {
  69641. /**
  69642. * Scalar computation library
  69643. */
  69644. export class Scalar {
  69645. /**
  69646. * Two pi constants convenient for computation.
  69647. */
  69648. static TwoPi: number;
  69649. /**
  69650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69651. * @param a number
  69652. * @param b number
  69653. * @param epsilon (default = 1.401298E-45)
  69654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69655. */
  69656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69657. /**
  69658. * Returns a string : the upper case translation of the number i to hexadecimal.
  69659. * @param i number
  69660. * @returns the upper case translation of the number i to hexadecimal.
  69661. */
  69662. static ToHex(i: number): string;
  69663. /**
  69664. * Returns -1 if value is negative and +1 is value is positive.
  69665. * @param value the value
  69666. * @returns the value itself if it's equal to zero.
  69667. */
  69668. static Sign(value: number): number;
  69669. /**
  69670. * Returns the value itself if it's between min and max.
  69671. * Returns min if the value is lower than min.
  69672. * Returns max if the value is greater than max.
  69673. * @param value the value to clmap
  69674. * @param min the min value to clamp to (default: 0)
  69675. * @param max the max value to clamp to (default: 1)
  69676. * @returns the clamped value
  69677. */
  69678. static Clamp(value: number, min?: number, max?: number): number;
  69679. /**
  69680. * the log2 of value.
  69681. * @param value the value to compute log2 of
  69682. * @returns the log2 of value.
  69683. */
  69684. static Log2(value: number): number;
  69685. /**
  69686. * Loops the value, so that it is never larger than length and never smaller than 0.
  69687. *
  69688. * This is similar to the modulo operator but it works with floating point numbers.
  69689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69690. * With t = 5 and length = 2.5, the result would be 0.0.
  69691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69692. * @param value the value
  69693. * @param length the length
  69694. * @returns the looped value
  69695. */
  69696. static Repeat(value: number, length: number): number;
  69697. /**
  69698. * Normalize the value between 0.0 and 1.0 using min and max values
  69699. * @param value value to normalize
  69700. * @param min max to normalize between
  69701. * @param max min to normalize between
  69702. * @returns the normalized value
  69703. */
  69704. static Normalize(value: number, min: number, max: number): number;
  69705. /**
  69706. * Denormalize the value from 0.0 and 1.0 using min and max values
  69707. * @param normalized value to denormalize
  69708. * @param min max to denormalize between
  69709. * @param max min to denormalize between
  69710. * @returns the denormalized value
  69711. */
  69712. static Denormalize(normalized: number, min: number, max: number): number;
  69713. /**
  69714. * Calculates the shortest difference between two given angles given in degrees.
  69715. * @param current current angle in degrees
  69716. * @param target target angle in degrees
  69717. * @returns the delta
  69718. */
  69719. static DeltaAngle(current: number, target: number): number;
  69720. /**
  69721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69722. * @param tx value
  69723. * @param length length
  69724. * @returns The returned value will move back and forth between 0 and length
  69725. */
  69726. static PingPong(tx: number, length: number): number;
  69727. /**
  69728. * Interpolates between min and max with smoothing at the limits.
  69729. *
  69730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69732. * @param from from
  69733. * @param to to
  69734. * @param tx value
  69735. * @returns the smooth stepped value
  69736. */
  69737. static SmoothStep(from: number, to: number, tx: number): number;
  69738. /**
  69739. * Moves a value current towards target.
  69740. *
  69741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69742. * Negative values of maxDelta pushes the value away from target.
  69743. * @param current current value
  69744. * @param target target value
  69745. * @param maxDelta max distance to move
  69746. * @returns resulting value
  69747. */
  69748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69749. /**
  69750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69751. *
  69752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69754. * @param current current value
  69755. * @param target target value
  69756. * @param maxDelta max distance to move
  69757. * @returns resulting angle
  69758. */
  69759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69760. /**
  69761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69762. * @param start start value
  69763. * @param end target value
  69764. * @param amount amount to lerp between
  69765. * @returns the lerped value
  69766. */
  69767. static Lerp(start: number, end: number, amount: number): number;
  69768. /**
  69769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69771. * @param start start value
  69772. * @param end target value
  69773. * @param amount amount to lerp between
  69774. * @returns the lerped value
  69775. */
  69776. static LerpAngle(start: number, end: number, amount: number): number;
  69777. /**
  69778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69779. * @param a start value
  69780. * @param b target value
  69781. * @param value value between a and b
  69782. * @returns the inverseLerp value
  69783. */
  69784. static InverseLerp(a: number, b: number, value: number): number;
  69785. /**
  69786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69788. * @param value1 spline value
  69789. * @param tangent1 spline value
  69790. * @param value2 spline value
  69791. * @param tangent2 spline value
  69792. * @param amount input value
  69793. * @returns hermite result
  69794. */
  69795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69796. /**
  69797. * Returns a random float number between and min and max values
  69798. * @param min min value of random
  69799. * @param max max value of random
  69800. * @returns random value
  69801. */
  69802. static RandomRange(min: number, max: number): number;
  69803. /**
  69804. * This function returns percentage of a number in a given range.
  69805. *
  69806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69808. * @param number to convert to percentage
  69809. * @param min min range
  69810. * @param max max range
  69811. * @returns the percentage
  69812. */
  69813. static RangeToPercent(number: number, min: number, max: number): number;
  69814. /**
  69815. * This function returns number that corresponds to the percentage in a given range.
  69816. *
  69817. * PercentToRange(0.34,0,100) will return 34.
  69818. * @param percent to convert to number
  69819. * @param min min range
  69820. * @param max max range
  69821. * @returns the number
  69822. */
  69823. static PercentToRange(percent: number, min: number, max: number): number;
  69824. /**
  69825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69826. * @param angle The angle to normalize in radian.
  69827. * @return The converted angle.
  69828. */
  69829. static NormalizeRadians(angle: number): number;
  69830. }
  69831. }
  69832. declare module BABYLON {
  69833. /**
  69834. * Constant used to convert a value to gamma space
  69835. * @ignorenaming
  69836. */
  69837. export const ToGammaSpace: number;
  69838. /**
  69839. * Constant used to convert a value to linear space
  69840. * @ignorenaming
  69841. */
  69842. export const ToLinearSpace = 2.2;
  69843. /**
  69844. * Constant used to define the minimal number value in Babylon.js
  69845. * @ignorenaming
  69846. */
  69847. let Epsilon: number;
  69848. }
  69849. declare module BABYLON {
  69850. /**
  69851. * Class used to represent a viewport on screen
  69852. */
  69853. export class Viewport {
  69854. /** viewport left coordinate */
  69855. x: number;
  69856. /** viewport top coordinate */
  69857. y: number;
  69858. /**viewport width */
  69859. width: number;
  69860. /** viewport height */
  69861. height: number;
  69862. /**
  69863. * Creates a Viewport object located at (x, y) and sized (width, height)
  69864. * @param x defines viewport left coordinate
  69865. * @param y defines viewport top coordinate
  69866. * @param width defines the viewport width
  69867. * @param height defines the viewport height
  69868. */
  69869. constructor(
  69870. /** viewport left coordinate */
  69871. x: number,
  69872. /** viewport top coordinate */
  69873. y: number,
  69874. /**viewport width */
  69875. width: number,
  69876. /** viewport height */
  69877. height: number);
  69878. /**
  69879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69880. * @param renderWidth defines the rendering width
  69881. * @param renderHeight defines the rendering height
  69882. * @returns a new Viewport
  69883. */
  69884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69885. /**
  69886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69887. * @param renderWidth defines the rendering width
  69888. * @param renderHeight defines the rendering height
  69889. * @param ref defines the target viewport
  69890. * @returns the current viewport
  69891. */
  69892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69893. /**
  69894. * Returns a new Viewport copied from the current one
  69895. * @returns a new Viewport
  69896. */
  69897. clone(): Viewport;
  69898. }
  69899. }
  69900. declare module BABYLON {
  69901. /**
  69902. * Class containing a set of static utilities functions for arrays.
  69903. */
  69904. export class ArrayTools {
  69905. /**
  69906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69907. * @param size the number of element to construct and put in the array
  69908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69909. * @returns a new array filled with new objects
  69910. */
  69911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69912. }
  69913. }
  69914. declare module BABYLON {
  69915. /**
  69916. * Class representing a vector containing 2 coordinates
  69917. */
  69918. export class Vector2 {
  69919. /** defines the first coordinate */
  69920. x: number;
  69921. /** defines the second coordinate */
  69922. y: number;
  69923. /**
  69924. * Creates a new Vector2 from the given x and y coordinates
  69925. * @param x defines the first coordinate
  69926. * @param y defines the second coordinate
  69927. */
  69928. constructor(
  69929. /** defines the first coordinate */
  69930. x?: number,
  69931. /** defines the second coordinate */
  69932. y?: number);
  69933. /**
  69934. * Gets a string with the Vector2 coordinates
  69935. * @returns a string with the Vector2 coordinates
  69936. */
  69937. toString(): string;
  69938. /**
  69939. * Gets class name
  69940. * @returns the string "Vector2"
  69941. */
  69942. getClassName(): string;
  69943. /**
  69944. * Gets current vector hash code
  69945. * @returns the Vector2 hash code as a number
  69946. */
  69947. getHashCode(): number;
  69948. /**
  69949. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69950. * @param array defines the source array
  69951. * @param index defines the offset in source array
  69952. * @returns the current Vector2
  69953. */
  69954. toArray(array: FloatArray, index?: number): Vector2;
  69955. /**
  69956. * Copy the current vector to an array
  69957. * @returns a new array with 2 elements: the Vector2 coordinates.
  69958. */
  69959. asArray(): number[];
  69960. /**
  69961. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69962. * @param source defines the source Vector2
  69963. * @returns the current updated Vector2
  69964. */
  69965. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69966. /**
  69967. * Sets the Vector2 coordinates with the given floats
  69968. * @param x defines the first coordinate
  69969. * @param y defines the second coordinate
  69970. * @returns the current updated Vector2
  69971. */
  69972. copyFromFloats(x: number, y: number): Vector2;
  69973. /**
  69974. * Sets the Vector2 coordinates with the given floats
  69975. * @param x defines the first coordinate
  69976. * @param y defines the second coordinate
  69977. * @returns the current updated Vector2
  69978. */
  69979. set(x: number, y: number): Vector2;
  69980. /**
  69981. * Add another vector with the current one
  69982. * @param otherVector defines the other vector
  69983. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69984. */
  69985. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69986. /**
  69987. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69988. * @param otherVector defines the other vector
  69989. * @param result defines the target vector
  69990. * @returns the unmodified current Vector2
  69991. */
  69992. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69993. /**
  69994. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69995. * @param otherVector defines the other vector
  69996. * @returns the current updated Vector2
  69997. */
  69998. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69999. /**
  70000. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70001. * @param otherVector defines the other vector
  70002. * @returns a new Vector2
  70003. */
  70004. addVector3(otherVector: Vector3): Vector2;
  70005. /**
  70006. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70007. * @param otherVector defines the other vector
  70008. * @returns a new Vector2
  70009. */
  70010. subtract(otherVector: Vector2): Vector2;
  70011. /**
  70012. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70013. * @param otherVector defines the other vector
  70014. * @param result defines the target vector
  70015. * @returns the unmodified current Vector2
  70016. */
  70017. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70018. /**
  70019. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70020. * @param otherVector defines the other vector
  70021. * @returns the current updated Vector2
  70022. */
  70023. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70024. /**
  70025. * Multiplies in place the current Vector2 coordinates by the given ones
  70026. * @param otherVector defines the other vector
  70027. * @returns the current updated Vector2
  70028. */
  70029. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70030. /**
  70031. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70032. * @param otherVector defines the other vector
  70033. * @returns a new Vector2
  70034. */
  70035. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70036. /**
  70037. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70038. * @param otherVector defines the other vector
  70039. * @param result defines the target vector
  70040. * @returns the unmodified current Vector2
  70041. */
  70042. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70043. /**
  70044. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70045. * @param x defines the first coordinate
  70046. * @param y defines the second coordinate
  70047. * @returns a new Vector2
  70048. */
  70049. multiplyByFloats(x: number, y: number): Vector2;
  70050. /**
  70051. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70052. * @param otherVector defines the other vector
  70053. * @returns a new Vector2
  70054. */
  70055. divide(otherVector: Vector2): Vector2;
  70056. /**
  70057. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70058. * @param otherVector defines the other vector
  70059. * @param result defines the target vector
  70060. * @returns the unmodified current Vector2
  70061. */
  70062. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70063. /**
  70064. * Divides the current Vector2 coordinates by the given ones
  70065. * @param otherVector defines the other vector
  70066. * @returns the current updated Vector2
  70067. */
  70068. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70069. /**
  70070. * Gets a new Vector2 with current Vector2 negated coordinates
  70071. * @returns a new Vector2
  70072. */
  70073. negate(): Vector2;
  70074. /**
  70075. * Multiply the Vector2 coordinates by scale
  70076. * @param scale defines the scaling factor
  70077. * @returns the current updated Vector2
  70078. */
  70079. scaleInPlace(scale: number): Vector2;
  70080. /**
  70081. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70082. * @param scale defines the scaling factor
  70083. * @returns a new Vector2
  70084. */
  70085. scale(scale: number): Vector2;
  70086. /**
  70087. * Scale the current Vector2 values by a factor to a given Vector2
  70088. * @param scale defines the scale factor
  70089. * @param result defines the Vector2 object where to store the result
  70090. * @returns the unmodified current Vector2
  70091. */
  70092. scaleToRef(scale: number, result: Vector2): Vector2;
  70093. /**
  70094. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70095. * @param scale defines the scale factor
  70096. * @param result defines the Vector2 object where to store the result
  70097. * @returns the unmodified current Vector2
  70098. */
  70099. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70100. /**
  70101. * Gets a boolean if two vectors are equals
  70102. * @param otherVector defines the other vector
  70103. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70104. */
  70105. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70106. /**
  70107. * Gets a boolean if two vectors are equals (using an epsilon value)
  70108. * @param otherVector defines the other vector
  70109. * @param epsilon defines the minimal distance to consider equality
  70110. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70111. */
  70112. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70113. /**
  70114. * Gets a new Vector2 from current Vector2 floored values
  70115. * @returns a new Vector2
  70116. */
  70117. floor(): Vector2;
  70118. /**
  70119. * Gets a new Vector2 from current Vector2 floored values
  70120. * @returns a new Vector2
  70121. */
  70122. fract(): Vector2;
  70123. /**
  70124. * Gets the length of the vector
  70125. * @returns the vector length (float)
  70126. */
  70127. length(): number;
  70128. /**
  70129. * Gets the vector squared length
  70130. * @returns the vector squared length (float)
  70131. */
  70132. lengthSquared(): number;
  70133. /**
  70134. * Normalize the vector
  70135. * @returns the current updated Vector2
  70136. */
  70137. normalize(): Vector2;
  70138. /**
  70139. * Gets a new Vector2 copied from the Vector2
  70140. * @returns a new Vector2
  70141. */
  70142. clone(): Vector2;
  70143. /**
  70144. * Gets a new Vector2(0, 0)
  70145. * @returns a new Vector2
  70146. */
  70147. static Zero(): Vector2;
  70148. /**
  70149. * Gets a new Vector2(1, 1)
  70150. * @returns a new Vector2
  70151. */
  70152. static One(): Vector2;
  70153. /**
  70154. * Gets a new Vector2 set from the given index element of the given array
  70155. * @param array defines the data source
  70156. * @param offset defines the offset in the data source
  70157. * @returns a new Vector2
  70158. */
  70159. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70160. /**
  70161. * Sets "result" from the given index element of the given array
  70162. * @param array defines the data source
  70163. * @param offset defines the offset in the data source
  70164. * @param result defines the target vector
  70165. */
  70166. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70167. /**
  70168. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70169. * @param value1 defines 1st point of control
  70170. * @param value2 defines 2nd point of control
  70171. * @param value3 defines 3rd point of control
  70172. * @param value4 defines 4th point of control
  70173. * @param amount defines the interpolation factor
  70174. * @returns a new Vector2
  70175. */
  70176. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70177. /**
  70178. * 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".
  70179. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70180. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70181. * @param value defines the value to clamp
  70182. * @param min defines the lower limit
  70183. * @param max defines the upper limit
  70184. * @returns a new Vector2
  70185. */
  70186. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70187. /**
  70188. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70189. * @param value1 defines the 1st control point
  70190. * @param tangent1 defines the outgoing tangent
  70191. * @param value2 defines the 2nd control point
  70192. * @param tangent2 defines the incoming tangent
  70193. * @param amount defines the interpolation factor
  70194. * @returns a new Vector2
  70195. */
  70196. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70197. /**
  70198. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70199. * @param start defines the start vector
  70200. * @param end defines the end vector
  70201. * @param amount defines the interpolation factor
  70202. * @returns a new Vector2
  70203. */
  70204. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70205. /**
  70206. * Gets the dot product of the vector "left" and the vector "right"
  70207. * @param left defines first vector
  70208. * @param right defines second vector
  70209. * @returns the dot product (float)
  70210. */
  70211. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70212. /**
  70213. * Returns a new Vector2 equal to the normalized given vector
  70214. * @param vector defines the vector to normalize
  70215. * @returns a new Vector2
  70216. */
  70217. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70218. /**
  70219. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70220. * @param left defines 1st vector
  70221. * @param right defines 2nd vector
  70222. * @returns a new Vector2
  70223. */
  70224. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70225. /**
  70226. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70227. * @param left defines 1st vector
  70228. * @param right defines 2nd vector
  70229. * @returns a new Vector2
  70230. */
  70231. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70232. /**
  70233. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70234. * @param vector defines the vector to transform
  70235. * @param transformation defines the matrix to apply
  70236. * @returns a new Vector2
  70237. */
  70238. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70239. /**
  70240. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70241. * @param vector defines the vector to transform
  70242. * @param transformation defines the matrix to apply
  70243. * @param result defines the target vector
  70244. */
  70245. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70246. /**
  70247. * Determines if a given vector is included in a triangle
  70248. * @param p defines the vector to test
  70249. * @param p0 defines 1st triangle point
  70250. * @param p1 defines 2nd triangle point
  70251. * @param p2 defines 3rd triangle point
  70252. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70253. */
  70254. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70255. /**
  70256. * Gets the distance between the vectors "value1" and "value2"
  70257. * @param value1 defines first vector
  70258. * @param value2 defines second vector
  70259. * @returns the distance between vectors
  70260. */
  70261. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70262. /**
  70263. * Returns the squared distance between the vectors "value1" and "value2"
  70264. * @param value1 defines first vector
  70265. * @param value2 defines second vector
  70266. * @returns the squared distance between vectors
  70267. */
  70268. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70269. /**
  70270. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70271. * @param value1 defines first vector
  70272. * @param value2 defines second vector
  70273. * @returns a new Vector2
  70274. */
  70275. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70276. /**
  70277. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70278. * @param p defines the middle point
  70279. * @param segA defines one point of the segment
  70280. * @param segB defines the other point of the segment
  70281. * @returns the shortest distance
  70282. */
  70283. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70284. }
  70285. /**
  70286. * Classed used to store (x,y,z) vector representation
  70287. * A Vector3 is the main object used in 3D geometry
  70288. * It can represent etiher the coordinates of a point the space, either a direction
  70289. * Reminder: js uses a left handed forward facing system
  70290. */
  70291. export class Vector3 {
  70292. /**
  70293. * Defines the first coordinates (on X axis)
  70294. */
  70295. x: number;
  70296. /**
  70297. * Defines the second coordinates (on Y axis)
  70298. */
  70299. y: number;
  70300. /**
  70301. * Defines the third coordinates (on Z axis)
  70302. */
  70303. z: number;
  70304. private static _UpReadOnly;
  70305. private static _ZeroReadOnly;
  70306. /**
  70307. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70308. * @param x defines the first coordinates (on X axis)
  70309. * @param y defines the second coordinates (on Y axis)
  70310. * @param z defines the third coordinates (on Z axis)
  70311. */
  70312. constructor(
  70313. /**
  70314. * Defines the first coordinates (on X axis)
  70315. */
  70316. x?: number,
  70317. /**
  70318. * Defines the second coordinates (on Y axis)
  70319. */
  70320. y?: number,
  70321. /**
  70322. * Defines the third coordinates (on Z axis)
  70323. */
  70324. z?: number);
  70325. /**
  70326. * Creates a string representation of the Vector3
  70327. * @returns a string with the Vector3 coordinates.
  70328. */
  70329. toString(): string;
  70330. /**
  70331. * Gets the class name
  70332. * @returns the string "Vector3"
  70333. */
  70334. getClassName(): string;
  70335. /**
  70336. * Creates the Vector3 hash code
  70337. * @returns a number which tends to be unique between Vector3 instances
  70338. */
  70339. getHashCode(): number;
  70340. /**
  70341. * Creates an array containing three elements : the coordinates of the Vector3
  70342. * @returns a new array of numbers
  70343. */
  70344. asArray(): number[];
  70345. /**
  70346. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70347. * @param array defines the destination array
  70348. * @param index defines the offset in the destination array
  70349. * @returns the current Vector3
  70350. */
  70351. toArray(array: FloatArray, index?: number): Vector3;
  70352. /**
  70353. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70354. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70355. */
  70356. toQuaternion(): Quaternion;
  70357. /**
  70358. * Adds the given vector to the current Vector3
  70359. * @param otherVector defines the second operand
  70360. * @returns the current updated Vector3
  70361. */
  70362. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70363. /**
  70364. * Adds the given coordinates to the current Vector3
  70365. * @param x defines the x coordinate of the operand
  70366. * @param y defines the y coordinate of the operand
  70367. * @param z defines the z coordinate of the operand
  70368. * @returns the current updated Vector3
  70369. */
  70370. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70371. /**
  70372. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70373. * @param otherVector defines the second operand
  70374. * @returns the resulting Vector3
  70375. */
  70376. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70377. /**
  70378. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70379. * @param otherVector defines the second operand
  70380. * @param result defines the Vector3 object where to store the result
  70381. * @returns the current Vector3
  70382. */
  70383. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70384. /**
  70385. * Subtract the given vector from the current Vector3
  70386. * @param otherVector defines the second operand
  70387. * @returns the current updated Vector3
  70388. */
  70389. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70390. /**
  70391. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70392. * @param otherVector defines the second operand
  70393. * @returns the resulting Vector3
  70394. */
  70395. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70396. /**
  70397. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70398. * @param otherVector defines the second operand
  70399. * @param result defines the Vector3 object where to store the result
  70400. * @returns the current Vector3
  70401. */
  70402. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70403. /**
  70404. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70405. * @param x defines the x coordinate of the operand
  70406. * @param y defines the y coordinate of the operand
  70407. * @param z defines the z coordinate of the operand
  70408. * @returns the resulting Vector3
  70409. */
  70410. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70411. /**
  70412. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70413. * @param x defines the x coordinate of the operand
  70414. * @param y defines the y coordinate of the operand
  70415. * @param z defines the z coordinate of the operand
  70416. * @param result defines the Vector3 object where to store the result
  70417. * @returns the current Vector3
  70418. */
  70419. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70420. /**
  70421. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70422. * @returns a new Vector3
  70423. */
  70424. negate(): Vector3;
  70425. /**
  70426. * Multiplies the Vector3 coordinates by the float "scale"
  70427. * @param scale defines the multiplier factor
  70428. * @returns the current updated Vector3
  70429. */
  70430. scaleInPlace(scale: number): Vector3;
  70431. /**
  70432. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70433. * @param scale defines the multiplier factor
  70434. * @returns a new Vector3
  70435. */
  70436. scale(scale: number): Vector3;
  70437. /**
  70438. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70439. * @param scale defines the multiplier factor
  70440. * @param result defines the Vector3 object where to store the result
  70441. * @returns the current Vector3
  70442. */
  70443. scaleToRef(scale: number, result: Vector3): Vector3;
  70444. /**
  70445. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70446. * @param scale defines the scale factor
  70447. * @param result defines the Vector3 object where to store the result
  70448. * @returns the unmodified current Vector3
  70449. */
  70450. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70451. /**
  70452. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70453. * @param otherVector defines the second operand
  70454. * @returns true if both vectors are equals
  70455. */
  70456. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70457. /**
  70458. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70459. * @param otherVector defines the second operand
  70460. * @param epsilon defines the minimal distance to define values as equals
  70461. * @returns true if both vectors are distant less than epsilon
  70462. */
  70463. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70464. /**
  70465. * Returns true if the current Vector3 coordinates equals the given floats
  70466. * @param x defines the x coordinate of the operand
  70467. * @param y defines the y coordinate of the operand
  70468. * @param z defines the z coordinate of the operand
  70469. * @returns true if both vectors are equals
  70470. */
  70471. equalsToFloats(x: number, y: number, z: number): boolean;
  70472. /**
  70473. * Multiplies the current Vector3 coordinates by the given ones
  70474. * @param otherVector defines the second operand
  70475. * @returns the current updated Vector3
  70476. */
  70477. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70478. /**
  70479. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70480. * @param otherVector defines the second operand
  70481. * @returns the new Vector3
  70482. */
  70483. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70484. /**
  70485. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70486. * @param otherVector defines the second operand
  70487. * @param result defines the Vector3 object where to store the result
  70488. * @returns the current Vector3
  70489. */
  70490. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70491. /**
  70492. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70493. * @param x defines the x coordinate of the operand
  70494. * @param y defines the y coordinate of the operand
  70495. * @param z defines the z coordinate of the operand
  70496. * @returns the new Vector3
  70497. */
  70498. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70499. /**
  70500. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70501. * @param otherVector defines the second operand
  70502. * @returns the new Vector3
  70503. */
  70504. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70505. /**
  70506. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70507. * @param otherVector defines the second operand
  70508. * @param result defines the Vector3 object where to store the result
  70509. * @returns the current Vector3
  70510. */
  70511. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70512. /**
  70513. * Divides the current Vector3 coordinates by the given ones.
  70514. * @param otherVector defines the second operand
  70515. * @returns the current updated Vector3
  70516. */
  70517. divideInPlace(otherVector: Vector3): Vector3;
  70518. /**
  70519. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70520. * @param other defines the second operand
  70521. * @returns the current updated Vector3
  70522. */
  70523. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70524. /**
  70525. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70526. * @param other defines the second operand
  70527. * @returns the current updated Vector3
  70528. */
  70529. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70530. /**
  70531. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70532. * @param x defines the x coordinate of the operand
  70533. * @param y defines the y coordinate of the operand
  70534. * @param z defines the z coordinate of the operand
  70535. * @returns the current updated Vector3
  70536. */
  70537. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70538. /**
  70539. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70540. * @param x defines the x coordinate of the operand
  70541. * @param y defines the y coordinate of the operand
  70542. * @param z defines the z coordinate of the operand
  70543. * @returns the current updated Vector3
  70544. */
  70545. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70546. /**
  70547. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70548. * Check if is non uniform within a certain amount of decimal places to account for this
  70549. * @param epsilon the amount the values can differ
  70550. * @returns if the the vector is non uniform to a certain number of decimal places
  70551. */
  70552. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70553. /**
  70554. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70555. */
  70556. readonly isNonUniform: boolean;
  70557. /**
  70558. * Gets a new Vector3 from current Vector3 floored values
  70559. * @returns a new Vector3
  70560. */
  70561. floor(): Vector3;
  70562. /**
  70563. * Gets a new Vector3 from current Vector3 floored values
  70564. * @returns a new Vector3
  70565. */
  70566. fract(): Vector3;
  70567. /**
  70568. * Gets the length of the Vector3
  70569. * @returns the length of the Vector3
  70570. */
  70571. length(): number;
  70572. /**
  70573. * Gets the squared length of the Vector3
  70574. * @returns squared length of the Vector3
  70575. */
  70576. lengthSquared(): number;
  70577. /**
  70578. * Normalize the current Vector3.
  70579. * Please note that this is an in place operation.
  70580. * @returns the current updated Vector3
  70581. */
  70582. normalize(): Vector3;
  70583. /**
  70584. * Reorders the x y z properties of the vector in place
  70585. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70586. * @returns the current updated vector
  70587. */
  70588. reorderInPlace(order: string): this;
  70589. /**
  70590. * Rotates the vector around 0,0,0 by a quaternion
  70591. * @param quaternion the rotation quaternion
  70592. * @param result vector to store the result
  70593. * @returns the resulting vector
  70594. */
  70595. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70596. /**
  70597. * Rotates a vector around a given point
  70598. * @param quaternion the rotation quaternion
  70599. * @param point the point to rotate around
  70600. * @param result vector to store the result
  70601. * @returns the resulting vector
  70602. */
  70603. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70604. /**
  70605. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70606. * The cross product is then orthogonal to both current and "other"
  70607. * @param other defines the right operand
  70608. * @returns the cross product
  70609. */
  70610. cross(other: Vector3): Vector3;
  70611. /**
  70612. * Normalize the current Vector3 with the given input length.
  70613. * Please note that this is an in place operation.
  70614. * @param len the length of the vector
  70615. * @returns the current updated Vector3
  70616. */
  70617. normalizeFromLength(len: number): Vector3;
  70618. /**
  70619. * Normalize the current Vector3 to a new vector
  70620. * @returns the new Vector3
  70621. */
  70622. normalizeToNew(): Vector3;
  70623. /**
  70624. * Normalize the current Vector3 to the reference
  70625. * @param reference define the Vector3 to update
  70626. * @returns the updated Vector3
  70627. */
  70628. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70629. /**
  70630. * Creates a new Vector3 copied from the current Vector3
  70631. * @returns the new Vector3
  70632. */
  70633. clone(): Vector3;
  70634. /**
  70635. * Copies the given vector coordinates to the current Vector3 ones
  70636. * @param source defines the source Vector3
  70637. * @returns the current updated Vector3
  70638. */
  70639. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70640. /**
  70641. * Copies the given floats to the current Vector3 coordinates
  70642. * @param x defines the x coordinate of the operand
  70643. * @param y defines the y coordinate of the operand
  70644. * @param z defines the z coordinate of the operand
  70645. * @returns the current updated Vector3
  70646. */
  70647. copyFromFloats(x: number, y: number, z: number): Vector3;
  70648. /**
  70649. * Copies the given floats to the current Vector3 coordinates
  70650. * @param x defines the x coordinate of the operand
  70651. * @param y defines the y coordinate of the operand
  70652. * @param z defines the z coordinate of the operand
  70653. * @returns the current updated Vector3
  70654. */
  70655. set(x: number, y: number, z: number): Vector3;
  70656. /**
  70657. * Copies the given float to the current Vector3 coordinates
  70658. * @param v defines the x, y and z coordinates of the operand
  70659. * @returns the current updated Vector3
  70660. */
  70661. setAll(v: number): Vector3;
  70662. /**
  70663. * Get the clip factor between two vectors
  70664. * @param vector0 defines the first operand
  70665. * @param vector1 defines the second operand
  70666. * @param axis defines the axis to use
  70667. * @param size defines the size along the axis
  70668. * @returns the clip factor
  70669. */
  70670. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70671. /**
  70672. * Get angle between two vectors
  70673. * @param vector0 angle between vector0 and vector1
  70674. * @param vector1 angle between vector0 and vector1
  70675. * @param normal direction of the normal
  70676. * @return the angle between vector0 and vector1
  70677. */
  70678. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70679. /**
  70680. * Returns a new Vector3 set from the index "offset" of the given array
  70681. * @param array defines the source array
  70682. * @param offset defines the offset in the source array
  70683. * @returns the new Vector3
  70684. */
  70685. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70686. /**
  70687. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70688. * This function is deprecated. Use FromArray instead
  70689. * @param array defines the source array
  70690. * @param offset defines the offset in the source array
  70691. * @returns the new Vector3
  70692. */
  70693. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70694. /**
  70695. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70696. * @param array defines the source array
  70697. * @param offset defines the offset in the source array
  70698. * @param result defines the Vector3 where to store the result
  70699. */
  70700. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70701. /**
  70702. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70703. * This function is deprecated. Use FromArrayToRef instead.
  70704. * @param array defines the source array
  70705. * @param offset defines the offset in the source array
  70706. * @param result defines the Vector3 where to store the result
  70707. */
  70708. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70709. /**
  70710. * Sets the given vector "result" with the given floats.
  70711. * @param x defines the x coordinate of the source
  70712. * @param y defines the y coordinate of the source
  70713. * @param z defines the z coordinate of the source
  70714. * @param result defines the Vector3 where to store the result
  70715. */
  70716. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70717. /**
  70718. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70719. * @returns a new empty Vector3
  70720. */
  70721. static Zero(): Vector3;
  70722. /**
  70723. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70724. * @returns a new unit Vector3
  70725. */
  70726. static One(): Vector3;
  70727. /**
  70728. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70729. * @returns a new up Vector3
  70730. */
  70731. static Up(): Vector3;
  70732. /**
  70733. * Gets a up Vector3 that must not be updated
  70734. */
  70735. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70736. /**
  70737. * Gets a zero Vector3 that must not be updated
  70738. */
  70739. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70740. /**
  70741. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70742. * @returns a new down Vector3
  70743. */
  70744. static Down(): Vector3;
  70745. /**
  70746. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70747. * @returns a new forward Vector3
  70748. */
  70749. static Forward(): Vector3;
  70750. /**
  70751. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70752. * @returns a new forward Vector3
  70753. */
  70754. static Backward(): Vector3;
  70755. /**
  70756. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70757. * @returns a new right Vector3
  70758. */
  70759. static Right(): Vector3;
  70760. /**
  70761. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70762. * @returns a new left Vector3
  70763. */
  70764. static Left(): Vector3;
  70765. /**
  70766. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70767. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70768. * @param vector defines the Vector3 to transform
  70769. * @param transformation defines the transformation matrix
  70770. * @returns the transformed Vector3
  70771. */
  70772. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70773. /**
  70774. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70775. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70776. * @param vector defines the Vector3 to transform
  70777. * @param transformation defines the transformation matrix
  70778. * @param result defines the Vector3 where to store the result
  70779. */
  70780. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70781. /**
  70782. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70783. * This method computes tranformed coordinates only, not transformed direction vectors
  70784. * @param x define the x coordinate of the source vector
  70785. * @param y define the y coordinate of the source vector
  70786. * @param z define the z coordinate of the source vector
  70787. * @param transformation defines the transformation matrix
  70788. * @param result defines the Vector3 where to store the result
  70789. */
  70790. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70791. /**
  70792. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70793. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70794. * @param vector defines the Vector3 to transform
  70795. * @param transformation defines the transformation matrix
  70796. * @returns the new Vector3
  70797. */
  70798. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70799. /**
  70800. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70801. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70802. * @param vector defines the Vector3 to transform
  70803. * @param transformation defines the transformation matrix
  70804. * @param result defines the Vector3 where to store the result
  70805. */
  70806. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70807. /**
  70808. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70809. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70810. * @param x define the x coordinate of the source vector
  70811. * @param y define the y coordinate of the source vector
  70812. * @param z define the z coordinate of the source vector
  70813. * @param transformation defines the transformation matrix
  70814. * @param result defines the Vector3 where to store the result
  70815. */
  70816. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70817. /**
  70818. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70819. * @param value1 defines the first control point
  70820. * @param value2 defines the second control point
  70821. * @param value3 defines the third control point
  70822. * @param value4 defines the fourth control point
  70823. * @param amount defines the amount on the spline to use
  70824. * @returns the new Vector3
  70825. */
  70826. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70827. /**
  70828. * 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"
  70829. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70830. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70831. * @param value defines the current value
  70832. * @param min defines the lower range value
  70833. * @param max defines the upper range value
  70834. * @returns the new Vector3
  70835. */
  70836. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70837. /**
  70838. * 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"
  70839. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70840. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70841. * @param value defines the current value
  70842. * @param min defines the lower range value
  70843. * @param max defines the upper range value
  70844. * @param result defines the Vector3 where to store the result
  70845. */
  70846. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70847. /**
  70848. * Checks if a given vector is inside a specific range
  70849. * @param v defines the vector to test
  70850. * @param min defines the minimum range
  70851. * @param max defines the maximum range
  70852. */
  70853. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70854. /**
  70855. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70856. * @param value1 defines the first control point
  70857. * @param tangent1 defines the first tangent vector
  70858. * @param value2 defines the second control point
  70859. * @param tangent2 defines the second tangent vector
  70860. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70861. * @returns the new Vector3
  70862. */
  70863. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70864. /**
  70865. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70866. * @param start defines the start value
  70867. * @param end defines the end value
  70868. * @param amount max defines amount between both (between 0 and 1)
  70869. * @returns the new Vector3
  70870. */
  70871. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70872. /**
  70873. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70874. * @param start defines the start value
  70875. * @param end defines the end value
  70876. * @param amount max defines amount between both (between 0 and 1)
  70877. * @param result defines the Vector3 where to store the result
  70878. */
  70879. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70880. /**
  70881. * Returns the dot product (float) between the vectors "left" and "right"
  70882. * @param left defines the left operand
  70883. * @param right defines the right operand
  70884. * @returns the dot product
  70885. */
  70886. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70887. /**
  70888. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70889. * The cross product is then orthogonal to both "left" and "right"
  70890. * @param left defines the left operand
  70891. * @param right defines the right operand
  70892. * @returns the cross product
  70893. */
  70894. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70895. /**
  70896. * Sets the given vector "result" with the cross product of "left" and "right"
  70897. * The cross product is then orthogonal to both "left" and "right"
  70898. * @param left defines the left operand
  70899. * @param right defines the right operand
  70900. * @param result defines the Vector3 where to store the result
  70901. */
  70902. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70903. /**
  70904. * Returns a new Vector3 as the normalization of the given vector
  70905. * @param vector defines the Vector3 to normalize
  70906. * @returns the new Vector3
  70907. */
  70908. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70909. /**
  70910. * Sets the given vector "result" with the normalization of the given first vector
  70911. * @param vector defines the Vector3 to normalize
  70912. * @param result defines the Vector3 where to store the result
  70913. */
  70914. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70915. /**
  70916. * Project a Vector3 onto screen space
  70917. * @param vector defines the Vector3 to project
  70918. * @param world defines the world matrix to use
  70919. * @param transform defines the transform (view x projection) matrix to use
  70920. * @param viewport defines the screen viewport to use
  70921. * @returns the new Vector3
  70922. */
  70923. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70924. /** @hidden */
  70925. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70926. /**
  70927. * Unproject from screen space to object space
  70928. * @param source defines the screen space Vector3 to use
  70929. * @param viewportWidth defines the current width of the viewport
  70930. * @param viewportHeight defines the current height of the viewport
  70931. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70932. * @param transform defines the transform (view x projection) matrix to use
  70933. * @returns the new Vector3
  70934. */
  70935. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70936. /**
  70937. * Unproject from screen space to object space
  70938. * @param source defines the screen space Vector3 to use
  70939. * @param viewportWidth defines the current width of the viewport
  70940. * @param viewportHeight defines the current height of the viewport
  70941. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70942. * @param view defines the view matrix to use
  70943. * @param projection defines the projection matrix to use
  70944. * @returns the new Vector3
  70945. */
  70946. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70947. /**
  70948. * Unproject from screen space to object space
  70949. * @param source defines the screen space Vector3 to use
  70950. * @param viewportWidth defines the current width of the viewport
  70951. * @param viewportHeight defines the current height of the viewport
  70952. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70953. * @param view defines the view matrix to use
  70954. * @param projection defines the projection matrix to use
  70955. * @param result defines the Vector3 where to store the result
  70956. */
  70957. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70958. /**
  70959. * Unproject from screen space to object space
  70960. * @param sourceX defines the screen space x coordinate to use
  70961. * @param sourceY defines the screen space y coordinate to use
  70962. * @param sourceZ defines the screen space z coordinate to use
  70963. * @param viewportWidth defines the current width of the viewport
  70964. * @param viewportHeight defines the current height of the viewport
  70965. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70966. * @param view defines the view matrix to use
  70967. * @param projection defines the projection matrix to use
  70968. * @param result defines the Vector3 where to store the result
  70969. */
  70970. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70971. /**
  70972. * Gets the minimal coordinate values between two Vector3
  70973. * @param left defines the first operand
  70974. * @param right defines the second operand
  70975. * @returns the new Vector3
  70976. */
  70977. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70978. /**
  70979. * Gets the maximal coordinate values between two Vector3
  70980. * @param left defines the first operand
  70981. * @param right defines the second operand
  70982. * @returns the new Vector3
  70983. */
  70984. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70985. /**
  70986. * Returns the distance between the vectors "value1" and "value2"
  70987. * @param value1 defines the first operand
  70988. * @param value2 defines the second operand
  70989. * @returns the distance
  70990. */
  70991. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70992. /**
  70993. * Returns the squared distance between the vectors "value1" and "value2"
  70994. * @param value1 defines the first operand
  70995. * @param value2 defines the second operand
  70996. * @returns the squared distance
  70997. */
  70998. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70999. /**
  71000. * Returns a new Vector3 located at the center between "value1" and "value2"
  71001. * @param value1 defines the first operand
  71002. * @param value2 defines the second operand
  71003. * @returns the new Vector3
  71004. */
  71005. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71006. /**
  71007. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71008. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71009. * to something in order to rotate it from its local system to the given target system
  71010. * Note: axis1, axis2 and axis3 are normalized during this operation
  71011. * @param axis1 defines the first axis
  71012. * @param axis2 defines the second axis
  71013. * @param axis3 defines the third axis
  71014. * @returns a new Vector3
  71015. */
  71016. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71017. /**
  71018. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71019. * @param axis1 defines the first axis
  71020. * @param axis2 defines the second axis
  71021. * @param axis3 defines the third axis
  71022. * @param ref defines the Vector3 where to store the result
  71023. */
  71024. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71025. }
  71026. /**
  71027. * Vector4 class created for EulerAngle class conversion to Quaternion
  71028. */
  71029. export class Vector4 {
  71030. /** x value of the vector */
  71031. x: number;
  71032. /** y value of the vector */
  71033. y: number;
  71034. /** z value of the vector */
  71035. z: number;
  71036. /** w value of the vector */
  71037. w: number;
  71038. /**
  71039. * Creates a Vector4 object from the given floats.
  71040. * @param x x value of the vector
  71041. * @param y y value of the vector
  71042. * @param z z value of the vector
  71043. * @param w w value of the vector
  71044. */
  71045. constructor(
  71046. /** x value of the vector */
  71047. x: number,
  71048. /** y value of the vector */
  71049. y: number,
  71050. /** z value of the vector */
  71051. z: number,
  71052. /** w value of the vector */
  71053. w: number);
  71054. /**
  71055. * Returns the string with the Vector4 coordinates.
  71056. * @returns a string containing all the vector values
  71057. */
  71058. toString(): string;
  71059. /**
  71060. * Returns the string "Vector4".
  71061. * @returns "Vector4"
  71062. */
  71063. getClassName(): string;
  71064. /**
  71065. * Returns the Vector4 hash code.
  71066. * @returns a unique hash code
  71067. */
  71068. getHashCode(): number;
  71069. /**
  71070. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71071. * @returns the resulting array
  71072. */
  71073. asArray(): number[];
  71074. /**
  71075. * Populates the given array from the given index with the Vector4 coordinates.
  71076. * @param array array to populate
  71077. * @param index index of the array to start at (default: 0)
  71078. * @returns the Vector4.
  71079. */
  71080. toArray(array: FloatArray, index?: number): Vector4;
  71081. /**
  71082. * Adds the given vector to the current Vector4.
  71083. * @param otherVector the vector to add
  71084. * @returns the updated Vector4.
  71085. */
  71086. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71087. /**
  71088. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71089. * @param otherVector the vector to add
  71090. * @returns the resulting vector
  71091. */
  71092. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71093. /**
  71094. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71095. * @param otherVector the vector to add
  71096. * @param result the vector to store the result
  71097. * @returns the current Vector4.
  71098. */
  71099. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71100. /**
  71101. * Subtract in place the given vector from the current Vector4.
  71102. * @param otherVector the vector to subtract
  71103. * @returns the updated Vector4.
  71104. */
  71105. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71106. /**
  71107. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71108. * @param otherVector the vector to add
  71109. * @returns the new vector with the result
  71110. */
  71111. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71112. /**
  71113. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71114. * @param otherVector the vector to subtract
  71115. * @param result the vector to store the result
  71116. * @returns the current Vector4.
  71117. */
  71118. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71119. /**
  71120. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71121. */
  71122. /**
  71123. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71124. * @param x value to subtract
  71125. * @param y value to subtract
  71126. * @param z value to subtract
  71127. * @param w value to subtract
  71128. * @returns new vector containing the result
  71129. */
  71130. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71131. /**
  71132. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71133. * @param x value to subtract
  71134. * @param y value to subtract
  71135. * @param z value to subtract
  71136. * @param w value to subtract
  71137. * @param result the vector to store the result in
  71138. * @returns the current Vector4.
  71139. */
  71140. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71141. /**
  71142. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71143. * @returns a new vector with the negated values
  71144. */
  71145. negate(): Vector4;
  71146. /**
  71147. * Multiplies the current Vector4 coordinates by scale (float).
  71148. * @param scale the number to scale with
  71149. * @returns the updated Vector4.
  71150. */
  71151. scaleInPlace(scale: number): Vector4;
  71152. /**
  71153. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71154. * @param scale the number to scale with
  71155. * @returns a new vector with the result
  71156. */
  71157. scale(scale: number): Vector4;
  71158. /**
  71159. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71160. * @param scale the number to scale with
  71161. * @param result a vector to store the result in
  71162. * @returns the current Vector4.
  71163. */
  71164. scaleToRef(scale: number, result: Vector4): Vector4;
  71165. /**
  71166. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71167. * @param scale defines the scale factor
  71168. * @param result defines the Vector4 object where to store the result
  71169. * @returns the unmodified current Vector4
  71170. */
  71171. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71172. /**
  71173. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71174. * @param otherVector the vector to compare against
  71175. * @returns true if they are equal
  71176. */
  71177. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71178. /**
  71179. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71180. * @param otherVector vector to compare against
  71181. * @param epsilon (Default: very small number)
  71182. * @returns true if they are equal
  71183. */
  71184. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71185. /**
  71186. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71187. * @param x x value to compare against
  71188. * @param y y value to compare against
  71189. * @param z z value to compare against
  71190. * @param w w value to compare against
  71191. * @returns true if equal
  71192. */
  71193. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71194. /**
  71195. * Multiplies in place the current Vector4 by the given one.
  71196. * @param otherVector vector to multiple with
  71197. * @returns the updated Vector4.
  71198. */
  71199. multiplyInPlace(otherVector: Vector4): Vector4;
  71200. /**
  71201. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71202. * @param otherVector vector to multiple with
  71203. * @returns resulting new vector
  71204. */
  71205. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71206. /**
  71207. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71208. * @param otherVector vector to multiple with
  71209. * @param result vector to store the result
  71210. * @returns the current Vector4.
  71211. */
  71212. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71213. /**
  71214. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71215. * @param x x value multiply with
  71216. * @param y y value multiply with
  71217. * @param z z value multiply with
  71218. * @param w w value multiply with
  71219. * @returns resulting new vector
  71220. */
  71221. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71222. /**
  71223. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71224. * @param otherVector vector to devide with
  71225. * @returns resulting new vector
  71226. */
  71227. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71228. /**
  71229. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71230. * @param otherVector vector to devide with
  71231. * @param result vector to store the result
  71232. * @returns the current Vector4.
  71233. */
  71234. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71235. /**
  71236. * Divides the current Vector3 coordinates by the given ones.
  71237. * @param otherVector vector to devide with
  71238. * @returns the updated Vector3.
  71239. */
  71240. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71241. /**
  71242. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71243. * @param other defines the second operand
  71244. * @returns the current updated Vector4
  71245. */
  71246. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71247. /**
  71248. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71249. * @param other defines the second operand
  71250. * @returns the current updated Vector4
  71251. */
  71252. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71253. /**
  71254. * Gets a new Vector4 from current Vector4 floored values
  71255. * @returns a new Vector4
  71256. */
  71257. floor(): Vector4;
  71258. /**
  71259. * Gets a new Vector4 from current Vector3 floored values
  71260. * @returns a new Vector4
  71261. */
  71262. fract(): Vector4;
  71263. /**
  71264. * Returns the Vector4 length (float).
  71265. * @returns the length
  71266. */
  71267. length(): number;
  71268. /**
  71269. * Returns the Vector4 squared length (float).
  71270. * @returns the length squared
  71271. */
  71272. lengthSquared(): number;
  71273. /**
  71274. * Normalizes in place the Vector4.
  71275. * @returns the updated Vector4.
  71276. */
  71277. normalize(): Vector4;
  71278. /**
  71279. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71280. * @returns this converted to a new vector3
  71281. */
  71282. toVector3(): Vector3;
  71283. /**
  71284. * Returns a new Vector4 copied from the current one.
  71285. * @returns the new cloned vector
  71286. */
  71287. clone(): Vector4;
  71288. /**
  71289. * Updates the current Vector4 with the given one coordinates.
  71290. * @param source the source vector to copy from
  71291. * @returns the updated Vector4.
  71292. */
  71293. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71294. /**
  71295. * Updates the current Vector4 coordinates with the given floats.
  71296. * @param x float to copy from
  71297. * @param y float to copy from
  71298. * @param z float to copy from
  71299. * @param w float to copy from
  71300. * @returns the updated Vector4.
  71301. */
  71302. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71303. /**
  71304. * Updates the current Vector4 coordinates with the given floats.
  71305. * @param x float to set from
  71306. * @param y float to set from
  71307. * @param z float to set from
  71308. * @param w float to set from
  71309. * @returns the updated Vector4.
  71310. */
  71311. set(x: number, y: number, z: number, w: number): Vector4;
  71312. /**
  71313. * Copies the given float to the current Vector3 coordinates
  71314. * @param v defines the x, y, z and w coordinates of the operand
  71315. * @returns the current updated Vector3
  71316. */
  71317. setAll(v: number): Vector4;
  71318. /**
  71319. * Returns a new Vector4 set from the starting index of the given array.
  71320. * @param array the array to pull values from
  71321. * @param offset the offset into the array to start at
  71322. * @returns the new vector
  71323. */
  71324. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71325. /**
  71326. * Updates the given vector "result" from the starting index of the given array.
  71327. * @param array the array to pull values from
  71328. * @param offset the offset into the array to start at
  71329. * @param result the vector to store the result in
  71330. */
  71331. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71332. /**
  71333. * Updates the given vector "result" from the starting index of the given Float32Array.
  71334. * @param array the array to pull values from
  71335. * @param offset the offset into the array to start at
  71336. * @param result the vector to store the result in
  71337. */
  71338. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71339. /**
  71340. * Updates the given vector "result" coordinates from the given floats.
  71341. * @param x float to set from
  71342. * @param y float to set from
  71343. * @param z float to set from
  71344. * @param w float to set from
  71345. * @param result the vector to the floats in
  71346. */
  71347. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71348. /**
  71349. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71350. * @returns the new vector
  71351. */
  71352. static Zero(): Vector4;
  71353. /**
  71354. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71355. * @returns the new vector
  71356. */
  71357. static One(): Vector4;
  71358. /**
  71359. * Returns a new normalized Vector4 from the given one.
  71360. * @param vector the vector to normalize
  71361. * @returns the vector
  71362. */
  71363. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71364. /**
  71365. * Updates the given vector "result" from the normalization of the given one.
  71366. * @param vector the vector to normalize
  71367. * @param result the vector to store the result in
  71368. */
  71369. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71370. /**
  71371. * Returns a vector with the minimum values from the left and right vectors
  71372. * @param left left vector to minimize
  71373. * @param right right vector to minimize
  71374. * @returns a new vector with the minimum of the left and right vector values
  71375. */
  71376. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71377. /**
  71378. * Returns a vector with the maximum values from the left and right vectors
  71379. * @param left left vector to maximize
  71380. * @param right right vector to maximize
  71381. * @returns a new vector with the maximum of the left and right vector values
  71382. */
  71383. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71384. /**
  71385. * Returns the distance (float) between the vectors "value1" and "value2".
  71386. * @param value1 value to calulate the distance between
  71387. * @param value2 value to calulate the distance between
  71388. * @return the distance between the two vectors
  71389. */
  71390. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71391. /**
  71392. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71393. * @param value1 value to calulate the distance between
  71394. * @param value2 value to calulate the distance between
  71395. * @return the distance between the two vectors squared
  71396. */
  71397. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71398. /**
  71399. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71400. * @param value1 value to calulate the center between
  71401. * @param value2 value to calulate the center between
  71402. * @return the center between the two vectors
  71403. */
  71404. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71405. /**
  71406. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71407. * This methods computes transformed normalized direction vectors only.
  71408. * @param vector the vector to transform
  71409. * @param transformation the transformation matrix to apply
  71410. * @returns the new vector
  71411. */
  71412. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71413. /**
  71414. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71415. * This methods computes transformed normalized direction vectors only.
  71416. * @param vector the vector to transform
  71417. * @param transformation the transformation matrix to apply
  71418. * @param result the vector to store the result in
  71419. */
  71420. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71421. /**
  71422. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71423. * This methods computes transformed normalized direction vectors only.
  71424. * @param x value to transform
  71425. * @param y value to transform
  71426. * @param z value to transform
  71427. * @param w value to transform
  71428. * @param transformation the transformation matrix to apply
  71429. * @param result the vector to store the results in
  71430. */
  71431. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71432. /**
  71433. * Creates a new Vector4 from a Vector3
  71434. * @param source defines the source data
  71435. * @param w defines the 4th component (default is 0)
  71436. * @returns a new Vector4
  71437. */
  71438. static FromVector3(source: Vector3, w?: number): Vector4;
  71439. }
  71440. /**
  71441. * Class used to store quaternion data
  71442. * @see https://en.wikipedia.org/wiki/Quaternion
  71443. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71444. */
  71445. export class Quaternion {
  71446. /** defines the first component (0 by default) */
  71447. x: number;
  71448. /** defines the second component (0 by default) */
  71449. y: number;
  71450. /** defines the third component (0 by default) */
  71451. z: number;
  71452. /** defines the fourth component (1.0 by default) */
  71453. w: number;
  71454. /**
  71455. * Creates a new Quaternion from the given floats
  71456. * @param x defines the first component (0 by default)
  71457. * @param y defines the second component (0 by default)
  71458. * @param z defines the third component (0 by default)
  71459. * @param w defines the fourth component (1.0 by default)
  71460. */
  71461. constructor(
  71462. /** defines the first component (0 by default) */
  71463. x?: number,
  71464. /** defines the second component (0 by default) */
  71465. y?: number,
  71466. /** defines the third component (0 by default) */
  71467. z?: number,
  71468. /** defines the fourth component (1.0 by default) */
  71469. w?: number);
  71470. /**
  71471. * Gets a string representation for the current quaternion
  71472. * @returns a string with the Quaternion coordinates
  71473. */
  71474. toString(): string;
  71475. /**
  71476. * Gets the class name of the quaternion
  71477. * @returns the string "Quaternion"
  71478. */
  71479. getClassName(): string;
  71480. /**
  71481. * Gets a hash code for this quaternion
  71482. * @returns the quaternion hash code
  71483. */
  71484. getHashCode(): number;
  71485. /**
  71486. * Copy the quaternion to an array
  71487. * @returns a new array populated with 4 elements from the quaternion coordinates
  71488. */
  71489. asArray(): number[];
  71490. /**
  71491. * Check if two quaternions are equals
  71492. * @param otherQuaternion defines the second operand
  71493. * @return true if the current quaternion and the given one coordinates are strictly equals
  71494. */
  71495. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71496. /**
  71497. * Clone the current quaternion
  71498. * @returns a new quaternion copied from the current one
  71499. */
  71500. clone(): Quaternion;
  71501. /**
  71502. * Copy a quaternion to the current one
  71503. * @param other defines the other quaternion
  71504. * @returns the updated current quaternion
  71505. */
  71506. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71507. /**
  71508. * Updates the current quaternion with the given float coordinates
  71509. * @param x defines the x coordinate
  71510. * @param y defines the y coordinate
  71511. * @param z defines the z coordinate
  71512. * @param w defines the w coordinate
  71513. * @returns the updated current quaternion
  71514. */
  71515. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71516. /**
  71517. * Updates the current quaternion from the given float coordinates
  71518. * @param x defines the x coordinate
  71519. * @param y defines the y coordinate
  71520. * @param z defines the z coordinate
  71521. * @param w defines the w coordinate
  71522. * @returns the updated current quaternion
  71523. */
  71524. set(x: number, y: number, z: number, w: number): Quaternion;
  71525. /**
  71526. * Adds two quaternions
  71527. * @param other defines the second operand
  71528. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71529. */
  71530. add(other: DeepImmutable<Quaternion>): Quaternion;
  71531. /**
  71532. * Add a quaternion to the current one
  71533. * @param other defines the quaternion to add
  71534. * @returns the current quaternion
  71535. */
  71536. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71537. /**
  71538. * Subtract two quaternions
  71539. * @param other defines the second operand
  71540. * @returns a new quaternion as the subtraction result of the given one from the current one
  71541. */
  71542. subtract(other: Quaternion): Quaternion;
  71543. /**
  71544. * Multiplies the current quaternion by a scale factor
  71545. * @param value defines the scale factor
  71546. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71547. */
  71548. scale(value: number): Quaternion;
  71549. /**
  71550. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71551. * @param scale defines the scale factor
  71552. * @param result defines the Quaternion object where to store the result
  71553. * @returns the unmodified current quaternion
  71554. */
  71555. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71556. /**
  71557. * Multiplies in place the current quaternion by a scale factor
  71558. * @param value defines the scale factor
  71559. * @returns the current modified quaternion
  71560. */
  71561. scaleInPlace(value: number): Quaternion;
  71562. /**
  71563. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71564. * @param scale defines the scale factor
  71565. * @param result defines the Quaternion object where to store the result
  71566. * @returns the unmodified current quaternion
  71567. */
  71568. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71569. /**
  71570. * Multiplies two quaternions
  71571. * @param q1 defines the second operand
  71572. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71573. */
  71574. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71575. /**
  71576. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71577. * @param q1 defines the second operand
  71578. * @param result defines the target quaternion
  71579. * @returns the current quaternion
  71580. */
  71581. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71582. /**
  71583. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71584. * @param q1 defines the second operand
  71585. * @returns the currentupdated quaternion
  71586. */
  71587. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71588. /**
  71589. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71590. * @param ref defines the target quaternion
  71591. * @returns the current quaternion
  71592. */
  71593. conjugateToRef(ref: Quaternion): Quaternion;
  71594. /**
  71595. * Conjugates in place (1-q) the current quaternion
  71596. * @returns the current updated quaternion
  71597. */
  71598. conjugateInPlace(): Quaternion;
  71599. /**
  71600. * Conjugates in place (1-q) the current quaternion
  71601. * @returns a new quaternion
  71602. */
  71603. conjugate(): Quaternion;
  71604. /**
  71605. * Gets length of current quaternion
  71606. * @returns the quaternion length (float)
  71607. */
  71608. length(): number;
  71609. /**
  71610. * Normalize in place the current quaternion
  71611. * @returns the current updated quaternion
  71612. */
  71613. normalize(): Quaternion;
  71614. /**
  71615. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71616. * @param order is a reserved parameter and is ignore for now
  71617. * @returns a new Vector3 containing the Euler angles
  71618. */
  71619. toEulerAngles(order?: string): Vector3;
  71620. /**
  71621. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71622. * @param result defines the vector which will be filled with the Euler angles
  71623. * @param order is a reserved parameter and is ignore for now
  71624. * @returns the current unchanged quaternion
  71625. */
  71626. toEulerAnglesToRef(result: Vector3): Quaternion;
  71627. /**
  71628. * Updates the given rotation matrix with the current quaternion values
  71629. * @param result defines the target matrix
  71630. * @returns the current unchanged quaternion
  71631. */
  71632. toRotationMatrix(result: Matrix): Quaternion;
  71633. /**
  71634. * Updates the current quaternion from the given rotation matrix values
  71635. * @param matrix defines the source matrix
  71636. * @returns the current updated quaternion
  71637. */
  71638. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71639. /**
  71640. * Creates a new quaternion from a rotation matrix
  71641. * @param matrix defines the source matrix
  71642. * @returns a new quaternion created from the given rotation matrix values
  71643. */
  71644. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71645. /**
  71646. * Updates the given quaternion with the given rotation matrix values
  71647. * @param matrix defines the source matrix
  71648. * @param result defines the target quaternion
  71649. */
  71650. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71651. /**
  71652. * Returns the dot product (float) between the quaternions "left" and "right"
  71653. * @param left defines the left operand
  71654. * @param right defines the right operand
  71655. * @returns the dot product
  71656. */
  71657. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71658. /**
  71659. * Checks if the two quaternions are close to each other
  71660. * @param quat0 defines the first quaternion to check
  71661. * @param quat1 defines the second quaternion to check
  71662. * @returns true if the two quaternions are close to each other
  71663. */
  71664. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71665. /**
  71666. * Creates an empty quaternion
  71667. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71668. */
  71669. static Zero(): Quaternion;
  71670. /**
  71671. * Inverse a given quaternion
  71672. * @param q defines the source quaternion
  71673. * @returns a new quaternion as the inverted current quaternion
  71674. */
  71675. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71676. /**
  71677. * Inverse a given quaternion
  71678. * @param q defines the source quaternion
  71679. * @param result the quaternion the result will be stored in
  71680. * @returns the result quaternion
  71681. */
  71682. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71683. /**
  71684. * Creates an identity quaternion
  71685. * @returns the identity quaternion
  71686. */
  71687. static Identity(): Quaternion;
  71688. /**
  71689. * Gets a boolean indicating if the given quaternion is identity
  71690. * @param quaternion defines the quaternion to check
  71691. * @returns true if the quaternion is identity
  71692. */
  71693. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71694. /**
  71695. * Creates a quaternion from a rotation around an axis
  71696. * @param axis defines the axis to use
  71697. * @param angle defines the angle to use
  71698. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71699. */
  71700. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71701. /**
  71702. * Creates a rotation around an axis and stores it into the given quaternion
  71703. * @param axis defines the axis to use
  71704. * @param angle defines the angle to use
  71705. * @param result defines the target quaternion
  71706. * @returns the target quaternion
  71707. */
  71708. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71709. /**
  71710. * Creates a new quaternion from data stored into an array
  71711. * @param array defines the data source
  71712. * @param offset defines the offset in the source array where the data starts
  71713. * @returns a new quaternion
  71714. */
  71715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71716. /**
  71717. * Create a quaternion from Euler rotation angles
  71718. * @param x Pitch
  71719. * @param y Yaw
  71720. * @param z Roll
  71721. * @returns the new Quaternion
  71722. */
  71723. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71724. /**
  71725. * Updates a quaternion from Euler rotation angles
  71726. * @param x Pitch
  71727. * @param y Yaw
  71728. * @param z Roll
  71729. * @param result the quaternion to store the result
  71730. * @returns the updated quaternion
  71731. */
  71732. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71733. /**
  71734. * Create a quaternion from Euler rotation vector
  71735. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71736. * @returns the new Quaternion
  71737. */
  71738. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71739. /**
  71740. * Updates a quaternion from Euler rotation vector
  71741. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71742. * @param result the quaternion to store the result
  71743. * @returns the updated quaternion
  71744. */
  71745. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71746. /**
  71747. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71748. * @param yaw defines the rotation around Y axis
  71749. * @param pitch defines the rotation around X axis
  71750. * @param roll defines the rotation around Z axis
  71751. * @returns the new quaternion
  71752. */
  71753. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71754. /**
  71755. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71756. * @param yaw defines the rotation around Y axis
  71757. * @param pitch defines the rotation around X axis
  71758. * @param roll defines the rotation around Z axis
  71759. * @param result defines the target quaternion
  71760. */
  71761. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71762. /**
  71763. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71764. * @param alpha defines the rotation around first axis
  71765. * @param beta defines the rotation around second axis
  71766. * @param gamma defines the rotation around third axis
  71767. * @returns the new quaternion
  71768. */
  71769. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71770. /**
  71771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71772. * @param alpha defines the rotation around first axis
  71773. * @param beta defines the rotation around second axis
  71774. * @param gamma defines the rotation around third axis
  71775. * @param result defines the target quaternion
  71776. */
  71777. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71778. /**
  71779. * 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)
  71780. * @param axis1 defines the first axis
  71781. * @param axis2 defines the second axis
  71782. * @param axis3 defines the third axis
  71783. * @returns the new quaternion
  71784. */
  71785. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71786. /**
  71787. * 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
  71788. * @param axis1 defines the first axis
  71789. * @param axis2 defines the second axis
  71790. * @param axis3 defines the third axis
  71791. * @param ref defines the target quaternion
  71792. */
  71793. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71794. /**
  71795. * Interpolates between two quaternions
  71796. * @param left defines first quaternion
  71797. * @param right defines second quaternion
  71798. * @param amount defines the gradient to use
  71799. * @returns the new interpolated quaternion
  71800. */
  71801. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71802. /**
  71803. * Interpolates between two quaternions and stores it into a target quaternion
  71804. * @param left defines first quaternion
  71805. * @param right defines second quaternion
  71806. * @param amount defines the gradient to use
  71807. * @param result defines the target quaternion
  71808. */
  71809. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71810. /**
  71811. * Interpolate between two quaternions using Hermite interpolation
  71812. * @param value1 defines first quaternion
  71813. * @param tangent1 defines the incoming tangent
  71814. * @param value2 defines second quaternion
  71815. * @param tangent2 defines the outgoing tangent
  71816. * @param amount defines the target quaternion
  71817. * @returns the new interpolated quaternion
  71818. */
  71819. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71820. }
  71821. /**
  71822. * Class used to store matrix data (4x4)
  71823. */
  71824. export class Matrix {
  71825. private static _updateFlagSeed;
  71826. private static _identityReadOnly;
  71827. private _isIdentity;
  71828. private _isIdentityDirty;
  71829. private _isIdentity3x2;
  71830. private _isIdentity3x2Dirty;
  71831. /**
  71832. * Gets the update flag of the matrix which is an unique number for the matrix.
  71833. * It will be incremented every time the matrix data change.
  71834. * You can use it to speed the comparison between two versions of the same matrix.
  71835. */
  71836. updateFlag: number;
  71837. private readonly _m;
  71838. /**
  71839. * Gets the internal data of the matrix
  71840. */
  71841. readonly m: DeepImmutable<Float32Array>;
  71842. /** @hidden */
  71843. _markAsUpdated(): void;
  71844. /** @hidden */
  71845. private _updateIdentityStatus;
  71846. /**
  71847. * Creates an empty matrix (filled with zeros)
  71848. */
  71849. constructor();
  71850. /**
  71851. * Check if the current matrix is identity
  71852. * @returns true is the matrix is the identity matrix
  71853. */
  71854. isIdentity(): boolean;
  71855. /**
  71856. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71857. * @returns true is the matrix is the identity matrix
  71858. */
  71859. isIdentityAs3x2(): boolean;
  71860. /**
  71861. * Gets the determinant of the matrix
  71862. * @returns the matrix determinant
  71863. */
  71864. determinant(): number;
  71865. /**
  71866. * Returns the matrix as a Float32Array
  71867. * @returns the matrix underlying array
  71868. */
  71869. toArray(): DeepImmutable<Float32Array>;
  71870. /**
  71871. * Returns the matrix as a Float32Array
  71872. * @returns the matrix underlying array.
  71873. */
  71874. asArray(): DeepImmutable<Float32Array>;
  71875. /**
  71876. * Inverts the current matrix in place
  71877. * @returns the current inverted matrix
  71878. */
  71879. invert(): Matrix;
  71880. /**
  71881. * Sets all the matrix elements to zero
  71882. * @returns the current matrix
  71883. */
  71884. reset(): Matrix;
  71885. /**
  71886. * Adds the current matrix with a second one
  71887. * @param other defines the matrix to add
  71888. * @returns a new matrix as the addition of the current matrix and the given one
  71889. */
  71890. add(other: DeepImmutable<Matrix>): Matrix;
  71891. /**
  71892. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71893. * @param other defines the matrix to add
  71894. * @param result defines the target matrix
  71895. * @returns the current matrix
  71896. */
  71897. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71898. /**
  71899. * Adds in place the given matrix to the current matrix
  71900. * @param other defines the second operand
  71901. * @returns the current updated matrix
  71902. */
  71903. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71904. /**
  71905. * Sets the given matrix to the current inverted Matrix
  71906. * @param other defines the target matrix
  71907. * @returns the unmodified current matrix
  71908. */
  71909. invertToRef(other: Matrix): Matrix;
  71910. /**
  71911. * add a value at the specified position in the current Matrix
  71912. * @param index the index of the value within the matrix. between 0 and 15.
  71913. * @param value the value to be added
  71914. * @returns the current updated matrix
  71915. */
  71916. addAtIndex(index: number, value: number): Matrix;
  71917. /**
  71918. * mutiply the specified position in the current Matrix by a value
  71919. * @param index the index of the value within the matrix. between 0 and 15.
  71920. * @param value the value to be added
  71921. * @returns the current updated matrix
  71922. */
  71923. multiplyAtIndex(index: number, value: number): Matrix;
  71924. /**
  71925. * Inserts the translation vector (using 3 floats) in the current matrix
  71926. * @param x defines the 1st component of the translation
  71927. * @param y defines the 2nd component of the translation
  71928. * @param z defines the 3rd component of the translation
  71929. * @returns the current updated matrix
  71930. */
  71931. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71932. /**
  71933. * Adds the translation vector (using 3 floats) in the current matrix
  71934. * @param x defines the 1st component of the translation
  71935. * @param y defines the 2nd component of the translation
  71936. * @param z defines the 3rd component of the translation
  71937. * @returns the current updated matrix
  71938. */
  71939. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71940. /**
  71941. * Inserts the translation vector in the current matrix
  71942. * @param vector3 defines the translation to insert
  71943. * @returns the current updated matrix
  71944. */
  71945. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71946. /**
  71947. * Gets the translation value of the current matrix
  71948. * @returns a new Vector3 as the extracted translation from the matrix
  71949. */
  71950. getTranslation(): Vector3;
  71951. /**
  71952. * Fill a Vector3 with the extracted translation from the matrix
  71953. * @param result defines the Vector3 where to store the translation
  71954. * @returns the current matrix
  71955. */
  71956. getTranslationToRef(result: Vector3): Matrix;
  71957. /**
  71958. * Remove rotation and scaling part from the matrix
  71959. * @returns the updated matrix
  71960. */
  71961. removeRotationAndScaling(): Matrix;
  71962. /**
  71963. * Multiply two matrices
  71964. * @param other defines the second operand
  71965. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71966. */
  71967. multiply(other: DeepImmutable<Matrix>): Matrix;
  71968. /**
  71969. * Copy the current matrix from the given one
  71970. * @param other defines the source matrix
  71971. * @returns the current updated matrix
  71972. */
  71973. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71974. /**
  71975. * Populates the given array from the starting index with the current matrix values
  71976. * @param array defines the target array
  71977. * @param offset defines the offset in the target array where to start storing values
  71978. * @returns the current matrix
  71979. */
  71980. copyToArray(array: Float32Array, offset?: number): Matrix;
  71981. /**
  71982. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71983. * @param other defines the second operand
  71984. * @param result defines the matrix where to store the multiplication
  71985. * @returns the current matrix
  71986. */
  71987. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71988. /**
  71989. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71990. * @param other defines the second operand
  71991. * @param result defines the array where to store the multiplication
  71992. * @param offset defines the offset in the target array where to start storing values
  71993. * @returns the current matrix
  71994. */
  71995. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71996. /**
  71997. * Check equality between this matrix and a second one
  71998. * @param value defines the second matrix to compare
  71999. * @returns true is the current matrix and the given one values are strictly equal
  72000. */
  72001. equals(value: DeepImmutable<Matrix>): boolean;
  72002. /**
  72003. * Clone the current matrix
  72004. * @returns a new matrix from the current matrix
  72005. */
  72006. clone(): Matrix;
  72007. /**
  72008. * Returns the name of the current matrix class
  72009. * @returns the string "Matrix"
  72010. */
  72011. getClassName(): string;
  72012. /**
  72013. * Gets the hash code of the current matrix
  72014. * @returns the hash code
  72015. */
  72016. getHashCode(): number;
  72017. /**
  72018. * Decomposes the current Matrix into a translation, rotation and scaling components
  72019. * @param scale defines the scale vector3 given as a reference to update
  72020. * @param rotation defines the rotation quaternion given as a reference to update
  72021. * @param translation defines the translation vector3 given as a reference to update
  72022. * @returns true if operation was successful
  72023. */
  72024. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72025. /**
  72026. * Gets specific row of the matrix
  72027. * @param index defines the number of the row to get
  72028. * @returns the index-th row of the current matrix as a new Vector4
  72029. */
  72030. getRow(index: number): Nullable<Vector4>;
  72031. /**
  72032. * Sets the index-th row of the current matrix to the vector4 values
  72033. * @param index defines the number of the row to set
  72034. * @param row defines the target vector4
  72035. * @returns the updated current matrix
  72036. */
  72037. setRow(index: number, row: Vector4): Matrix;
  72038. /**
  72039. * Compute the transpose of the matrix
  72040. * @returns the new transposed matrix
  72041. */
  72042. transpose(): Matrix;
  72043. /**
  72044. * Compute the transpose of the matrix and store it in a given matrix
  72045. * @param result defines the target matrix
  72046. * @returns the current matrix
  72047. */
  72048. transposeToRef(result: Matrix): Matrix;
  72049. /**
  72050. * Sets the index-th row of the current matrix with the given 4 x float values
  72051. * @param index defines the row index
  72052. * @param x defines the x component to set
  72053. * @param y defines the y component to set
  72054. * @param z defines the z component to set
  72055. * @param w defines the w component to set
  72056. * @returns the updated current matrix
  72057. */
  72058. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72059. /**
  72060. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72061. * @param scale defines the scale factor
  72062. * @returns a new matrix
  72063. */
  72064. scale(scale: number): Matrix;
  72065. /**
  72066. * Scale the current matrix values by a factor to a given result matrix
  72067. * @param scale defines the scale factor
  72068. * @param result defines the matrix to store the result
  72069. * @returns the current matrix
  72070. */
  72071. scaleToRef(scale: number, result: Matrix): Matrix;
  72072. /**
  72073. * Scale the current matrix values by a factor and add the result to a given matrix
  72074. * @param scale defines the scale factor
  72075. * @param result defines the Matrix to store the result
  72076. * @returns the current matrix
  72077. */
  72078. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72079. /**
  72080. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72081. * @param ref matrix to store the result
  72082. */
  72083. toNormalMatrix(ref: Matrix): void;
  72084. /**
  72085. * Gets only rotation part of the current matrix
  72086. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72087. */
  72088. getRotationMatrix(): Matrix;
  72089. /**
  72090. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72091. * @param result defines the target matrix to store data to
  72092. * @returns the current matrix
  72093. */
  72094. getRotationMatrixToRef(result: Matrix): Matrix;
  72095. /**
  72096. * Toggles model matrix from being right handed to left handed in place and vice versa
  72097. */
  72098. toggleModelMatrixHandInPlace(): void;
  72099. /**
  72100. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72101. */
  72102. toggleProjectionMatrixHandInPlace(): void;
  72103. /**
  72104. * Creates a matrix from an array
  72105. * @param array defines the source array
  72106. * @param offset defines an offset in the source array
  72107. * @returns a new Matrix set from the starting index of the given array
  72108. */
  72109. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72110. /**
  72111. * Copy the content of an array into a given matrix
  72112. * @param array defines the source array
  72113. * @param offset defines an offset in the source array
  72114. * @param result defines the target matrix
  72115. */
  72116. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72117. /**
  72118. * Stores an array into a matrix after having multiplied each component by a given factor
  72119. * @param array defines the source array
  72120. * @param offset defines the offset in the source array
  72121. * @param scale defines the scaling factor
  72122. * @param result defines the target matrix
  72123. */
  72124. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72125. /**
  72126. * Gets an identity matrix that must not be updated
  72127. */
  72128. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72129. /**
  72130. * Stores a list of values (16) inside a given matrix
  72131. * @param initialM11 defines 1st value of 1st row
  72132. * @param initialM12 defines 2nd value of 1st row
  72133. * @param initialM13 defines 3rd value of 1st row
  72134. * @param initialM14 defines 4th value of 1st row
  72135. * @param initialM21 defines 1st value of 2nd row
  72136. * @param initialM22 defines 2nd value of 2nd row
  72137. * @param initialM23 defines 3rd value of 2nd row
  72138. * @param initialM24 defines 4th value of 2nd row
  72139. * @param initialM31 defines 1st value of 3rd row
  72140. * @param initialM32 defines 2nd value of 3rd row
  72141. * @param initialM33 defines 3rd value of 3rd row
  72142. * @param initialM34 defines 4th value of 3rd row
  72143. * @param initialM41 defines 1st value of 4th row
  72144. * @param initialM42 defines 2nd value of 4th row
  72145. * @param initialM43 defines 3rd value of 4th row
  72146. * @param initialM44 defines 4th value of 4th row
  72147. * @param result defines the target matrix
  72148. */
  72149. 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;
  72150. /**
  72151. * Creates new matrix from a list of values (16)
  72152. * @param initialM11 defines 1st value of 1st row
  72153. * @param initialM12 defines 2nd value of 1st row
  72154. * @param initialM13 defines 3rd value of 1st row
  72155. * @param initialM14 defines 4th value of 1st row
  72156. * @param initialM21 defines 1st value of 2nd row
  72157. * @param initialM22 defines 2nd value of 2nd row
  72158. * @param initialM23 defines 3rd value of 2nd row
  72159. * @param initialM24 defines 4th value of 2nd row
  72160. * @param initialM31 defines 1st value of 3rd row
  72161. * @param initialM32 defines 2nd value of 3rd row
  72162. * @param initialM33 defines 3rd value of 3rd row
  72163. * @param initialM34 defines 4th value of 3rd row
  72164. * @param initialM41 defines 1st value of 4th row
  72165. * @param initialM42 defines 2nd value of 4th row
  72166. * @param initialM43 defines 3rd value of 4th row
  72167. * @param initialM44 defines 4th value of 4th row
  72168. * @returns the new matrix
  72169. */
  72170. 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;
  72171. /**
  72172. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72173. * @param scale defines the scale vector3
  72174. * @param rotation defines the rotation quaternion
  72175. * @param translation defines the translation vector3
  72176. * @returns a new matrix
  72177. */
  72178. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72179. /**
  72180. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72181. * @param scale defines the scale vector3
  72182. * @param rotation defines the rotation quaternion
  72183. * @param translation defines the translation vector3
  72184. * @param result defines the target matrix
  72185. */
  72186. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72187. /**
  72188. * Creates a new identity matrix
  72189. * @returns a new identity matrix
  72190. */
  72191. static Identity(): Matrix;
  72192. /**
  72193. * Creates a new identity matrix and stores the result in a given matrix
  72194. * @param result defines the target matrix
  72195. */
  72196. static IdentityToRef(result: Matrix): void;
  72197. /**
  72198. * Creates a new zero matrix
  72199. * @returns a new zero matrix
  72200. */
  72201. static Zero(): Matrix;
  72202. /**
  72203. * Creates a new rotation matrix for "angle" radians around the X axis
  72204. * @param angle defines the angle (in radians) to use
  72205. * @return the new matrix
  72206. */
  72207. static RotationX(angle: number): Matrix;
  72208. /**
  72209. * Creates a new matrix as the invert of a given matrix
  72210. * @param source defines the source matrix
  72211. * @returns the new matrix
  72212. */
  72213. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72214. /**
  72215. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72216. * @param angle defines the angle (in radians) to use
  72217. * @param result defines the target matrix
  72218. */
  72219. static RotationXToRef(angle: number, result: Matrix): void;
  72220. /**
  72221. * Creates a new rotation matrix for "angle" radians around the Y axis
  72222. * @param angle defines the angle (in radians) to use
  72223. * @return the new matrix
  72224. */
  72225. static RotationY(angle: number): Matrix;
  72226. /**
  72227. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72228. * @param angle defines the angle (in radians) to use
  72229. * @param result defines the target matrix
  72230. */
  72231. static RotationYToRef(angle: number, result: Matrix): void;
  72232. /**
  72233. * Creates a new rotation matrix for "angle" radians around the Z axis
  72234. * @param angle defines the angle (in radians) to use
  72235. * @return the new matrix
  72236. */
  72237. static RotationZ(angle: number): Matrix;
  72238. /**
  72239. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72240. * @param angle defines the angle (in radians) to use
  72241. * @param result defines the target matrix
  72242. */
  72243. static RotationZToRef(angle: number, result: Matrix): void;
  72244. /**
  72245. * Creates a new rotation matrix for "angle" radians around the given axis
  72246. * @param axis defines the axis to use
  72247. * @param angle defines the angle (in radians) to use
  72248. * @return the new matrix
  72249. */
  72250. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72251. /**
  72252. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72253. * @param axis defines the axis to use
  72254. * @param angle defines the angle (in radians) to use
  72255. * @param result defines the target matrix
  72256. */
  72257. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72258. /**
  72259. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72260. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72261. * @param from defines the vector to align
  72262. * @param to defines the vector to align to
  72263. * @param result defines the target matrix
  72264. */
  72265. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72266. /**
  72267. * Creates a rotation matrix
  72268. * @param yaw defines the yaw angle in radians (Y axis)
  72269. * @param pitch defines the pitch angle in radians (X axis)
  72270. * @param roll defines the roll angle in radians (X axis)
  72271. * @returns the new rotation matrix
  72272. */
  72273. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72274. /**
  72275. * Creates a rotation matrix and stores it in a given matrix
  72276. * @param yaw defines the yaw angle in radians (Y axis)
  72277. * @param pitch defines the pitch angle in radians (X axis)
  72278. * @param roll defines the roll angle in radians (X axis)
  72279. * @param result defines the target matrix
  72280. */
  72281. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72282. /**
  72283. * Creates a scaling matrix
  72284. * @param x defines the scale factor on X axis
  72285. * @param y defines the scale factor on Y axis
  72286. * @param z defines the scale factor on Z axis
  72287. * @returns the new matrix
  72288. */
  72289. static Scaling(x: number, y: number, z: number): Matrix;
  72290. /**
  72291. * Creates a scaling matrix and stores it in a given matrix
  72292. * @param x defines the scale factor on X axis
  72293. * @param y defines the scale factor on Y axis
  72294. * @param z defines the scale factor on Z axis
  72295. * @param result defines the target matrix
  72296. */
  72297. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72298. /**
  72299. * Creates a translation matrix
  72300. * @param x defines the translation on X axis
  72301. * @param y defines the translation on Y axis
  72302. * @param z defines the translationon Z axis
  72303. * @returns the new matrix
  72304. */
  72305. static Translation(x: number, y: number, z: number): Matrix;
  72306. /**
  72307. * Creates a translation matrix and stores it in a given matrix
  72308. * @param x defines the translation on X axis
  72309. * @param y defines the translation on Y axis
  72310. * @param z defines the translationon Z axis
  72311. * @param result defines the target matrix
  72312. */
  72313. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72314. /**
  72315. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72316. * @param startValue defines the start value
  72317. * @param endValue defines the end value
  72318. * @param gradient defines the gradient factor
  72319. * @returns the new matrix
  72320. */
  72321. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72322. /**
  72323. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72324. * @param startValue defines the start value
  72325. * @param endValue defines the end value
  72326. * @param gradient defines the gradient factor
  72327. * @param result defines the Matrix object where to store data
  72328. */
  72329. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72330. /**
  72331. * Builds a new matrix whose values are computed by:
  72332. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72333. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72334. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72335. * @param startValue defines the first matrix
  72336. * @param endValue defines the second matrix
  72337. * @param gradient defines the gradient between the two matrices
  72338. * @returns the new matrix
  72339. */
  72340. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72341. /**
  72342. * Update a matrix to values which are computed by:
  72343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72346. * @param startValue defines the first matrix
  72347. * @param endValue defines the second matrix
  72348. * @param gradient defines the gradient between the two matrices
  72349. * @param result defines the target matrix
  72350. */
  72351. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72352. /**
  72353. * 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"
  72354. * This function works in left handed mode
  72355. * @param eye defines the final position of the entity
  72356. * @param target defines where the entity should look at
  72357. * @param up defines the up vector for the entity
  72358. * @returns the new matrix
  72359. */
  72360. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72361. /**
  72362. * 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".
  72363. * This function works in left handed mode
  72364. * @param eye defines the final position of the entity
  72365. * @param target defines where the entity should look at
  72366. * @param up defines the up vector for the entity
  72367. * @param result defines the target matrix
  72368. */
  72369. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72370. /**
  72371. * 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"
  72372. * This function works in right handed mode
  72373. * @param eye defines the final position of the entity
  72374. * @param target defines where the entity should look at
  72375. * @param up defines the up vector for the entity
  72376. * @returns the new matrix
  72377. */
  72378. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72379. /**
  72380. * 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".
  72381. * This function works in right handed mode
  72382. * @param eye defines the final position of the entity
  72383. * @param target defines where the entity should look at
  72384. * @param up defines the up vector for the entity
  72385. * @param result defines the target matrix
  72386. */
  72387. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72388. /**
  72389. * Create a left-handed orthographic projection matrix
  72390. * @param width defines the viewport width
  72391. * @param height defines the viewport height
  72392. * @param znear defines the near clip plane
  72393. * @param zfar defines the far clip plane
  72394. * @returns a new matrix as a left-handed orthographic projection matrix
  72395. */
  72396. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72397. /**
  72398. * Store a left-handed orthographic projection to a given matrix
  72399. * @param width defines the viewport width
  72400. * @param height defines the viewport height
  72401. * @param znear defines the near clip plane
  72402. * @param zfar defines the far clip plane
  72403. * @param result defines the target matrix
  72404. */
  72405. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72406. /**
  72407. * Create a left-handed orthographic projection matrix
  72408. * @param left defines the viewport left coordinate
  72409. * @param right defines the viewport right coordinate
  72410. * @param bottom defines the viewport bottom coordinate
  72411. * @param top defines the viewport top coordinate
  72412. * @param znear defines the near clip plane
  72413. * @param zfar defines the far clip plane
  72414. * @returns a new matrix as a left-handed orthographic projection matrix
  72415. */
  72416. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72417. /**
  72418. * Stores a left-handed orthographic projection into a given matrix
  72419. * @param left defines the viewport left coordinate
  72420. * @param right defines the viewport right coordinate
  72421. * @param bottom defines the viewport bottom coordinate
  72422. * @param top defines the viewport top coordinate
  72423. * @param znear defines the near clip plane
  72424. * @param zfar defines the far clip plane
  72425. * @param result defines the target matrix
  72426. */
  72427. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72428. /**
  72429. * Creates a right-handed orthographic projection matrix
  72430. * @param left defines the viewport left coordinate
  72431. * @param right defines the viewport right coordinate
  72432. * @param bottom defines the viewport bottom coordinate
  72433. * @param top defines the viewport top coordinate
  72434. * @param znear defines the near clip plane
  72435. * @param zfar defines the far clip plane
  72436. * @returns a new matrix as a right-handed orthographic projection matrix
  72437. */
  72438. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72439. /**
  72440. * Stores a right-handed orthographic projection into a given matrix
  72441. * @param left defines the viewport left coordinate
  72442. * @param right defines the viewport right coordinate
  72443. * @param bottom defines the viewport bottom coordinate
  72444. * @param top defines the viewport top coordinate
  72445. * @param znear defines the near clip plane
  72446. * @param zfar defines the far clip plane
  72447. * @param result defines the target matrix
  72448. */
  72449. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72450. /**
  72451. * Creates a left-handed perspective projection matrix
  72452. * @param width defines the viewport width
  72453. * @param height defines the viewport height
  72454. * @param znear defines the near clip plane
  72455. * @param zfar defines the far clip plane
  72456. * @returns a new matrix as a left-handed perspective projection matrix
  72457. */
  72458. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72459. /**
  72460. * Creates a left-handed perspective projection matrix
  72461. * @param fov defines the horizontal field of view
  72462. * @param aspect defines the aspect ratio
  72463. * @param znear defines the near clip plane
  72464. * @param zfar defines the far clip plane
  72465. * @returns a new matrix as a left-handed perspective projection matrix
  72466. */
  72467. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72468. /**
  72469. * Stores a left-handed perspective projection into a given matrix
  72470. * @param fov defines the horizontal field of view
  72471. * @param aspect defines the aspect ratio
  72472. * @param znear defines the near clip plane
  72473. * @param zfar defines the far clip plane
  72474. * @param result defines the target matrix
  72475. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72476. */
  72477. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72478. /**
  72479. * Creates a right-handed perspective projection matrix
  72480. * @param fov defines the horizontal field of view
  72481. * @param aspect defines the aspect ratio
  72482. * @param znear defines the near clip plane
  72483. * @param zfar defines the far clip plane
  72484. * @returns a new matrix as a right-handed perspective projection matrix
  72485. */
  72486. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72487. /**
  72488. * Stores a right-handed perspective projection into a given matrix
  72489. * @param fov defines the horizontal field of view
  72490. * @param aspect defines the aspect ratio
  72491. * @param znear defines the near clip plane
  72492. * @param zfar defines the far clip plane
  72493. * @param result defines the target matrix
  72494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72495. */
  72496. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72497. /**
  72498. * Stores a perspective projection for WebVR info a given matrix
  72499. * @param fov defines the field of view
  72500. * @param znear defines the near clip plane
  72501. * @param zfar defines the far clip plane
  72502. * @param result defines the target matrix
  72503. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72504. */
  72505. static PerspectiveFovWebVRToRef(fov: {
  72506. upDegrees: number;
  72507. downDegrees: number;
  72508. leftDegrees: number;
  72509. rightDegrees: number;
  72510. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72511. /**
  72512. * Computes a complete transformation matrix
  72513. * @param viewport defines the viewport to use
  72514. * @param world defines the world matrix
  72515. * @param view defines the view matrix
  72516. * @param projection defines the projection matrix
  72517. * @param zmin defines the near clip plane
  72518. * @param zmax defines the far clip plane
  72519. * @returns the transformation matrix
  72520. */
  72521. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72522. /**
  72523. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72524. * @param matrix defines the matrix to use
  72525. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72526. */
  72527. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72528. /**
  72529. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72530. * @param matrix defines the matrix to use
  72531. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72532. */
  72533. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72534. /**
  72535. * Compute the transpose of a given matrix
  72536. * @param matrix defines the matrix to transpose
  72537. * @returns the new matrix
  72538. */
  72539. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72540. /**
  72541. * Compute the transpose of a matrix and store it in a target matrix
  72542. * @param matrix defines the matrix to transpose
  72543. * @param result defines the target matrix
  72544. */
  72545. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72546. /**
  72547. * Computes a reflection matrix from a plane
  72548. * @param plane defines the reflection plane
  72549. * @returns a new matrix
  72550. */
  72551. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72552. /**
  72553. * Computes a reflection matrix from a plane
  72554. * @param plane defines the reflection plane
  72555. * @param result defines the target matrix
  72556. */
  72557. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72558. /**
  72559. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72560. * @param xaxis defines the value of the 1st axis
  72561. * @param yaxis defines the value of the 2nd axis
  72562. * @param zaxis defines the value of the 3rd axis
  72563. * @param result defines the target matrix
  72564. */
  72565. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72566. /**
  72567. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72568. * @param quat defines the quaternion to use
  72569. * @param result defines the target matrix
  72570. */
  72571. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72572. }
  72573. /**
  72574. * @hidden
  72575. */
  72576. export class TmpVectors {
  72577. static Vector2: Vector2[];
  72578. static Vector3: Vector3[];
  72579. static Vector4: Vector4[];
  72580. static Quaternion: Quaternion[];
  72581. static Matrix: Matrix[];
  72582. }
  72583. }
  72584. declare module BABYLON {
  72585. /**
  72586. * Defines potential orientation for back face culling
  72587. */
  72588. export enum Orientation {
  72589. /**
  72590. * Clockwise
  72591. */
  72592. CW = 0,
  72593. /** Counter clockwise */
  72594. CCW = 1
  72595. }
  72596. /** Class used to represent a Bezier curve */
  72597. export class BezierCurve {
  72598. /**
  72599. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72600. * @param t defines the time
  72601. * @param x1 defines the left coordinate on X axis
  72602. * @param y1 defines the left coordinate on Y axis
  72603. * @param x2 defines the right coordinate on X axis
  72604. * @param y2 defines the right coordinate on Y axis
  72605. * @returns the interpolated value
  72606. */
  72607. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72608. }
  72609. /**
  72610. * Defines angle representation
  72611. */
  72612. export class Angle {
  72613. private _radians;
  72614. /**
  72615. * Creates an Angle object of "radians" radians (float).
  72616. * @param radians the angle in radians
  72617. */
  72618. constructor(radians: number);
  72619. /**
  72620. * Get value in degrees
  72621. * @returns the Angle value in degrees (float)
  72622. */
  72623. degrees(): number;
  72624. /**
  72625. * Get value in radians
  72626. * @returns the Angle value in radians (float)
  72627. */
  72628. radians(): number;
  72629. /**
  72630. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72631. * @param a defines first vector
  72632. * @param b defines second vector
  72633. * @returns a new Angle
  72634. */
  72635. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72636. /**
  72637. * Gets a new Angle object from the given float in radians
  72638. * @param radians defines the angle value in radians
  72639. * @returns a new Angle
  72640. */
  72641. static FromRadians(radians: number): Angle;
  72642. /**
  72643. * Gets a new Angle object from the given float in degrees
  72644. * @param degrees defines the angle value in degrees
  72645. * @returns a new Angle
  72646. */
  72647. static FromDegrees(degrees: number): Angle;
  72648. }
  72649. /**
  72650. * This represents an arc in a 2d space.
  72651. */
  72652. export class Arc2 {
  72653. /** Defines the start point of the arc */
  72654. startPoint: Vector2;
  72655. /** Defines the mid point of the arc */
  72656. midPoint: Vector2;
  72657. /** Defines the end point of the arc */
  72658. endPoint: Vector2;
  72659. /**
  72660. * Defines the center point of the arc.
  72661. */
  72662. centerPoint: Vector2;
  72663. /**
  72664. * Defines the radius of the arc.
  72665. */
  72666. radius: number;
  72667. /**
  72668. * Defines the angle of the arc (from mid point to end point).
  72669. */
  72670. angle: Angle;
  72671. /**
  72672. * Defines the start angle of the arc (from start point to middle point).
  72673. */
  72674. startAngle: Angle;
  72675. /**
  72676. * Defines the orientation of the arc (clock wise/counter clock wise).
  72677. */
  72678. orientation: Orientation;
  72679. /**
  72680. * Creates an Arc object from the three given points : start, middle and end.
  72681. * @param startPoint Defines the start point of the arc
  72682. * @param midPoint Defines the midlle point of the arc
  72683. * @param endPoint Defines the end point of the arc
  72684. */
  72685. constructor(
  72686. /** Defines the start point of the arc */
  72687. startPoint: Vector2,
  72688. /** Defines the mid point of the arc */
  72689. midPoint: Vector2,
  72690. /** Defines the end point of the arc */
  72691. endPoint: Vector2);
  72692. }
  72693. /**
  72694. * Represents a 2D path made up of multiple 2D points
  72695. */
  72696. export class Path2 {
  72697. private _points;
  72698. private _length;
  72699. /**
  72700. * If the path start and end point are the same
  72701. */
  72702. closed: boolean;
  72703. /**
  72704. * Creates a Path2 object from the starting 2D coordinates x and y.
  72705. * @param x the starting points x value
  72706. * @param y the starting points y value
  72707. */
  72708. constructor(x: number, y: number);
  72709. /**
  72710. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72711. * @param x the added points x value
  72712. * @param y the added points y value
  72713. * @returns the updated Path2.
  72714. */
  72715. addLineTo(x: number, y: number): Path2;
  72716. /**
  72717. * 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.
  72718. * @param midX middle point x value
  72719. * @param midY middle point y value
  72720. * @param endX end point x value
  72721. * @param endY end point y value
  72722. * @param numberOfSegments (default: 36)
  72723. * @returns the updated Path2.
  72724. */
  72725. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72726. /**
  72727. * Closes the Path2.
  72728. * @returns the Path2.
  72729. */
  72730. close(): Path2;
  72731. /**
  72732. * Gets the sum of the distance between each sequential point in the path
  72733. * @returns the Path2 total length (float).
  72734. */
  72735. length(): number;
  72736. /**
  72737. * Gets the points which construct the path
  72738. * @returns the Path2 internal array of points.
  72739. */
  72740. getPoints(): Vector2[];
  72741. /**
  72742. * Retreives the point at the distance aways from the starting point
  72743. * @param normalizedLengthPosition the length along the path to retreive the point from
  72744. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72745. */
  72746. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72747. /**
  72748. * Creates a new path starting from an x and y position
  72749. * @param x starting x value
  72750. * @param y starting y value
  72751. * @returns a new Path2 starting at the coordinates (x, y).
  72752. */
  72753. static StartingAt(x: number, y: number): Path2;
  72754. }
  72755. /**
  72756. * Represents a 3D path made up of multiple 3D points
  72757. */
  72758. export class Path3D {
  72759. /**
  72760. * an array of Vector3, the curve axis of the Path3D
  72761. */
  72762. path: Vector3[];
  72763. private _curve;
  72764. private _distances;
  72765. private _tangents;
  72766. private _normals;
  72767. private _binormals;
  72768. private _raw;
  72769. /**
  72770. * new Path3D(path, normal, raw)
  72771. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72772. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72773. * @param path an array of Vector3, the curve axis of the Path3D
  72774. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72775. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72776. */
  72777. constructor(
  72778. /**
  72779. * an array of Vector3, the curve axis of the Path3D
  72780. */
  72781. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72782. /**
  72783. * Returns the Path3D array of successive Vector3 designing its curve.
  72784. * @returns the Path3D array of successive Vector3 designing its curve.
  72785. */
  72786. getCurve(): Vector3[];
  72787. /**
  72788. * Returns an array populated with tangent vectors on each Path3D curve point.
  72789. * @returns an array populated with tangent vectors on each Path3D curve point.
  72790. */
  72791. getTangents(): Vector3[];
  72792. /**
  72793. * Returns an array populated with normal vectors on each Path3D curve point.
  72794. * @returns an array populated with normal vectors on each Path3D curve point.
  72795. */
  72796. getNormals(): Vector3[];
  72797. /**
  72798. * Returns an array populated with binormal vectors on each Path3D curve point.
  72799. * @returns an array populated with binormal vectors on each Path3D curve point.
  72800. */
  72801. getBinormals(): Vector3[];
  72802. /**
  72803. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72804. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72805. */
  72806. getDistances(): number[];
  72807. /**
  72808. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72809. * @param path path which all values are copied into the curves points
  72810. * @param firstNormal which should be projected onto the curve
  72811. * @returns the same object updated.
  72812. */
  72813. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72814. private _compute;
  72815. private _getFirstNonNullVector;
  72816. private _getLastNonNullVector;
  72817. private _normalVector;
  72818. }
  72819. /**
  72820. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72821. * A Curve3 is designed from a series of successive Vector3.
  72822. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72823. */
  72824. export class Curve3 {
  72825. private _points;
  72826. private _length;
  72827. /**
  72828. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72829. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72830. * @param v1 (Vector3) the control point
  72831. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72832. * @param nbPoints (integer) the wanted number of points in the curve
  72833. * @returns the created Curve3
  72834. */
  72835. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72836. /**
  72837. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72838. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72839. * @param v1 (Vector3) the first control point
  72840. * @param v2 (Vector3) the second control point
  72841. * @param v3 (Vector3) the end point of the Cubic Bezier
  72842. * @param nbPoints (integer) the wanted number of points in the curve
  72843. * @returns the created Curve3
  72844. */
  72845. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72846. /**
  72847. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72848. * @param p1 (Vector3) the origin point of the Hermite Spline
  72849. * @param t1 (Vector3) the tangent vector at the origin point
  72850. * @param p2 (Vector3) the end point of the Hermite Spline
  72851. * @param t2 (Vector3) the tangent vector at the end point
  72852. * @param nbPoints (integer) the wanted number of points in the curve
  72853. * @returns the created Curve3
  72854. */
  72855. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72856. /**
  72857. * Returns a Curve3 object along a CatmullRom Spline curve :
  72858. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72859. * @param nbPoints (integer) the wanted number of points between each curve control points
  72860. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72861. * @returns the created Curve3
  72862. */
  72863. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72864. /**
  72865. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72866. * A Curve3 is designed from a series of successive Vector3.
  72867. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72868. * @param points points which make up the curve
  72869. */
  72870. constructor(points: Vector3[]);
  72871. /**
  72872. * @returns the Curve3 stored array of successive Vector3
  72873. */
  72874. getPoints(): Vector3[];
  72875. /**
  72876. * @returns the computed length (float) of the curve.
  72877. */
  72878. length(): number;
  72879. /**
  72880. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72881. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72882. * curveA and curveB keep unchanged.
  72883. * @param curve the curve to continue from this curve
  72884. * @returns the newly constructed curve
  72885. */
  72886. continue(curve: DeepImmutable<Curve3>): Curve3;
  72887. private _computeLength;
  72888. }
  72889. }
  72890. declare module BABYLON {
  72891. /**
  72892. * This represents the main contract an easing function should follow.
  72893. * Easing functions are used throughout the animation system.
  72894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72895. */
  72896. export interface IEasingFunction {
  72897. /**
  72898. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72899. * of the easing function.
  72900. * The link below provides some of the most common examples of easing functions.
  72901. * @see https://easings.net/
  72902. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72903. * @returns the corresponding value on the curve defined by the easing function
  72904. */
  72905. ease(gradient: number): number;
  72906. }
  72907. /**
  72908. * Base class used for every default easing function.
  72909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72910. */
  72911. export class EasingFunction implements IEasingFunction {
  72912. /**
  72913. * Interpolation follows the mathematical formula associated with the easing function.
  72914. */
  72915. static readonly EASINGMODE_EASEIN: number;
  72916. /**
  72917. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72918. */
  72919. static readonly EASINGMODE_EASEOUT: number;
  72920. /**
  72921. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72922. */
  72923. static readonly EASINGMODE_EASEINOUT: number;
  72924. private _easingMode;
  72925. /**
  72926. * Sets the easing mode of the current function.
  72927. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72928. */
  72929. setEasingMode(easingMode: number): void;
  72930. /**
  72931. * Gets the current easing mode.
  72932. * @returns the easing mode
  72933. */
  72934. getEasingMode(): number;
  72935. /**
  72936. * @hidden
  72937. */
  72938. easeInCore(gradient: number): number;
  72939. /**
  72940. * Given an input gradient between 0 and 1, this returns the corresponding value
  72941. * of the easing function.
  72942. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72943. * @returns the corresponding value on the curve defined by the easing function
  72944. */
  72945. ease(gradient: number): number;
  72946. }
  72947. /**
  72948. * Easing function with a circle shape (see link below).
  72949. * @see https://easings.net/#easeInCirc
  72950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72951. */
  72952. export class CircleEase extends EasingFunction implements IEasingFunction {
  72953. /** @hidden */
  72954. easeInCore(gradient: number): number;
  72955. }
  72956. /**
  72957. * Easing function with a ease back shape (see link below).
  72958. * @see https://easings.net/#easeInBack
  72959. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72960. */
  72961. export class BackEase extends EasingFunction implements IEasingFunction {
  72962. /** Defines the amplitude of the function */
  72963. amplitude: number;
  72964. /**
  72965. * Instantiates a back ease easing
  72966. * @see https://easings.net/#easeInBack
  72967. * @param amplitude Defines the amplitude of the function
  72968. */
  72969. constructor(
  72970. /** Defines the amplitude of the function */
  72971. amplitude?: number);
  72972. /** @hidden */
  72973. easeInCore(gradient: number): number;
  72974. }
  72975. /**
  72976. * Easing function with a bouncing shape (see link below).
  72977. * @see https://easings.net/#easeInBounce
  72978. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72979. */
  72980. export class BounceEase extends EasingFunction implements IEasingFunction {
  72981. /** Defines the number of bounces */
  72982. bounces: number;
  72983. /** Defines the amplitude of the bounce */
  72984. bounciness: number;
  72985. /**
  72986. * Instantiates a bounce easing
  72987. * @see https://easings.net/#easeInBounce
  72988. * @param bounces Defines the number of bounces
  72989. * @param bounciness Defines the amplitude of the bounce
  72990. */
  72991. constructor(
  72992. /** Defines the number of bounces */
  72993. bounces?: number,
  72994. /** Defines the amplitude of the bounce */
  72995. bounciness?: number);
  72996. /** @hidden */
  72997. easeInCore(gradient: number): number;
  72998. }
  72999. /**
  73000. * Easing function with a power of 3 shape (see link below).
  73001. * @see https://easings.net/#easeInCubic
  73002. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73003. */
  73004. export class CubicEase extends EasingFunction implements IEasingFunction {
  73005. /** @hidden */
  73006. easeInCore(gradient: number): number;
  73007. }
  73008. /**
  73009. * Easing function with an elastic shape (see link below).
  73010. * @see https://easings.net/#easeInElastic
  73011. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73012. */
  73013. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73014. /** Defines the number of oscillations*/
  73015. oscillations: number;
  73016. /** Defines the amplitude of the oscillations*/
  73017. springiness: number;
  73018. /**
  73019. * Instantiates an elastic easing function
  73020. * @see https://easings.net/#easeInElastic
  73021. * @param oscillations Defines the number of oscillations
  73022. * @param springiness Defines the amplitude of the oscillations
  73023. */
  73024. constructor(
  73025. /** Defines the number of oscillations*/
  73026. oscillations?: number,
  73027. /** Defines the amplitude of the oscillations*/
  73028. springiness?: number);
  73029. /** @hidden */
  73030. easeInCore(gradient: number): number;
  73031. }
  73032. /**
  73033. * Easing function with an exponential shape (see link below).
  73034. * @see https://easings.net/#easeInExpo
  73035. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73036. */
  73037. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73038. /** Defines the exponent of the function */
  73039. exponent: number;
  73040. /**
  73041. * Instantiates an exponential easing function
  73042. * @see https://easings.net/#easeInExpo
  73043. * @param exponent Defines the exponent of the function
  73044. */
  73045. constructor(
  73046. /** Defines the exponent of the function */
  73047. exponent?: number);
  73048. /** @hidden */
  73049. easeInCore(gradient: number): number;
  73050. }
  73051. /**
  73052. * Easing function with a power shape (see link below).
  73053. * @see https://easings.net/#easeInQuad
  73054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73055. */
  73056. export class PowerEase extends EasingFunction implements IEasingFunction {
  73057. /** Defines the power of the function */
  73058. power: number;
  73059. /**
  73060. * Instantiates an power base easing function
  73061. * @see https://easings.net/#easeInQuad
  73062. * @param power Defines the power of the function
  73063. */
  73064. constructor(
  73065. /** Defines the power of the function */
  73066. power?: number);
  73067. /** @hidden */
  73068. easeInCore(gradient: number): number;
  73069. }
  73070. /**
  73071. * Easing function with a power of 2 shape (see link below).
  73072. * @see https://easings.net/#easeInQuad
  73073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73074. */
  73075. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73076. /** @hidden */
  73077. easeInCore(gradient: number): number;
  73078. }
  73079. /**
  73080. * Easing function with a power of 4 shape (see link below).
  73081. * @see https://easings.net/#easeInQuart
  73082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73083. */
  73084. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73085. /** @hidden */
  73086. easeInCore(gradient: number): number;
  73087. }
  73088. /**
  73089. * Easing function with a power of 5 shape (see link below).
  73090. * @see https://easings.net/#easeInQuint
  73091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73092. */
  73093. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73094. /** @hidden */
  73095. easeInCore(gradient: number): number;
  73096. }
  73097. /**
  73098. * Easing function with a sin shape (see link below).
  73099. * @see https://easings.net/#easeInSine
  73100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73101. */
  73102. export class SineEase extends EasingFunction implements IEasingFunction {
  73103. /** @hidden */
  73104. easeInCore(gradient: number): number;
  73105. }
  73106. /**
  73107. * Easing function with a bezier shape (see link below).
  73108. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73110. */
  73111. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73112. /** Defines the x component of the start tangent in the bezier curve */
  73113. x1: number;
  73114. /** Defines the y component of the start tangent in the bezier curve */
  73115. y1: number;
  73116. /** Defines the x component of the end tangent in the bezier curve */
  73117. x2: number;
  73118. /** Defines the y component of the end tangent in the bezier curve */
  73119. y2: number;
  73120. /**
  73121. * Instantiates a bezier function
  73122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73123. * @param x1 Defines the x component of the start tangent in the bezier curve
  73124. * @param y1 Defines the y component of the start tangent in the bezier curve
  73125. * @param x2 Defines the x component of the end tangent in the bezier curve
  73126. * @param y2 Defines the y component of the end tangent in the bezier curve
  73127. */
  73128. constructor(
  73129. /** Defines the x component of the start tangent in the bezier curve */
  73130. x1?: number,
  73131. /** Defines the y component of the start tangent in the bezier curve */
  73132. y1?: number,
  73133. /** Defines the x component of the end tangent in the bezier curve */
  73134. x2?: number,
  73135. /** Defines the y component of the end tangent in the bezier curve */
  73136. y2?: number);
  73137. /** @hidden */
  73138. easeInCore(gradient: number): number;
  73139. }
  73140. }
  73141. declare module BABYLON {
  73142. /**
  73143. * Class used to hold a RBG color
  73144. */
  73145. export class Color3 {
  73146. /**
  73147. * Defines the red component (between 0 and 1, default is 0)
  73148. */
  73149. r: number;
  73150. /**
  73151. * Defines the green component (between 0 and 1, default is 0)
  73152. */
  73153. g: number;
  73154. /**
  73155. * Defines the blue component (between 0 and 1, default is 0)
  73156. */
  73157. b: number;
  73158. /**
  73159. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73160. * @param r defines the red component (between 0 and 1, default is 0)
  73161. * @param g defines the green component (between 0 and 1, default is 0)
  73162. * @param b defines the blue component (between 0 and 1, default is 0)
  73163. */
  73164. constructor(
  73165. /**
  73166. * Defines the red component (between 0 and 1, default is 0)
  73167. */
  73168. r?: number,
  73169. /**
  73170. * Defines the green component (between 0 and 1, default is 0)
  73171. */
  73172. g?: number,
  73173. /**
  73174. * Defines the blue component (between 0 and 1, default is 0)
  73175. */
  73176. b?: number);
  73177. /**
  73178. * Creates a string with the Color3 current values
  73179. * @returns the string representation of the Color3 object
  73180. */
  73181. toString(): string;
  73182. /**
  73183. * Returns the string "Color3"
  73184. * @returns "Color3"
  73185. */
  73186. getClassName(): string;
  73187. /**
  73188. * Compute the Color3 hash code
  73189. * @returns an unique number that can be used to hash Color3 objects
  73190. */
  73191. getHashCode(): number;
  73192. /**
  73193. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73194. * @param array defines the array where to store the r,g,b components
  73195. * @param index defines an optional index in the target array to define where to start storing values
  73196. * @returns the current Color3 object
  73197. */
  73198. toArray(array: FloatArray, index?: number): Color3;
  73199. /**
  73200. * Returns a new Color4 object from the current Color3 and the given alpha
  73201. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73202. * @returns a new Color4 object
  73203. */
  73204. toColor4(alpha?: number): Color4;
  73205. /**
  73206. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73207. * @returns the new array
  73208. */
  73209. asArray(): number[];
  73210. /**
  73211. * Returns the luminance value
  73212. * @returns a float value
  73213. */
  73214. toLuminance(): number;
  73215. /**
  73216. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73217. * @param otherColor defines the second operand
  73218. * @returns the new Color3 object
  73219. */
  73220. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73221. /**
  73222. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73223. * @param otherColor defines the second operand
  73224. * @param result defines the Color3 object where to store the result
  73225. * @returns the current Color3
  73226. */
  73227. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73228. /**
  73229. * Determines equality between Color3 objects
  73230. * @param otherColor defines the second operand
  73231. * @returns true if the rgb values are equal to the given ones
  73232. */
  73233. equals(otherColor: DeepImmutable<Color3>): boolean;
  73234. /**
  73235. * Determines equality between the current Color3 object and a set of r,b,g values
  73236. * @param r defines the red component to check
  73237. * @param g defines the green component to check
  73238. * @param b defines the blue component to check
  73239. * @returns true if the rgb values are equal to the given ones
  73240. */
  73241. equalsFloats(r: number, g: number, b: number): boolean;
  73242. /**
  73243. * Multiplies in place each rgb value by scale
  73244. * @param scale defines the scaling factor
  73245. * @returns the updated Color3
  73246. */
  73247. scale(scale: number): Color3;
  73248. /**
  73249. * Multiplies the rgb values by scale and stores the result into "result"
  73250. * @param scale defines the scaling factor
  73251. * @param result defines the Color3 object where to store the result
  73252. * @returns the unmodified current Color3
  73253. */
  73254. scaleToRef(scale: number, result: Color3): Color3;
  73255. /**
  73256. * Scale the current Color3 values by a factor and add the result to a given Color3
  73257. * @param scale defines the scale factor
  73258. * @param result defines color to store the result into
  73259. * @returns the unmodified current Color3
  73260. */
  73261. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73262. /**
  73263. * Clamps the rgb values by the min and max values and stores the result into "result"
  73264. * @param min defines minimum clamping value (default is 0)
  73265. * @param max defines maximum clamping value (default is 1)
  73266. * @param result defines color to store the result into
  73267. * @returns the original Color3
  73268. */
  73269. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73270. /**
  73271. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73272. * @param otherColor defines the second operand
  73273. * @returns the new Color3
  73274. */
  73275. add(otherColor: DeepImmutable<Color3>): Color3;
  73276. /**
  73277. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73278. * @param otherColor defines the second operand
  73279. * @param result defines Color3 object to store the result into
  73280. * @returns the unmodified current Color3
  73281. */
  73282. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73283. /**
  73284. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73285. * @param otherColor defines the second operand
  73286. * @returns the new Color3
  73287. */
  73288. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73289. /**
  73290. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73291. * @param otherColor defines the second operand
  73292. * @param result defines Color3 object to store the result into
  73293. * @returns the unmodified current Color3
  73294. */
  73295. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73296. /**
  73297. * Copy the current object
  73298. * @returns a new Color3 copied the current one
  73299. */
  73300. clone(): Color3;
  73301. /**
  73302. * Copies the rgb values from the source in the current Color3
  73303. * @param source defines the source Color3 object
  73304. * @returns the updated Color3 object
  73305. */
  73306. copyFrom(source: DeepImmutable<Color3>): Color3;
  73307. /**
  73308. * Updates the Color3 rgb values from the given floats
  73309. * @param r defines the red component to read from
  73310. * @param g defines the green component to read from
  73311. * @param b defines the blue component to read from
  73312. * @returns the current Color3 object
  73313. */
  73314. copyFromFloats(r: number, g: number, b: number): Color3;
  73315. /**
  73316. * Updates the Color3 rgb values from the given floats
  73317. * @param r defines the red component to read from
  73318. * @param g defines the green component to read from
  73319. * @param b defines the blue component to read from
  73320. * @returns the current Color3 object
  73321. */
  73322. set(r: number, g: number, b: number): Color3;
  73323. /**
  73324. * Compute the Color3 hexadecimal code as a string
  73325. * @returns a string containing the hexadecimal representation of the Color3 object
  73326. */
  73327. toHexString(): string;
  73328. /**
  73329. * Computes a new Color3 converted from the current one to linear space
  73330. * @returns a new Color3 object
  73331. */
  73332. toLinearSpace(): Color3;
  73333. /**
  73334. * Converts current color in rgb space to HSV values
  73335. * @returns a new color3 representing the HSV values
  73336. */
  73337. toHSV(): Color3;
  73338. /**
  73339. * Converts current color in rgb space to HSV values
  73340. * @param result defines the Color3 where to store the HSV values
  73341. */
  73342. toHSVToRef(result: Color3): void;
  73343. /**
  73344. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73345. * @param convertedColor defines the Color3 object where to store the linear space version
  73346. * @returns the unmodified Color3
  73347. */
  73348. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73349. /**
  73350. * Computes a new Color3 converted from the current one to gamma space
  73351. * @returns a new Color3 object
  73352. */
  73353. toGammaSpace(): Color3;
  73354. /**
  73355. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73356. * @param convertedColor defines the Color3 object where to store the gamma space version
  73357. * @returns the unmodified Color3
  73358. */
  73359. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73360. private static _BlackReadOnly;
  73361. /**
  73362. * Convert Hue, saturation and value to a Color3 (RGB)
  73363. * @param hue defines the hue
  73364. * @param saturation defines the saturation
  73365. * @param value defines the value
  73366. * @param result defines the Color3 where to store the RGB values
  73367. */
  73368. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73369. /**
  73370. * Creates a new Color3 from the string containing valid hexadecimal values
  73371. * @param hex defines a string containing valid hexadecimal values
  73372. * @returns a new Color3 object
  73373. */
  73374. static FromHexString(hex: string): Color3;
  73375. /**
  73376. * Creates a new Color3 from the starting index of the given array
  73377. * @param array defines the source array
  73378. * @param offset defines an offset in the source array
  73379. * @returns a new Color3 object
  73380. */
  73381. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73382. /**
  73383. * Creates a new Color3 from integer values (< 256)
  73384. * @param r defines the red component to read from (value between 0 and 255)
  73385. * @param g defines the green component to read from (value between 0 and 255)
  73386. * @param b defines the blue component to read from (value between 0 and 255)
  73387. * @returns a new Color3 object
  73388. */
  73389. static FromInts(r: number, g: number, b: number): Color3;
  73390. /**
  73391. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73392. * @param start defines the start Color3 value
  73393. * @param end defines the end Color3 value
  73394. * @param amount defines the gradient value between start and end
  73395. * @returns a new Color3 object
  73396. */
  73397. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73398. /**
  73399. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73400. * @param left defines the start value
  73401. * @param right defines the end value
  73402. * @param amount defines the gradient factor
  73403. * @param result defines the Color3 object where to store the result
  73404. */
  73405. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73406. /**
  73407. * Returns a Color3 value containing a red color
  73408. * @returns a new Color3 object
  73409. */
  73410. static Red(): Color3;
  73411. /**
  73412. * Returns a Color3 value containing a green color
  73413. * @returns a new Color3 object
  73414. */
  73415. static Green(): Color3;
  73416. /**
  73417. * Returns a Color3 value containing a blue color
  73418. * @returns a new Color3 object
  73419. */
  73420. static Blue(): Color3;
  73421. /**
  73422. * Returns a Color3 value containing a black color
  73423. * @returns a new Color3 object
  73424. */
  73425. static Black(): Color3;
  73426. /**
  73427. * Gets a Color3 value containing a black color that must not be updated
  73428. */
  73429. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73430. /**
  73431. * Returns a Color3 value containing a white color
  73432. * @returns a new Color3 object
  73433. */
  73434. static White(): Color3;
  73435. /**
  73436. * Returns a Color3 value containing a purple color
  73437. * @returns a new Color3 object
  73438. */
  73439. static Purple(): Color3;
  73440. /**
  73441. * Returns a Color3 value containing a magenta color
  73442. * @returns a new Color3 object
  73443. */
  73444. static Magenta(): Color3;
  73445. /**
  73446. * Returns a Color3 value containing a yellow color
  73447. * @returns a new Color3 object
  73448. */
  73449. static Yellow(): Color3;
  73450. /**
  73451. * Returns a Color3 value containing a gray color
  73452. * @returns a new Color3 object
  73453. */
  73454. static Gray(): Color3;
  73455. /**
  73456. * Returns a Color3 value containing a teal color
  73457. * @returns a new Color3 object
  73458. */
  73459. static Teal(): Color3;
  73460. /**
  73461. * Returns a Color3 value containing a random color
  73462. * @returns a new Color3 object
  73463. */
  73464. static Random(): Color3;
  73465. }
  73466. /**
  73467. * Class used to hold a RBGA color
  73468. */
  73469. export class Color4 {
  73470. /**
  73471. * Defines the red component (between 0 and 1, default is 0)
  73472. */
  73473. r: number;
  73474. /**
  73475. * Defines the green component (between 0 and 1, default is 0)
  73476. */
  73477. g: number;
  73478. /**
  73479. * Defines the blue component (between 0 and 1, default is 0)
  73480. */
  73481. b: number;
  73482. /**
  73483. * Defines the alpha component (between 0 and 1, default is 1)
  73484. */
  73485. a: number;
  73486. /**
  73487. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73488. * @param r defines the red component (between 0 and 1, default is 0)
  73489. * @param g defines the green component (between 0 and 1, default is 0)
  73490. * @param b defines the blue component (between 0 and 1, default is 0)
  73491. * @param a defines the alpha component (between 0 and 1, default is 1)
  73492. */
  73493. constructor(
  73494. /**
  73495. * Defines the red component (between 0 and 1, default is 0)
  73496. */
  73497. r?: number,
  73498. /**
  73499. * Defines the green component (between 0 and 1, default is 0)
  73500. */
  73501. g?: number,
  73502. /**
  73503. * Defines the blue component (between 0 and 1, default is 0)
  73504. */
  73505. b?: number,
  73506. /**
  73507. * Defines the alpha component (between 0 and 1, default is 1)
  73508. */
  73509. a?: number);
  73510. /**
  73511. * Adds in place the given Color4 values to the current Color4 object
  73512. * @param right defines the second operand
  73513. * @returns the current updated Color4 object
  73514. */
  73515. addInPlace(right: DeepImmutable<Color4>): Color4;
  73516. /**
  73517. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73518. * @returns the new array
  73519. */
  73520. asArray(): number[];
  73521. /**
  73522. * Stores from the starting index in the given array the Color4 successive values
  73523. * @param array defines the array where to store the r,g,b components
  73524. * @param index defines an optional index in the target array to define where to start storing values
  73525. * @returns the current Color4 object
  73526. */
  73527. toArray(array: number[], index?: number): Color4;
  73528. /**
  73529. * Determines equality between Color4 objects
  73530. * @param otherColor defines the second operand
  73531. * @returns true if the rgba values are equal to the given ones
  73532. */
  73533. equals(otherColor: DeepImmutable<Color4>): boolean;
  73534. /**
  73535. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73536. * @param right defines the second operand
  73537. * @returns a new Color4 object
  73538. */
  73539. add(right: DeepImmutable<Color4>): Color4;
  73540. /**
  73541. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73542. * @param right defines the second operand
  73543. * @returns a new Color4 object
  73544. */
  73545. subtract(right: DeepImmutable<Color4>): Color4;
  73546. /**
  73547. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73548. * @param right defines the second operand
  73549. * @param result defines the Color4 object where to store the result
  73550. * @returns the current Color4 object
  73551. */
  73552. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73553. /**
  73554. * Creates a new Color4 with the current Color4 values multiplied by scale
  73555. * @param scale defines the scaling factor to apply
  73556. * @returns a new Color4 object
  73557. */
  73558. scale(scale: number): Color4;
  73559. /**
  73560. * Multiplies the current Color4 values by scale and stores the result in "result"
  73561. * @param scale defines the scaling factor to apply
  73562. * @param result defines the Color4 object where to store the result
  73563. * @returns the current unmodified Color4
  73564. */
  73565. scaleToRef(scale: number, result: Color4): Color4;
  73566. /**
  73567. * Scale the current Color4 values by a factor and add the result to a given Color4
  73568. * @param scale defines the scale factor
  73569. * @param result defines the Color4 object where to store the result
  73570. * @returns the unmodified current Color4
  73571. */
  73572. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73573. /**
  73574. * Clamps the rgb values by the min and max values and stores the result into "result"
  73575. * @param min defines minimum clamping value (default is 0)
  73576. * @param max defines maximum clamping value (default is 1)
  73577. * @param result defines color to store the result into.
  73578. * @returns the cuurent Color4
  73579. */
  73580. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73581. /**
  73582. * Multipy an Color4 value by another and return a new Color4 object
  73583. * @param color defines the Color4 value to multiply by
  73584. * @returns a new Color4 object
  73585. */
  73586. multiply(color: Color4): Color4;
  73587. /**
  73588. * Multipy a Color4 value by another and push the result in a reference value
  73589. * @param color defines the Color4 value to multiply by
  73590. * @param result defines the Color4 to fill the result in
  73591. * @returns the result Color4
  73592. */
  73593. multiplyToRef(color: Color4, result: Color4): Color4;
  73594. /**
  73595. * Creates a string with the Color4 current values
  73596. * @returns the string representation of the Color4 object
  73597. */
  73598. toString(): string;
  73599. /**
  73600. * Returns the string "Color4"
  73601. * @returns "Color4"
  73602. */
  73603. getClassName(): string;
  73604. /**
  73605. * Compute the Color4 hash code
  73606. * @returns an unique number that can be used to hash Color4 objects
  73607. */
  73608. getHashCode(): number;
  73609. /**
  73610. * Creates a new Color4 copied from the current one
  73611. * @returns a new Color4 object
  73612. */
  73613. clone(): Color4;
  73614. /**
  73615. * Copies the given Color4 values into the current one
  73616. * @param source defines the source Color4 object
  73617. * @returns the current updated Color4 object
  73618. */
  73619. copyFrom(source: Color4): Color4;
  73620. /**
  73621. * Copies the given float values into the current one
  73622. * @param r defines the red component to read from
  73623. * @param g defines the green component to read from
  73624. * @param b defines the blue component to read from
  73625. * @param a defines the alpha component to read from
  73626. * @returns the current updated Color4 object
  73627. */
  73628. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73629. /**
  73630. * Copies the given float values into the current one
  73631. * @param r defines the red component to read from
  73632. * @param g defines the green component to read from
  73633. * @param b defines the blue component to read from
  73634. * @param a defines the alpha component to read from
  73635. * @returns the current updated Color4 object
  73636. */
  73637. set(r: number, g: number, b: number, a: number): Color4;
  73638. /**
  73639. * Compute the Color4 hexadecimal code as a string
  73640. * @returns a string containing the hexadecimal representation of the Color4 object
  73641. */
  73642. toHexString(): string;
  73643. /**
  73644. * Computes a new Color4 converted from the current one to linear space
  73645. * @returns a new Color4 object
  73646. */
  73647. toLinearSpace(): Color4;
  73648. /**
  73649. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73650. * @param convertedColor defines the Color4 object where to store the linear space version
  73651. * @returns the unmodified Color4
  73652. */
  73653. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73654. /**
  73655. * Computes a new Color4 converted from the current one to gamma space
  73656. * @returns a new Color4 object
  73657. */
  73658. toGammaSpace(): Color4;
  73659. /**
  73660. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73661. * @param convertedColor defines the Color4 object where to store the gamma space version
  73662. * @returns the unmodified Color4
  73663. */
  73664. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73665. /**
  73666. * Creates a new Color4 from the string containing valid hexadecimal values
  73667. * @param hex defines a string containing valid hexadecimal values
  73668. * @returns a new Color4 object
  73669. */
  73670. static FromHexString(hex: string): Color4;
  73671. /**
  73672. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73673. * @param left defines the start value
  73674. * @param right defines the end value
  73675. * @param amount defines the gradient factor
  73676. * @returns a new Color4 object
  73677. */
  73678. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73679. /**
  73680. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73681. * @param left defines the start value
  73682. * @param right defines the end value
  73683. * @param amount defines the gradient factor
  73684. * @param result defines the Color4 object where to store data
  73685. */
  73686. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73687. /**
  73688. * Creates a new Color4 from a Color3 and an alpha value
  73689. * @param color3 defines the source Color3 to read from
  73690. * @param alpha defines the alpha component (1.0 by default)
  73691. * @returns a new Color4 object
  73692. */
  73693. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73694. /**
  73695. * Creates a new Color4 from the starting index element of the given array
  73696. * @param array defines the source array to read from
  73697. * @param offset defines the offset in the source array
  73698. * @returns a new Color4 object
  73699. */
  73700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73701. /**
  73702. * Creates a new Color3 from integer values (< 256)
  73703. * @param r defines the red component to read from (value between 0 and 255)
  73704. * @param g defines the green component to read from (value between 0 and 255)
  73705. * @param b defines the blue component to read from (value between 0 and 255)
  73706. * @param a defines the alpha component to read from (value between 0 and 255)
  73707. * @returns a new Color3 object
  73708. */
  73709. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73710. /**
  73711. * Check the content of a given array and convert it to an array containing RGBA data
  73712. * If the original array was already containing count * 4 values then it is returned directly
  73713. * @param colors defines the array to check
  73714. * @param count defines the number of RGBA data to expect
  73715. * @returns an array containing count * 4 values (RGBA)
  73716. */
  73717. static CheckColors4(colors: number[], count: number): number[];
  73718. }
  73719. /**
  73720. * @hidden
  73721. */
  73722. export class TmpColors {
  73723. static Color3: Color3[];
  73724. static Color4: Color4[];
  73725. }
  73726. }
  73727. declare module BABYLON {
  73728. /**
  73729. * Defines an interface which represents an animation key frame
  73730. */
  73731. export interface IAnimationKey {
  73732. /**
  73733. * Frame of the key frame
  73734. */
  73735. frame: number;
  73736. /**
  73737. * Value at the specifies key frame
  73738. */
  73739. value: any;
  73740. /**
  73741. * The input tangent for the cubic hermite spline
  73742. */
  73743. inTangent?: any;
  73744. /**
  73745. * The output tangent for the cubic hermite spline
  73746. */
  73747. outTangent?: any;
  73748. /**
  73749. * The animation interpolation type
  73750. */
  73751. interpolation?: AnimationKeyInterpolation;
  73752. }
  73753. /**
  73754. * Enum for the animation key frame interpolation type
  73755. */
  73756. export enum AnimationKeyInterpolation {
  73757. /**
  73758. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73759. */
  73760. STEP = 1
  73761. }
  73762. }
  73763. declare module BABYLON {
  73764. /**
  73765. * Represents the range of an animation
  73766. */
  73767. export class AnimationRange {
  73768. /**The name of the animation range**/
  73769. name: string;
  73770. /**The starting frame of the animation */
  73771. from: number;
  73772. /**The ending frame of the animation*/
  73773. to: number;
  73774. /**
  73775. * Initializes the range of an animation
  73776. * @param name The name of the animation range
  73777. * @param from The starting frame of the animation
  73778. * @param to The ending frame of the animation
  73779. */
  73780. constructor(
  73781. /**The name of the animation range**/
  73782. name: string,
  73783. /**The starting frame of the animation */
  73784. from: number,
  73785. /**The ending frame of the animation*/
  73786. to: number);
  73787. /**
  73788. * Makes a copy of the animation range
  73789. * @returns A copy of the animation range
  73790. */
  73791. clone(): AnimationRange;
  73792. }
  73793. }
  73794. declare module BABYLON {
  73795. /**
  73796. * Composed of a frame, and an action function
  73797. */
  73798. export class AnimationEvent {
  73799. /** The frame for which the event is triggered **/
  73800. frame: number;
  73801. /** The event to perform when triggered **/
  73802. action: (currentFrame: number) => void;
  73803. /** Specifies if the event should be triggered only once**/
  73804. onlyOnce?: boolean | undefined;
  73805. /**
  73806. * Specifies if the animation event is done
  73807. */
  73808. isDone: boolean;
  73809. /**
  73810. * Initializes the animation event
  73811. * @param frame The frame for which the event is triggered
  73812. * @param action The event to perform when triggered
  73813. * @param onlyOnce Specifies if the event should be triggered only once
  73814. */
  73815. constructor(
  73816. /** The frame for which the event is triggered **/
  73817. frame: number,
  73818. /** The event to perform when triggered **/
  73819. action: (currentFrame: number) => void,
  73820. /** Specifies if the event should be triggered only once**/
  73821. onlyOnce?: boolean | undefined);
  73822. /** @hidden */
  73823. _clone(): AnimationEvent;
  73824. }
  73825. }
  73826. declare module BABYLON {
  73827. /**
  73828. * Interface used to define a behavior
  73829. */
  73830. export interface Behavior<T> {
  73831. /** gets or sets behavior's name */
  73832. name: string;
  73833. /**
  73834. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73835. */
  73836. init(): void;
  73837. /**
  73838. * Called when the behavior is attached to a target
  73839. * @param target defines the target where the behavior is attached to
  73840. */
  73841. attach(target: T): void;
  73842. /**
  73843. * Called when the behavior is detached from its target
  73844. */
  73845. detach(): void;
  73846. }
  73847. /**
  73848. * Interface implemented by classes supporting behaviors
  73849. */
  73850. export interface IBehaviorAware<T> {
  73851. /**
  73852. * Attach a behavior
  73853. * @param behavior defines the behavior to attach
  73854. * @returns the current host
  73855. */
  73856. addBehavior(behavior: Behavior<T>): T;
  73857. /**
  73858. * Remove a behavior from the current object
  73859. * @param behavior defines the behavior to detach
  73860. * @returns the current host
  73861. */
  73862. removeBehavior(behavior: Behavior<T>): T;
  73863. /**
  73864. * Gets a behavior using its name to search
  73865. * @param name defines the name to search
  73866. * @returns the behavior or null if not found
  73867. */
  73868. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73869. }
  73870. }
  73871. declare module BABYLON {
  73872. /**
  73873. * Defines an array and its length.
  73874. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73875. */
  73876. export interface ISmartArrayLike<T> {
  73877. /**
  73878. * The data of the array.
  73879. */
  73880. data: Array<T>;
  73881. /**
  73882. * The active length of the array.
  73883. */
  73884. length: number;
  73885. }
  73886. /**
  73887. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73888. */
  73889. export class SmartArray<T> implements ISmartArrayLike<T> {
  73890. /**
  73891. * The full set of data from the array.
  73892. */
  73893. data: Array<T>;
  73894. /**
  73895. * The active length of the array.
  73896. */
  73897. length: number;
  73898. protected _id: number;
  73899. /**
  73900. * Instantiates a Smart Array.
  73901. * @param capacity defines the default capacity of the array.
  73902. */
  73903. constructor(capacity: number);
  73904. /**
  73905. * Pushes a value at the end of the active data.
  73906. * @param value defines the object to push in the array.
  73907. */
  73908. push(value: T): void;
  73909. /**
  73910. * Iterates over the active data and apply the lambda to them.
  73911. * @param func defines the action to apply on each value.
  73912. */
  73913. forEach(func: (content: T) => void): void;
  73914. /**
  73915. * Sorts the full sets of data.
  73916. * @param compareFn defines the comparison function to apply.
  73917. */
  73918. sort(compareFn: (a: T, b: T) => number): void;
  73919. /**
  73920. * Resets the active data to an empty array.
  73921. */
  73922. reset(): void;
  73923. /**
  73924. * Releases all the data from the array as well as the array.
  73925. */
  73926. dispose(): void;
  73927. /**
  73928. * Concats the active data with a given array.
  73929. * @param array defines the data to concatenate with.
  73930. */
  73931. concat(array: any): void;
  73932. /**
  73933. * Returns the position of a value in the active data.
  73934. * @param value defines the value to find the index for
  73935. * @returns the index if found in the active data otherwise -1
  73936. */
  73937. indexOf(value: T): number;
  73938. /**
  73939. * Returns whether an element is part of the active data.
  73940. * @param value defines the value to look for
  73941. * @returns true if found in the active data otherwise false
  73942. */
  73943. contains(value: T): boolean;
  73944. private static _GlobalId;
  73945. }
  73946. /**
  73947. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73948. * The data in this array can only be present once
  73949. */
  73950. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73951. private _duplicateId;
  73952. /**
  73953. * Pushes a value at the end of the active data.
  73954. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73955. * @param value defines the object to push in the array.
  73956. */
  73957. push(value: T): void;
  73958. /**
  73959. * Pushes a value at the end of the active data.
  73960. * If the data is already present, it won t be added again
  73961. * @param value defines the object to push in the array.
  73962. * @returns true if added false if it was already present
  73963. */
  73964. pushNoDuplicate(value: T): boolean;
  73965. /**
  73966. * Resets the active data to an empty array.
  73967. */
  73968. reset(): void;
  73969. /**
  73970. * Concats the active data with a given array.
  73971. * This ensures no dupplicate will be present in the result.
  73972. * @param array defines the data to concatenate with.
  73973. */
  73974. concatWithNoDuplicate(array: any): void;
  73975. }
  73976. }
  73977. declare module BABYLON {
  73978. /**
  73979. * @ignore
  73980. * This is a list of all the different input types that are available in the application.
  73981. * Fo instance: ArcRotateCameraGamepadInput...
  73982. */
  73983. export var CameraInputTypes: {};
  73984. /**
  73985. * This is the contract to implement in order to create a new input class.
  73986. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73987. */
  73988. export interface ICameraInput<TCamera extends Camera> {
  73989. /**
  73990. * Defines the camera the input is attached to.
  73991. */
  73992. camera: Nullable<TCamera>;
  73993. /**
  73994. * Gets the class name of the current intput.
  73995. * @returns the class name
  73996. */
  73997. getClassName(): string;
  73998. /**
  73999. * Get the friendly name associated with the input class.
  74000. * @returns the input friendly name
  74001. */
  74002. getSimpleName(): string;
  74003. /**
  74004. * Attach the input controls to a specific dom element to get the input from.
  74005. * @param element Defines the element the controls should be listened from
  74006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74007. */
  74008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74009. /**
  74010. * Detach the current controls from the specified dom element.
  74011. * @param element Defines the element to stop listening the inputs from
  74012. */
  74013. detachControl(element: Nullable<HTMLElement>): void;
  74014. /**
  74015. * Update the current camera state depending on the inputs that have been used this frame.
  74016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74017. */
  74018. checkInputs?: () => void;
  74019. }
  74020. /**
  74021. * Represents a map of input types to input instance or input index to input instance.
  74022. */
  74023. export interface CameraInputsMap<TCamera extends Camera> {
  74024. /**
  74025. * Accessor to the input by input type.
  74026. */
  74027. [name: string]: ICameraInput<TCamera>;
  74028. /**
  74029. * Accessor to the input by input index.
  74030. */
  74031. [idx: number]: ICameraInput<TCamera>;
  74032. }
  74033. /**
  74034. * This represents the input manager used within a camera.
  74035. * It helps dealing with all the different kind of input attached to a camera.
  74036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74037. */
  74038. export class CameraInputsManager<TCamera extends Camera> {
  74039. /**
  74040. * Defines the list of inputs attahed to the camera.
  74041. */
  74042. attached: CameraInputsMap<TCamera>;
  74043. /**
  74044. * Defines the dom element the camera is collecting inputs from.
  74045. * This is null if the controls have not been attached.
  74046. */
  74047. attachedElement: Nullable<HTMLElement>;
  74048. /**
  74049. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74050. */
  74051. noPreventDefault: boolean;
  74052. /**
  74053. * Defined the camera the input manager belongs to.
  74054. */
  74055. camera: TCamera;
  74056. /**
  74057. * Update the current camera state depending on the inputs that have been used this frame.
  74058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74059. */
  74060. checkInputs: () => void;
  74061. /**
  74062. * Instantiate a new Camera Input Manager.
  74063. * @param camera Defines the camera the input manager blongs to
  74064. */
  74065. constructor(camera: TCamera);
  74066. /**
  74067. * Add an input method to a camera
  74068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74069. * @param input camera input method
  74070. */
  74071. add(input: ICameraInput<TCamera>): void;
  74072. /**
  74073. * Remove a specific input method from a camera
  74074. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74075. * @param inputToRemove camera input method
  74076. */
  74077. remove(inputToRemove: ICameraInput<TCamera>): void;
  74078. /**
  74079. * Remove a specific input type from a camera
  74080. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74081. * @param inputType the type of the input to remove
  74082. */
  74083. removeByType(inputType: string): void;
  74084. private _addCheckInputs;
  74085. /**
  74086. * Attach the input controls to the currently attached dom element to listen the events from.
  74087. * @param input Defines the input to attach
  74088. */
  74089. attachInput(input: ICameraInput<TCamera>): void;
  74090. /**
  74091. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74092. * @param element Defines the dom element to collect the events from
  74093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74094. */
  74095. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74096. /**
  74097. * Detach the current manager inputs controls from a specific dom element.
  74098. * @param element Defines the dom element to collect the events from
  74099. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74100. */
  74101. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74102. /**
  74103. * Rebuild the dynamic inputCheck function from the current list of
  74104. * defined inputs in the manager.
  74105. */
  74106. rebuildInputCheck(): void;
  74107. /**
  74108. * Remove all attached input methods from a camera
  74109. */
  74110. clear(): void;
  74111. /**
  74112. * Serialize the current input manager attached to a camera.
  74113. * This ensures than once parsed,
  74114. * the input associated to the camera will be identical to the current ones
  74115. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74116. */
  74117. serialize(serializedCamera: any): void;
  74118. /**
  74119. * Parses an input manager serialized JSON to restore the previous list of inputs
  74120. * and states associated to a camera.
  74121. * @param parsedCamera Defines the JSON to parse
  74122. */
  74123. parse(parsedCamera: any): void;
  74124. }
  74125. }
  74126. declare module BABYLON {
  74127. /**
  74128. * Class used to store data that will be store in GPU memory
  74129. */
  74130. export class Buffer {
  74131. private _engine;
  74132. private _buffer;
  74133. /** @hidden */
  74134. _data: Nullable<DataArray>;
  74135. private _updatable;
  74136. private _instanced;
  74137. private _divisor;
  74138. /**
  74139. * Gets the byte stride.
  74140. */
  74141. readonly byteStride: number;
  74142. /**
  74143. * Constructor
  74144. * @param engine the engine
  74145. * @param data the data to use for this buffer
  74146. * @param updatable whether the data is updatable
  74147. * @param stride the stride (optional)
  74148. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74149. * @param instanced whether the buffer is instanced (optional)
  74150. * @param useBytes set to true if the stride in in bytes (optional)
  74151. * @param divisor sets an optional divisor for instances (1 by default)
  74152. */
  74153. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74154. /**
  74155. * Create a new VertexBuffer based on the current buffer
  74156. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74157. * @param offset defines offset in the buffer (0 by default)
  74158. * @param size defines the size in floats of attributes (position is 3 for instance)
  74159. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74160. * @param instanced defines if the vertex buffer contains indexed data
  74161. * @param useBytes defines if the offset and stride are in bytes *
  74162. * @param divisor sets an optional divisor for instances (1 by default)
  74163. * @returns the new vertex buffer
  74164. */
  74165. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74166. /**
  74167. * Gets a boolean indicating if the Buffer is updatable?
  74168. * @returns true if the buffer is updatable
  74169. */
  74170. isUpdatable(): boolean;
  74171. /**
  74172. * Gets current buffer's data
  74173. * @returns a DataArray or null
  74174. */
  74175. getData(): Nullable<DataArray>;
  74176. /**
  74177. * Gets underlying native buffer
  74178. * @returns underlying native buffer
  74179. */
  74180. getBuffer(): Nullable<DataBuffer>;
  74181. /**
  74182. * Gets the stride in float32 units (i.e. byte stride / 4).
  74183. * May not be an integer if the byte stride is not divisible by 4.
  74184. * DEPRECATED. Use byteStride instead.
  74185. * @returns the stride in float32 units
  74186. */
  74187. getStrideSize(): number;
  74188. /**
  74189. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74190. * @param data defines the data to store
  74191. */
  74192. create(data?: Nullable<DataArray>): void;
  74193. /** @hidden */
  74194. _rebuild(): void;
  74195. /**
  74196. * Update current buffer data
  74197. * @param data defines the data to store
  74198. */
  74199. update(data: DataArray): void;
  74200. /**
  74201. * Updates the data directly.
  74202. * @param data the new data
  74203. * @param offset the new offset
  74204. * @param vertexCount the vertex count (optional)
  74205. * @param useBytes set to true if the offset is in bytes
  74206. */
  74207. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74208. /**
  74209. * Release all resources
  74210. */
  74211. dispose(): void;
  74212. }
  74213. /**
  74214. * Specialized buffer used to store vertex data
  74215. */
  74216. export class VertexBuffer {
  74217. /** @hidden */
  74218. _buffer: Buffer;
  74219. private _kind;
  74220. private _size;
  74221. private _ownsBuffer;
  74222. private _instanced;
  74223. private _instanceDivisor;
  74224. /**
  74225. * The byte type.
  74226. */
  74227. static readonly BYTE: number;
  74228. /**
  74229. * The unsigned byte type.
  74230. */
  74231. static readonly UNSIGNED_BYTE: number;
  74232. /**
  74233. * The short type.
  74234. */
  74235. static readonly SHORT: number;
  74236. /**
  74237. * The unsigned short type.
  74238. */
  74239. static readonly UNSIGNED_SHORT: number;
  74240. /**
  74241. * The integer type.
  74242. */
  74243. static readonly INT: number;
  74244. /**
  74245. * The unsigned integer type.
  74246. */
  74247. static readonly UNSIGNED_INT: number;
  74248. /**
  74249. * The float type.
  74250. */
  74251. static readonly FLOAT: number;
  74252. /**
  74253. * Gets or sets the instance divisor when in instanced mode
  74254. */
  74255. instanceDivisor: number;
  74256. /**
  74257. * Gets the byte stride.
  74258. */
  74259. readonly byteStride: number;
  74260. /**
  74261. * Gets the byte offset.
  74262. */
  74263. readonly byteOffset: number;
  74264. /**
  74265. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74266. */
  74267. readonly normalized: boolean;
  74268. /**
  74269. * Gets the data type of each component in the array.
  74270. */
  74271. readonly type: number;
  74272. /**
  74273. * Constructor
  74274. * @param engine the engine
  74275. * @param data the data to use for this vertex buffer
  74276. * @param kind the vertex buffer kind
  74277. * @param updatable whether the data is updatable
  74278. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74279. * @param stride the stride (optional)
  74280. * @param instanced whether the buffer is instanced (optional)
  74281. * @param offset the offset of the data (optional)
  74282. * @param size the number of components (optional)
  74283. * @param type the type of the component (optional)
  74284. * @param normalized whether the data contains normalized data (optional)
  74285. * @param useBytes set to true if stride and offset are in bytes (optional)
  74286. * @param divisor defines the instance divisor to use (1 by default)
  74287. */
  74288. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  74289. /** @hidden */
  74290. _rebuild(): void;
  74291. /**
  74292. * Returns the kind of the VertexBuffer (string)
  74293. * @returns a string
  74294. */
  74295. getKind(): string;
  74296. /**
  74297. * Gets a boolean indicating if the VertexBuffer is updatable?
  74298. * @returns true if the buffer is updatable
  74299. */
  74300. isUpdatable(): boolean;
  74301. /**
  74302. * Gets current buffer's data
  74303. * @returns a DataArray or null
  74304. */
  74305. getData(): Nullable<DataArray>;
  74306. /**
  74307. * Gets underlying native buffer
  74308. * @returns underlying native buffer
  74309. */
  74310. getBuffer(): Nullable<DataBuffer>;
  74311. /**
  74312. * Gets the stride in float32 units (i.e. byte stride / 4).
  74313. * May not be an integer if the byte stride is not divisible by 4.
  74314. * DEPRECATED. Use byteStride instead.
  74315. * @returns the stride in float32 units
  74316. */
  74317. getStrideSize(): number;
  74318. /**
  74319. * Returns the offset as a multiple of the type byte length.
  74320. * DEPRECATED. Use byteOffset instead.
  74321. * @returns the offset in bytes
  74322. */
  74323. getOffset(): number;
  74324. /**
  74325. * Returns the number of components per vertex attribute (integer)
  74326. * @returns the size in float
  74327. */
  74328. getSize(): number;
  74329. /**
  74330. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74331. * @returns true if this buffer is instanced
  74332. */
  74333. getIsInstanced(): boolean;
  74334. /**
  74335. * Returns the instancing divisor, zero for non-instanced (integer).
  74336. * @returns a number
  74337. */
  74338. getInstanceDivisor(): number;
  74339. /**
  74340. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74341. * @param data defines the data to store
  74342. */
  74343. create(data?: DataArray): void;
  74344. /**
  74345. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74346. * This function will create a new buffer if the current one is not updatable
  74347. * @param data defines the data to store
  74348. */
  74349. update(data: DataArray): void;
  74350. /**
  74351. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74352. * Returns the directly updated WebGLBuffer.
  74353. * @param data the new data
  74354. * @param offset the new offset
  74355. * @param useBytes set to true if the offset is in bytes
  74356. */
  74357. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74358. /**
  74359. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74360. */
  74361. dispose(): void;
  74362. /**
  74363. * Enumerates each value of this vertex buffer as numbers.
  74364. * @param count the number of values to enumerate
  74365. * @param callback the callback function called for each value
  74366. */
  74367. forEach(count: number, callback: (value: number, index: number) => void): void;
  74368. /**
  74369. * Positions
  74370. */
  74371. static readonly PositionKind: string;
  74372. /**
  74373. * Normals
  74374. */
  74375. static readonly NormalKind: string;
  74376. /**
  74377. * Tangents
  74378. */
  74379. static readonly TangentKind: string;
  74380. /**
  74381. * Texture coordinates
  74382. */
  74383. static readonly UVKind: string;
  74384. /**
  74385. * Texture coordinates 2
  74386. */
  74387. static readonly UV2Kind: string;
  74388. /**
  74389. * Texture coordinates 3
  74390. */
  74391. static readonly UV3Kind: string;
  74392. /**
  74393. * Texture coordinates 4
  74394. */
  74395. static readonly UV4Kind: string;
  74396. /**
  74397. * Texture coordinates 5
  74398. */
  74399. static readonly UV5Kind: string;
  74400. /**
  74401. * Texture coordinates 6
  74402. */
  74403. static readonly UV6Kind: string;
  74404. /**
  74405. * Colors
  74406. */
  74407. static readonly ColorKind: string;
  74408. /**
  74409. * Matrix indices (for bones)
  74410. */
  74411. static readonly MatricesIndicesKind: string;
  74412. /**
  74413. * Matrix weights (for bones)
  74414. */
  74415. static readonly MatricesWeightsKind: string;
  74416. /**
  74417. * Additional matrix indices (for bones)
  74418. */
  74419. static readonly MatricesIndicesExtraKind: string;
  74420. /**
  74421. * Additional matrix weights (for bones)
  74422. */
  74423. static readonly MatricesWeightsExtraKind: string;
  74424. /**
  74425. * Deduces the stride given a kind.
  74426. * @param kind The kind string to deduce
  74427. * @returns The deduced stride
  74428. */
  74429. static DeduceStride(kind: string): number;
  74430. /**
  74431. * Gets the byte length of the given type.
  74432. * @param type the type
  74433. * @returns the number of bytes
  74434. */
  74435. static GetTypeByteLength(type: number): number;
  74436. /**
  74437. * Enumerates each value of the given parameters as numbers.
  74438. * @param data the data to enumerate
  74439. * @param byteOffset the byte offset of the data
  74440. * @param byteStride the byte stride of the data
  74441. * @param componentCount the number of components per element
  74442. * @param componentType the type of the component
  74443. * @param count the number of values to enumerate
  74444. * @param normalized whether the data is normalized
  74445. * @param callback the callback function called for each value
  74446. */
  74447. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74448. private static _GetFloatValue;
  74449. }
  74450. }
  74451. declare module BABYLON {
  74452. /**
  74453. * @hidden
  74454. */
  74455. export class IntersectionInfo {
  74456. bu: Nullable<number>;
  74457. bv: Nullable<number>;
  74458. distance: number;
  74459. faceId: number;
  74460. subMeshId: number;
  74461. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74462. }
  74463. }
  74464. declare module BABYLON {
  74465. /**
  74466. * Represens a plane by the equation ax + by + cz + d = 0
  74467. */
  74468. export class Plane {
  74469. private static _TmpMatrix;
  74470. /**
  74471. * Normal of the plane (a,b,c)
  74472. */
  74473. normal: Vector3;
  74474. /**
  74475. * d component of the plane
  74476. */
  74477. d: number;
  74478. /**
  74479. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74480. * @param a a component of the plane
  74481. * @param b b component of the plane
  74482. * @param c c component of the plane
  74483. * @param d d component of the plane
  74484. */
  74485. constructor(a: number, b: number, c: number, d: number);
  74486. /**
  74487. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74488. */
  74489. asArray(): number[];
  74490. /**
  74491. * @returns a new plane copied from the current Plane.
  74492. */
  74493. clone(): Plane;
  74494. /**
  74495. * @returns the string "Plane".
  74496. */
  74497. getClassName(): string;
  74498. /**
  74499. * @returns the Plane hash code.
  74500. */
  74501. getHashCode(): number;
  74502. /**
  74503. * Normalize the current Plane in place.
  74504. * @returns the updated Plane.
  74505. */
  74506. normalize(): Plane;
  74507. /**
  74508. * Applies a transformation the plane and returns the result
  74509. * @param transformation the transformation matrix to be applied to the plane
  74510. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74511. */
  74512. transform(transformation: DeepImmutable<Matrix>): Plane;
  74513. /**
  74514. * Calcualtte the dot product between the point and the plane normal
  74515. * @param point point to calculate the dot product with
  74516. * @returns the dot product (float) of the point coordinates and the plane normal.
  74517. */
  74518. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74519. /**
  74520. * Updates the current Plane from the plane defined by the three given points.
  74521. * @param point1 one of the points used to contruct the plane
  74522. * @param point2 one of the points used to contruct the plane
  74523. * @param point3 one of the points used to contruct the plane
  74524. * @returns the updated Plane.
  74525. */
  74526. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74527. /**
  74528. * Checks if the plane is facing a given direction
  74529. * @param direction the direction to check if the plane is facing
  74530. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74531. * @returns True is the vector "direction" is the same side than the plane normal.
  74532. */
  74533. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74534. /**
  74535. * Calculates the distance to a point
  74536. * @param point point to calculate distance to
  74537. * @returns the signed distance (float) from the given point to the Plane.
  74538. */
  74539. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74540. /**
  74541. * Creates a plane from an array
  74542. * @param array the array to create a plane from
  74543. * @returns a new Plane from the given array.
  74544. */
  74545. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74546. /**
  74547. * Creates a plane from three points
  74548. * @param point1 point used to create the plane
  74549. * @param point2 point used to create the plane
  74550. * @param point3 point used to create the plane
  74551. * @returns a new Plane defined by the three given points.
  74552. */
  74553. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74554. /**
  74555. * Creates a plane from an origin point and a normal
  74556. * @param origin origin of the plane to be constructed
  74557. * @param normal normal of the plane to be constructed
  74558. * @returns a new Plane the normal vector to this plane at the given origin point.
  74559. * Note : the vector "normal" is updated because normalized.
  74560. */
  74561. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74562. /**
  74563. * Calculates the distance from a plane and a point
  74564. * @param origin origin of the plane to be constructed
  74565. * @param normal normal of the plane to be constructed
  74566. * @param point point to calculate distance to
  74567. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74568. */
  74569. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74570. }
  74571. }
  74572. declare module BABYLON {
  74573. /**
  74574. * Class used to store bounding sphere information
  74575. */
  74576. export class BoundingSphere {
  74577. /**
  74578. * Gets the center of the bounding sphere in local space
  74579. */
  74580. readonly center: Vector3;
  74581. /**
  74582. * Radius of the bounding sphere in local space
  74583. */
  74584. radius: number;
  74585. /**
  74586. * Gets the center of the bounding sphere in world space
  74587. */
  74588. readonly centerWorld: Vector3;
  74589. /**
  74590. * Radius of the bounding sphere in world space
  74591. */
  74592. radiusWorld: number;
  74593. /**
  74594. * Gets the minimum vector in local space
  74595. */
  74596. readonly minimum: Vector3;
  74597. /**
  74598. * Gets the maximum vector in local space
  74599. */
  74600. readonly maximum: Vector3;
  74601. private _worldMatrix;
  74602. private static readonly TmpVector3;
  74603. /**
  74604. * Creates a new bounding sphere
  74605. * @param min defines the minimum vector (in local space)
  74606. * @param max defines the maximum vector (in local space)
  74607. * @param worldMatrix defines the new world matrix
  74608. */
  74609. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74610. /**
  74611. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74612. * @param min defines the new minimum vector (in local space)
  74613. * @param max defines the new maximum vector (in local space)
  74614. * @param worldMatrix defines the new world matrix
  74615. */
  74616. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74617. /**
  74618. * Scale the current bounding sphere by applying a scale factor
  74619. * @param factor defines the scale factor to apply
  74620. * @returns the current bounding box
  74621. */
  74622. scale(factor: number): BoundingSphere;
  74623. /**
  74624. * Gets the world matrix of the bounding box
  74625. * @returns a matrix
  74626. */
  74627. getWorldMatrix(): DeepImmutable<Matrix>;
  74628. /** @hidden */
  74629. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74630. /**
  74631. * Tests if the bounding sphere is intersecting the frustum planes
  74632. * @param frustumPlanes defines the frustum planes to test
  74633. * @returns true if there is an intersection
  74634. */
  74635. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74636. /**
  74637. * Tests if the bounding sphere center is in between the frustum planes.
  74638. * Used for optimistic fast inclusion.
  74639. * @param frustumPlanes defines the frustum planes to test
  74640. * @returns true if the sphere center is in between the frustum planes
  74641. */
  74642. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74643. /**
  74644. * Tests if a point is inside the bounding sphere
  74645. * @param point defines the point to test
  74646. * @returns true if the point is inside the bounding sphere
  74647. */
  74648. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74649. /**
  74650. * Checks if two sphere intersct
  74651. * @param sphere0 sphere 0
  74652. * @param sphere1 sphere 1
  74653. * @returns true if the speres intersect
  74654. */
  74655. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74656. }
  74657. }
  74658. declare module BABYLON {
  74659. /**
  74660. * Class used to store bounding box information
  74661. */
  74662. export class BoundingBox implements ICullable {
  74663. /**
  74664. * Gets the 8 vectors representing the bounding box in local space
  74665. */
  74666. readonly vectors: Vector3[];
  74667. /**
  74668. * Gets the center of the bounding box in local space
  74669. */
  74670. readonly center: Vector3;
  74671. /**
  74672. * Gets the center of the bounding box in world space
  74673. */
  74674. readonly centerWorld: Vector3;
  74675. /**
  74676. * Gets the extend size in local space
  74677. */
  74678. readonly extendSize: Vector3;
  74679. /**
  74680. * Gets the extend size in world space
  74681. */
  74682. readonly extendSizeWorld: Vector3;
  74683. /**
  74684. * Gets the OBB (object bounding box) directions
  74685. */
  74686. readonly directions: Vector3[];
  74687. /**
  74688. * Gets the 8 vectors representing the bounding box in world space
  74689. */
  74690. readonly vectorsWorld: Vector3[];
  74691. /**
  74692. * Gets the minimum vector in world space
  74693. */
  74694. readonly minimumWorld: Vector3;
  74695. /**
  74696. * Gets the maximum vector in world space
  74697. */
  74698. readonly maximumWorld: Vector3;
  74699. /**
  74700. * Gets the minimum vector in local space
  74701. */
  74702. readonly minimum: Vector3;
  74703. /**
  74704. * Gets the maximum vector in local space
  74705. */
  74706. readonly maximum: Vector3;
  74707. private _worldMatrix;
  74708. private static readonly TmpVector3;
  74709. /**
  74710. * @hidden
  74711. */
  74712. _tag: number;
  74713. /**
  74714. * Creates a new bounding box
  74715. * @param min defines the minimum vector (in local space)
  74716. * @param max defines the maximum vector (in local space)
  74717. * @param worldMatrix defines the new world matrix
  74718. */
  74719. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74720. /**
  74721. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74722. * @param min defines the new minimum vector (in local space)
  74723. * @param max defines the new maximum vector (in local space)
  74724. * @param worldMatrix defines the new world matrix
  74725. */
  74726. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74727. /**
  74728. * Scale the current bounding box by applying a scale factor
  74729. * @param factor defines the scale factor to apply
  74730. * @returns the current bounding box
  74731. */
  74732. scale(factor: number): BoundingBox;
  74733. /**
  74734. * Gets the world matrix of the bounding box
  74735. * @returns a matrix
  74736. */
  74737. getWorldMatrix(): DeepImmutable<Matrix>;
  74738. /** @hidden */
  74739. _update(world: DeepImmutable<Matrix>): void;
  74740. /**
  74741. * Tests if the bounding box is intersecting the frustum planes
  74742. * @param frustumPlanes defines the frustum planes to test
  74743. * @returns true if there is an intersection
  74744. */
  74745. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74746. /**
  74747. * Tests if the bounding box is entirely inside the frustum planes
  74748. * @param frustumPlanes defines the frustum planes to test
  74749. * @returns true if there is an inclusion
  74750. */
  74751. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74752. /**
  74753. * Tests if a point is inside the bounding box
  74754. * @param point defines the point to test
  74755. * @returns true if the point is inside the bounding box
  74756. */
  74757. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74758. /**
  74759. * Tests if the bounding box intersects with a bounding sphere
  74760. * @param sphere defines the sphere to test
  74761. * @returns true if there is an intersection
  74762. */
  74763. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74764. /**
  74765. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74766. * @param min defines the min vector to use
  74767. * @param max defines the max vector to use
  74768. * @returns true if there is an intersection
  74769. */
  74770. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74771. /**
  74772. * Tests if two bounding boxes are intersections
  74773. * @param box0 defines the first box to test
  74774. * @param box1 defines the second box to test
  74775. * @returns true if there is an intersection
  74776. */
  74777. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74778. /**
  74779. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74780. * @param minPoint defines the minimum vector of the bounding box
  74781. * @param maxPoint defines the maximum vector of the bounding box
  74782. * @param sphereCenter defines the sphere center
  74783. * @param sphereRadius defines the sphere radius
  74784. * @returns true if there is an intersection
  74785. */
  74786. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74787. /**
  74788. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74789. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74790. * @param frustumPlanes defines the frustum planes to test
  74791. * @return true if there is an inclusion
  74792. */
  74793. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74794. /**
  74795. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74796. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74797. * @param frustumPlanes defines the frustum planes to test
  74798. * @return true if there is an intersection
  74799. */
  74800. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74801. }
  74802. }
  74803. declare module BABYLON {
  74804. /** @hidden */
  74805. export class Collider {
  74806. /** Define if a collision was found */
  74807. collisionFound: boolean;
  74808. /**
  74809. * Define last intersection point in local space
  74810. */
  74811. intersectionPoint: Vector3;
  74812. /**
  74813. * Define last collided mesh
  74814. */
  74815. collidedMesh: Nullable<AbstractMesh>;
  74816. private _collisionPoint;
  74817. private _planeIntersectionPoint;
  74818. private _tempVector;
  74819. private _tempVector2;
  74820. private _tempVector3;
  74821. private _tempVector4;
  74822. private _edge;
  74823. private _baseToVertex;
  74824. private _destinationPoint;
  74825. private _slidePlaneNormal;
  74826. private _displacementVector;
  74827. /** @hidden */
  74828. _radius: Vector3;
  74829. /** @hidden */
  74830. _retry: number;
  74831. private _velocity;
  74832. private _basePoint;
  74833. private _epsilon;
  74834. /** @hidden */
  74835. _velocityWorldLength: number;
  74836. /** @hidden */
  74837. _basePointWorld: Vector3;
  74838. private _velocityWorld;
  74839. private _normalizedVelocity;
  74840. /** @hidden */
  74841. _initialVelocity: Vector3;
  74842. /** @hidden */
  74843. _initialPosition: Vector3;
  74844. private _nearestDistance;
  74845. private _collisionMask;
  74846. collisionMask: number;
  74847. /**
  74848. * Gets the plane normal used to compute the sliding response (in local space)
  74849. */
  74850. readonly slidePlaneNormal: Vector3;
  74851. /** @hidden */
  74852. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74853. /** @hidden */
  74854. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74855. /** @hidden */
  74856. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74857. /** @hidden */
  74858. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74859. /** @hidden */
  74860. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74861. /** @hidden */
  74862. _getResponse(pos: Vector3, vel: Vector3): void;
  74863. }
  74864. }
  74865. declare module BABYLON {
  74866. /**
  74867. * Interface for cullable objects
  74868. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74869. */
  74870. export interface ICullable {
  74871. /**
  74872. * Checks if the object or part of the object is in the frustum
  74873. * @param frustumPlanes Camera near/planes
  74874. * @returns true if the object is in frustum otherwise false
  74875. */
  74876. isInFrustum(frustumPlanes: Plane[]): boolean;
  74877. /**
  74878. * Checks if a cullable object (mesh...) is in the camera frustum
  74879. * Unlike isInFrustum this cheks the full bounding box
  74880. * @param frustumPlanes Camera near/planes
  74881. * @returns true if the object is in frustum otherwise false
  74882. */
  74883. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74884. }
  74885. /**
  74886. * Info for a bounding data of a mesh
  74887. */
  74888. export class BoundingInfo implements ICullable {
  74889. /**
  74890. * Bounding box for the mesh
  74891. */
  74892. readonly boundingBox: BoundingBox;
  74893. /**
  74894. * Bounding sphere for the mesh
  74895. */
  74896. readonly boundingSphere: BoundingSphere;
  74897. private _isLocked;
  74898. private static readonly TmpVector3;
  74899. /**
  74900. * Constructs bounding info
  74901. * @param minimum min vector of the bounding box/sphere
  74902. * @param maximum max vector of the bounding box/sphere
  74903. * @param worldMatrix defines the new world matrix
  74904. */
  74905. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74906. /**
  74907. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74908. * @param min defines the new minimum vector (in local space)
  74909. * @param max defines the new maximum vector (in local space)
  74910. * @param worldMatrix defines the new world matrix
  74911. */
  74912. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74913. /**
  74914. * min vector of the bounding box/sphere
  74915. */
  74916. readonly minimum: Vector3;
  74917. /**
  74918. * max vector of the bounding box/sphere
  74919. */
  74920. readonly maximum: Vector3;
  74921. /**
  74922. * If the info is locked and won't be updated to avoid perf overhead
  74923. */
  74924. isLocked: boolean;
  74925. /**
  74926. * Updates the bounding sphere and box
  74927. * @param world world matrix to be used to update
  74928. */
  74929. update(world: DeepImmutable<Matrix>): void;
  74930. /**
  74931. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74932. * @param center New center of the bounding info
  74933. * @param extend New extend of the bounding info
  74934. * @returns the current bounding info
  74935. */
  74936. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74937. /**
  74938. * Scale the current bounding info by applying a scale factor
  74939. * @param factor defines the scale factor to apply
  74940. * @returns the current bounding info
  74941. */
  74942. scale(factor: number): BoundingInfo;
  74943. /**
  74944. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74945. * @param frustumPlanes defines the frustum to test
  74946. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74947. * @returns true if the bounding info is in the frustum planes
  74948. */
  74949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74950. /**
  74951. * Gets the world distance between the min and max points of the bounding box
  74952. */
  74953. readonly diagonalLength: number;
  74954. /**
  74955. * Checks if a cullable object (mesh...) is in the camera frustum
  74956. * Unlike isInFrustum this cheks the full bounding box
  74957. * @param frustumPlanes Camera near/planes
  74958. * @returns true if the object is in frustum otherwise false
  74959. */
  74960. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74961. /** @hidden */
  74962. _checkCollision(collider: Collider): boolean;
  74963. /**
  74964. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74965. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74966. * @param point the point to check intersection with
  74967. * @returns if the point intersects
  74968. */
  74969. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74970. /**
  74971. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74972. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74973. * @param boundingInfo the bounding info to check intersection with
  74974. * @param precise if the intersection should be done using OBB
  74975. * @returns if the bounding info intersects
  74976. */
  74977. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74978. }
  74979. }
  74980. declare module BABYLON {
  74981. /**
  74982. * Extracts minimum and maximum values from a list of indexed positions
  74983. * @param positions defines the positions to use
  74984. * @param indices defines the indices to the positions
  74985. * @param indexStart defines the start index
  74986. * @param indexCount defines the end index
  74987. * @param bias defines bias value to add to the result
  74988. * @return minimum and maximum values
  74989. */
  74990. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74991. minimum: Vector3;
  74992. maximum: Vector3;
  74993. };
  74994. /**
  74995. * Extracts minimum and maximum values from a list of positions
  74996. * @param positions defines the positions to use
  74997. * @param start defines the start index in the positions array
  74998. * @param count defines the number of positions to handle
  74999. * @param bias defines bias value to add to the result
  75000. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75001. * @return minimum and maximum values
  75002. */
  75003. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75004. minimum: Vector3;
  75005. maximum: Vector3;
  75006. };
  75007. }
  75008. declare module BABYLON {
  75009. /** @hidden */
  75010. export class WebGLDataBuffer extends DataBuffer {
  75011. private _buffer;
  75012. constructor(resource: WebGLBuffer);
  75013. readonly underlyingResource: any;
  75014. }
  75015. }
  75016. declare module BABYLON {
  75017. /** @hidden */
  75018. export class WebGLPipelineContext implements IPipelineContext {
  75019. engine: ThinEngine;
  75020. program: Nullable<WebGLProgram>;
  75021. context?: WebGLRenderingContext;
  75022. vertexShader?: WebGLShader;
  75023. fragmentShader?: WebGLShader;
  75024. isParallelCompiled: boolean;
  75025. onCompiled?: () => void;
  75026. transformFeedback?: WebGLTransformFeedback | null;
  75027. readonly isAsync: boolean;
  75028. readonly isReady: boolean;
  75029. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75030. }
  75031. }
  75032. declare module BABYLON {
  75033. interface ThinEngine {
  75034. /**
  75035. * Create an uniform buffer
  75036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75037. * @param elements defines the content of the uniform buffer
  75038. * @returns the webGL uniform buffer
  75039. */
  75040. createUniformBuffer(elements: FloatArray): DataBuffer;
  75041. /**
  75042. * Create a dynamic uniform buffer
  75043. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75044. * @param elements defines the content of the uniform buffer
  75045. * @returns the webGL uniform buffer
  75046. */
  75047. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75048. /**
  75049. * Update an existing uniform buffer
  75050. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75051. * @param uniformBuffer defines the target uniform buffer
  75052. * @param elements defines the content to update
  75053. * @param offset defines the offset in the uniform buffer where update should start
  75054. * @param count defines the size of the data to update
  75055. */
  75056. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75057. /**
  75058. * Bind an uniform buffer to the current webGL context
  75059. * @param buffer defines the buffer to bind
  75060. */
  75061. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75062. /**
  75063. * Bind a buffer to the current webGL context at a given location
  75064. * @param buffer defines the buffer to bind
  75065. * @param location defines the index where to bind the buffer
  75066. */
  75067. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75068. /**
  75069. * Bind a specific block at a given index in a specific shader program
  75070. * @param pipelineContext defines the pipeline context to use
  75071. * @param blockName defines the block name
  75072. * @param index defines the index where to bind the block
  75073. */
  75074. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75075. }
  75076. }
  75077. declare module BABYLON {
  75078. /**
  75079. * Uniform buffer objects.
  75080. *
  75081. * Handles blocks of uniform on the GPU.
  75082. *
  75083. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75084. *
  75085. * For more information, please refer to :
  75086. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75087. */
  75088. export class UniformBuffer {
  75089. private _engine;
  75090. private _buffer;
  75091. private _data;
  75092. private _bufferData;
  75093. private _dynamic?;
  75094. private _uniformLocations;
  75095. private _uniformSizes;
  75096. private _uniformLocationPointer;
  75097. private _needSync;
  75098. private _noUBO;
  75099. private _currentEffect;
  75100. /** @hidden */
  75101. _alreadyBound: boolean;
  75102. private static _MAX_UNIFORM_SIZE;
  75103. private static _tempBuffer;
  75104. /**
  75105. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75106. * This is dynamic to allow compat with webgl 1 and 2.
  75107. * You will need to pass the name of the uniform as well as the value.
  75108. */
  75109. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75110. /**
  75111. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75112. * This is dynamic to allow compat with webgl 1 and 2.
  75113. * You will need to pass the name of the uniform as well as the value.
  75114. */
  75115. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75116. /**
  75117. * Lambda to Update a single float in a uniform buffer.
  75118. * This is dynamic to allow compat with webgl 1 and 2.
  75119. * You will need to pass the name of the uniform as well as the value.
  75120. */
  75121. updateFloat: (name: string, x: number) => void;
  75122. /**
  75123. * Lambda to Update a vec2 of float in a uniform buffer.
  75124. * This is dynamic to allow compat with webgl 1 and 2.
  75125. * You will need to pass the name of the uniform as well as the value.
  75126. */
  75127. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75128. /**
  75129. * Lambda to Update a vec3 of float in a uniform buffer.
  75130. * This is dynamic to allow compat with webgl 1 and 2.
  75131. * You will need to pass the name of the uniform as well as the value.
  75132. */
  75133. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75134. /**
  75135. * Lambda to Update a vec4 of float in a uniform buffer.
  75136. * This is dynamic to allow compat with webgl 1 and 2.
  75137. * You will need to pass the name of the uniform as well as the value.
  75138. */
  75139. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75140. /**
  75141. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75142. * This is dynamic to allow compat with webgl 1 and 2.
  75143. * You will need to pass the name of the uniform as well as the value.
  75144. */
  75145. updateMatrix: (name: string, mat: Matrix) => void;
  75146. /**
  75147. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75148. * This is dynamic to allow compat with webgl 1 and 2.
  75149. * You will need to pass the name of the uniform as well as the value.
  75150. */
  75151. updateVector3: (name: string, vector: Vector3) => void;
  75152. /**
  75153. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75154. * This is dynamic to allow compat with webgl 1 and 2.
  75155. * You will need to pass the name of the uniform as well as the value.
  75156. */
  75157. updateVector4: (name: string, vector: Vector4) => void;
  75158. /**
  75159. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75160. * This is dynamic to allow compat with webgl 1 and 2.
  75161. * You will need to pass the name of the uniform as well as the value.
  75162. */
  75163. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75164. /**
  75165. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75166. * This is dynamic to allow compat with webgl 1 and 2.
  75167. * You will need to pass the name of the uniform as well as the value.
  75168. */
  75169. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75170. /**
  75171. * Instantiates a new Uniform buffer objects.
  75172. *
  75173. * Handles blocks of uniform on the GPU.
  75174. *
  75175. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75176. *
  75177. * For more information, please refer to :
  75178. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75179. * @param engine Define the engine the buffer is associated with
  75180. * @param data Define the data contained in the buffer
  75181. * @param dynamic Define if the buffer is updatable
  75182. */
  75183. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75184. /**
  75185. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75186. * or just falling back on setUniformXXX calls.
  75187. */
  75188. readonly useUbo: boolean;
  75189. /**
  75190. * Indicates if the WebGL underlying uniform buffer is in sync
  75191. * with the javascript cache data.
  75192. */
  75193. readonly isSync: boolean;
  75194. /**
  75195. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75196. * Also, a dynamic UniformBuffer will disable cache verification and always
  75197. * update the underlying WebGL uniform buffer to the GPU.
  75198. * @returns if Dynamic, otherwise false
  75199. */
  75200. isDynamic(): boolean;
  75201. /**
  75202. * The data cache on JS side.
  75203. * @returns the underlying data as a float array
  75204. */
  75205. getData(): Float32Array;
  75206. /**
  75207. * The underlying WebGL Uniform buffer.
  75208. * @returns the webgl buffer
  75209. */
  75210. getBuffer(): Nullable<DataBuffer>;
  75211. /**
  75212. * std140 layout specifies how to align data within an UBO structure.
  75213. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75214. * for specs.
  75215. */
  75216. private _fillAlignment;
  75217. /**
  75218. * Adds an uniform in the buffer.
  75219. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75220. * for the layout to be correct !
  75221. * @param name Name of the uniform, as used in the uniform block in the shader.
  75222. * @param size Data size, or data directly.
  75223. */
  75224. addUniform(name: string, size: number | number[]): void;
  75225. /**
  75226. * Adds a Matrix 4x4 to the uniform buffer.
  75227. * @param name Name of the uniform, as used in the uniform block in the shader.
  75228. * @param mat A 4x4 matrix.
  75229. */
  75230. addMatrix(name: string, mat: Matrix): void;
  75231. /**
  75232. * Adds a vec2 to the uniform buffer.
  75233. * @param name Name of the uniform, as used in the uniform block in the shader.
  75234. * @param x Define the x component value of the vec2
  75235. * @param y Define the y component value of the vec2
  75236. */
  75237. addFloat2(name: string, x: number, y: number): void;
  75238. /**
  75239. * Adds a vec3 to the uniform buffer.
  75240. * @param name Name of the uniform, as used in the uniform block in the shader.
  75241. * @param x Define the x component value of the vec3
  75242. * @param y Define the y component value of the vec3
  75243. * @param z Define the z component value of the vec3
  75244. */
  75245. addFloat3(name: string, x: number, y: number, z: number): void;
  75246. /**
  75247. * Adds a vec3 to the uniform buffer.
  75248. * @param name Name of the uniform, as used in the uniform block in the shader.
  75249. * @param color Define the vec3 from a Color
  75250. */
  75251. addColor3(name: string, color: Color3): void;
  75252. /**
  75253. * Adds a vec4 to the uniform buffer.
  75254. * @param name Name of the uniform, as used in the uniform block in the shader.
  75255. * @param color Define the rgb components from a Color
  75256. * @param alpha Define the a component of the vec4
  75257. */
  75258. addColor4(name: string, color: Color3, alpha: number): void;
  75259. /**
  75260. * Adds a vec3 to the uniform buffer.
  75261. * @param name Name of the uniform, as used in the uniform block in the shader.
  75262. * @param vector Define the vec3 components from a Vector
  75263. */
  75264. addVector3(name: string, vector: Vector3): void;
  75265. /**
  75266. * Adds a Matrix 3x3 to the uniform buffer.
  75267. * @param name Name of the uniform, as used in the uniform block in the shader.
  75268. */
  75269. addMatrix3x3(name: string): void;
  75270. /**
  75271. * Adds a Matrix 2x2 to the uniform buffer.
  75272. * @param name Name of the uniform, as used in the uniform block in the shader.
  75273. */
  75274. addMatrix2x2(name: string): void;
  75275. /**
  75276. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75277. */
  75278. create(): void;
  75279. /** @hidden */
  75280. _rebuild(): void;
  75281. /**
  75282. * Updates the WebGL Uniform Buffer on the GPU.
  75283. * If the `dynamic` flag is set to true, no cache comparison is done.
  75284. * Otherwise, the buffer will be updated only if the cache differs.
  75285. */
  75286. update(): void;
  75287. /**
  75288. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75289. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75290. * @param data Define the flattened data
  75291. * @param size Define the size of the data.
  75292. */
  75293. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75294. private _valueCache;
  75295. private _cacheMatrix;
  75296. private _updateMatrix3x3ForUniform;
  75297. private _updateMatrix3x3ForEffect;
  75298. private _updateMatrix2x2ForEffect;
  75299. private _updateMatrix2x2ForUniform;
  75300. private _updateFloatForEffect;
  75301. private _updateFloatForUniform;
  75302. private _updateFloat2ForEffect;
  75303. private _updateFloat2ForUniform;
  75304. private _updateFloat3ForEffect;
  75305. private _updateFloat3ForUniform;
  75306. private _updateFloat4ForEffect;
  75307. private _updateFloat4ForUniform;
  75308. private _updateMatrixForEffect;
  75309. private _updateMatrixForUniform;
  75310. private _updateVector3ForEffect;
  75311. private _updateVector3ForUniform;
  75312. private _updateVector4ForEffect;
  75313. private _updateVector4ForUniform;
  75314. private _updateColor3ForEffect;
  75315. private _updateColor3ForUniform;
  75316. private _updateColor4ForEffect;
  75317. private _updateColor4ForUniform;
  75318. /**
  75319. * Sets a sampler uniform on the effect.
  75320. * @param name Define the name of the sampler.
  75321. * @param texture Define the texture to set in the sampler
  75322. */
  75323. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75324. /**
  75325. * Directly updates the value of the uniform in the cache AND on the GPU.
  75326. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75327. * @param data Define the flattened data
  75328. */
  75329. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75330. /**
  75331. * Binds this uniform buffer to an effect.
  75332. * @param effect Define the effect to bind the buffer to
  75333. * @param name Name of the uniform block in the shader.
  75334. */
  75335. bindToEffect(effect: Effect, name: string): void;
  75336. /**
  75337. * Disposes the uniform buffer.
  75338. */
  75339. dispose(): void;
  75340. }
  75341. }
  75342. declare module BABYLON {
  75343. /**
  75344. * Enum that determines the text-wrapping mode to use.
  75345. */
  75346. export enum InspectableType {
  75347. /**
  75348. * Checkbox for booleans
  75349. */
  75350. Checkbox = 0,
  75351. /**
  75352. * Sliders for numbers
  75353. */
  75354. Slider = 1,
  75355. /**
  75356. * Vector3
  75357. */
  75358. Vector3 = 2,
  75359. /**
  75360. * Quaternions
  75361. */
  75362. Quaternion = 3,
  75363. /**
  75364. * Color3
  75365. */
  75366. Color3 = 4,
  75367. /**
  75368. * String
  75369. */
  75370. String = 5
  75371. }
  75372. /**
  75373. * Interface used to define custom inspectable properties.
  75374. * This interface is used by the inspector to display custom property grids
  75375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75376. */
  75377. export interface IInspectable {
  75378. /**
  75379. * Gets the label to display
  75380. */
  75381. label: string;
  75382. /**
  75383. * Gets the name of the property to edit
  75384. */
  75385. propertyName: string;
  75386. /**
  75387. * Gets the type of the editor to use
  75388. */
  75389. type: InspectableType;
  75390. /**
  75391. * Gets the minimum value of the property when using in "slider" mode
  75392. */
  75393. min?: number;
  75394. /**
  75395. * Gets the maximum value of the property when using in "slider" mode
  75396. */
  75397. max?: number;
  75398. /**
  75399. * Gets the setp to use when using in "slider" mode
  75400. */
  75401. step?: number;
  75402. }
  75403. }
  75404. declare module BABYLON {
  75405. /**
  75406. * Class used to provide helper for timing
  75407. */
  75408. export class TimingTools {
  75409. /**
  75410. * Polyfill for setImmediate
  75411. * @param action defines the action to execute after the current execution block
  75412. */
  75413. static SetImmediate(action: () => void): void;
  75414. }
  75415. }
  75416. declare module BABYLON {
  75417. /**
  75418. * Class used to enable instatition of objects by class name
  75419. */
  75420. export class InstantiationTools {
  75421. /**
  75422. * Use this object to register external classes like custom textures or material
  75423. * to allow the laoders to instantiate them
  75424. */
  75425. static RegisteredExternalClasses: {
  75426. [key: string]: Object;
  75427. };
  75428. /**
  75429. * Tries to instantiate a new object from a given class name
  75430. * @param className defines the class name to instantiate
  75431. * @returns the new object or null if the system was not able to do the instantiation
  75432. */
  75433. static Instantiate(className: string): any;
  75434. }
  75435. }
  75436. declare module BABYLON {
  75437. /**
  75438. * Define options used to create a depth texture
  75439. */
  75440. export class DepthTextureCreationOptions {
  75441. /** Specifies whether or not a stencil should be allocated in the texture */
  75442. generateStencil?: boolean;
  75443. /** Specifies whether or not bilinear filtering is enable on the texture */
  75444. bilinearFiltering?: boolean;
  75445. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75446. comparisonFunction?: number;
  75447. /** Specifies if the created texture is a cube texture */
  75448. isCube?: boolean;
  75449. }
  75450. }
  75451. declare module BABYLON {
  75452. interface ThinEngine {
  75453. /**
  75454. * Creates a depth stencil cube texture.
  75455. * This is only available in WebGL 2.
  75456. * @param size The size of face edge in the cube texture.
  75457. * @param options The options defining the cube texture.
  75458. * @returns The cube texture
  75459. */
  75460. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75461. /**
  75462. * Creates a cube texture
  75463. * @param rootUrl defines the url where the files to load is located
  75464. * @param scene defines the current scene
  75465. * @param files defines the list of files to load (1 per face)
  75466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75467. * @param onLoad defines an optional callback raised when the texture is loaded
  75468. * @param onError defines an optional callback raised if there is an issue to load the texture
  75469. * @param format defines the format of the data
  75470. * @param forcedExtension defines the extension to use to pick the right loader
  75471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75474. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75475. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75476. * @returns the cube texture as an InternalTexture
  75477. */
  75478. 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;
  75479. /**
  75480. * Creates a cube texture
  75481. * @param rootUrl defines the url where the files to load is located
  75482. * @param scene defines the current scene
  75483. * @param files defines the list of files to load (1 per face)
  75484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75485. * @param onLoad defines an optional callback raised when the texture is loaded
  75486. * @param onError defines an optional callback raised if there is an issue to load the texture
  75487. * @param format defines the format of the data
  75488. * @param forcedExtension defines the extension to use to pick the right loader
  75489. * @returns the cube texture as an InternalTexture
  75490. */
  75491. 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;
  75492. /**
  75493. * Creates a cube texture
  75494. * @param rootUrl defines the url where the files to load is located
  75495. * @param scene defines the current scene
  75496. * @param files defines the list of files to load (1 per face)
  75497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75498. * @param onLoad defines an optional callback raised when the texture is loaded
  75499. * @param onError defines an optional callback raised if there is an issue to load the texture
  75500. * @param format defines the format of the data
  75501. * @param forcedExtension defines the extension to use to pick the right loader
  75502. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75505. * @returns the cube texture as an InternalTexture
  75506. */
  75507. 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;
  75508. /** @hidden */
  75509. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75510. /** @hidden */
  75511. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75512. /** @hidden */
  75513. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75514. /** @hidden */
  75515. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75516. /**
  75517. * @hidden
  75518. */
  75519. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75520. }
  75521. }
  75522. declare module BABYLON {
  75523. /**
  75524. * Class for creating a cube texture
  75525. */
  75526. export class CubeTexture extends BaseTexture {
  75527. private _delayedOnLoad;
  75528. /**
  75529. * The url of the texture
  75530. */
  75531. url: string;
  75532. /**
  75533. * Gets or sets the center of the bounding box associated with the cube texture.
  75534. * It must define where the camera used to render the texture was set
  75535. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75536. */
  75537. boundingBoxPosition: Vector3;
  75538. private _boundingBoxSize;
  75539. /**
  75540. * Gets or sets the size of the bounding box associated with the cube texture
  75541. * When defined, the cubemap will switch to local mode
  75542. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75543. * @example https://www.babylonjs-playground.com/#RNASML
  75544. */
  75545. /**
  75546. * Returns the bounding box size
  75547. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75548. */
  75549. boundingBoxSize: Vector3;
  75550. protected _rotationY: number;
  75551. /**
  75552. * Sets texture matrix rotation angle around Y axis in radians.
  75553. */
  75554. /**
  75555. * Gets texture matrix rotation angle around Y axis radians.
  75556. */
  75557. rotationY: number;
  75558. /**
  75559. * Are mip maps generated for this texture or not.
  75560. */
  75561. readonly noMipmap: boolean;
  75562. private _noMipmap;
  75563. private _files;
  75564. protected _forcedExtension: Nullable<string>;
  75565. private _extensions;
  75566. private _textureMatrix;
  75567. private _format;
  75568. private _createPolynomials;
  75569. /** @hidden */
  75570. _prefiltered: boolean;
  75571. /**
  75572. * Creates a cube texture from an array of image urls
  75573. * @param files defines an array of image urls
  75574. * @param scene defines the hosting scene
  75575. * @param noMipmap specifies if mip maps are not used
  75576. * @returns a cube texture
  75577. */
  75578. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75579. /**
  75580. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75581. * @param url defines the url of the prefiltered texture
  75582. * @param scene defines the scene the texture is attached to
  75583. * @param forcedExtension defines the extension of the file if different from the url
  75584. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75585. * @return the prefiltered texture
  75586. */
  75587. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75588. /**
  75589. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75590. * as prefiltered data.
  75591. * @param rootUrl defines the url of the texture or the root name of the six images
  75592. * @param scene defines the scene the texture is attached to
  75593. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75594. * @param noMipmap defines if mipmaps should be created or not
  75595. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75596. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75597. * @param onError defines a callback triggered in case of error during load
  75598. * @param format defines the internal format to use for the texture once loaded
  75599. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75600. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75601. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75602. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75603. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75604. * @return the cube texture
  75605. */
  75606. 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);
  75607. /**
  75608. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75609. */
  75610. readonly isPrefiltered: boolean;
  75611. /**
  75612. * Get the current class name of the texture useful for serialization or dynamic coding.
  75613. * @returns "CubeTexture"
  75614. */
  75615. getClassName(): string;
  75616. /**
  75617. * Update the url (and optional buffer) of this texture if url was null during construction.
  75618. * @param url the url of the texture
  75619. * @param forcedExtension defines the extension to use
  75620. * @param onLoad callback called when the texture is loaded (defaults to null)
  75621. */
  75622. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75623. /**
  75624. * Delays loading of the cube texture
  75625. * @param forcedExtension defines the extension to use
  75626. */
  75627. delayLoad(forcedExtension?: string): void;
  75628. /**
  75629. * Returns the reflection texture matrix
  75630. * @returns the reflection texture matrix
  75631. */
  75632. getReflectionTextureMatrix(): Matrix;
  75633. /**
  75634. * Sets the reflection texture matrix
  75635. * @param value Reflection texture matrix
  75636. */
  75637. setReflectionTextureMatrix(value: Matrix): void;
  75638. /**
  75639. * Parses text to create a cube texture
  75640. * @param parsedTexture define the serialized text to read from
  75641. * @param scene defines the hosting scene
  75642. * @param rootUrl defines the root url of the cube texture
  75643. * @returns a cube texture
  75644. */
  75645. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75646. /**
  75647. * Makes a clone, or deep copy, of the cube texture
  75648. * @returns a new cube texture
  75649. */
  75650. clone(): CubeTexture;
  75651. }
  75652. }
  75653. declare module BABYLON {
  75654. /**
  75655. * Manages the defines for the Material
  75656. */
  75657. export class MaterialDefines {
  75658. /** @hidden */
  75659. protected _keys: string[];
  75660. private _isDirty;
  75661. /** @hidden */
  75662. _renderId: number;
  75663. /** @hidden */
  75664. _areLightsDirty: boolean;
  75665. /** @hidden */
  75666. _areLightsDisposed: boolean;
  75667. /** @hidden */
  75668. _areAttributesDirty: boolean;
  75669. /** @hidden */
  75670. _areTexturesDirty: boolean;
  75671. /** @hidden */
  75672. _areFresnelDirty: boolean;
  75673. /** @hidden */
  75674. _areMiscDirty: boolean;
  75675. /** @hidden */
  75676. _areImageProcessingDirty: boolean;
  75677. /** @hidden */
  75678. _normals: boolean;
  75679. /** @hidden */
  75680. _uvs: boolean;
  75681. /** @hidden */
  75682. _needNormals: boolean;
  75683. /** @hidden */
  75684. _needUVs: boolean;
  75685. [id: string]: any;
  75686. /**
  75687. * Specifies if the material needs to be re-calculated
  75688. */
  75689. readonly isDirty: boolean;
  75690. /**
  75691. * Marks the material to indicate that it has been re-calculated
  75692. */
  75693. markAsProcessed(): void;
  75694. /**
  75695. * Marks the material to indicate that it needs to be re-calculated
  75696. */
  75697. markAsUnprocessed(): void;
  75698. /**
  75699. * Marks the material to indicate all of its defines need to be re-calculated
  75700. */
  75701. markAllAsDirty(): void;
  75702. /**
  75703. * Marks the material to indicate that image processing needs to be re-calculated
  75704. */
  75705. markAsImageProcessingDirty(): void;
  75706. /**
  75707. * Marks the material to indicate the lights need to be re-calculated
  75708. * @param disposed Defines whether the light is dirty due to dispose or not
  75709. */
  75710. markAsLightDirty(disposed?: boolean): void;
  75711. /**
  75712. * Marks the attribute state as changed
  75713. */
  75714. markAsAttributesDirty(): void;
  75715. /**
  75716. * Marks the texture state as changed
  75717. */
  75718. markAsTexturesDirty(): void;
  75719. /**
  75720. * Marks the fresnel state as changed
  75721. */
  75722. markAsFresnelDirty(): void;
  75723. /**
  75724. * Marks the misc state as changed
  75725. */
  75726. markAsMiscDirty(): void;
  75727. /**
  75728. * Rebuilds the material defines
  75729. */
  75730. rebuild(): void;
  75731. /**
  75732. * Specifies if two material defines are equal
  75733. * @param other - A material define instance to compare to
  75734. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75735. */
  75736. isEqual(other: MaterialDefines): boolean;
  75737. /**
  75738. * Clones this instance's defines to another instance
  75739. * @param other - material defines to clone values to
  75740. */
  75741. cloneTo(other: MaterialDefines): void;
  75742. /**
  75743. * Resets the material define values
  75744. */
  75745. reset(): void;
  75746. /**
  75747. * Converts the material define values to a string
  75748. * @returns - String of material define information
  75749. */
  75750. toString(): string;
  75751. }
  75752. }
  75753. declare module BABYLON {
  75754. /**
  75755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75757. * 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;
  75758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75759. */
  75760. export class ColorCurves {
  75761. private _dirty;
  75762. private _tempColor;
  75763. private _globalCurve;
  75764. private _highlightsCurve;
  75765. private _midtonesCurve;
  75766. private _shadowsCurve;
  75767. private _positiveCurve;
  75768. private _negativeCurve;
  75769. private _globalHue;
  75770. private _globalDensity;
  75771. private _globalSaturation;
  75772. private _globalExposure;
  75773. /**
  75774. * Gets the global Hue value.
  75775. * 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).
  75776. */
  75777. /**
  75778. * Sets the global Hue value.
  75779. * 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).
  75780. */
  75781. globalHue: number;
  75782. /**
  75783. * Gets the global Density value.
  75784. * 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.
  75785. * Values less than zero provide a filter of opposite hue.
  75786. */
  75787. /**
  75788. * Sets the global Density value.
  75789. * 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.
  75790. * Values less than zero provide a filter of opposite hue.
  75791. */
  75792. globalDensity: number;
  75793. /**
  75794. * Gets the global Saturation value.
  75795. * 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.
  75796. */
  75797. /**
  75798. * Sets the global Saturation value.
  75799. * 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.
  75800. */
  75801. globalSaturation: number;
  75802. /**
  75803. * Gets the global Exposure value.
  75804. * 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.
  75805. */
  75806. /**
  75807. * Sets the global Exposure value.
  75808. * 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.
  75809. */
  75810. globalExposure: number;
  75811. private _highlightsHue;
  75812. private _highlightsDensity;
  75813. private _highlightsSaturation;
  75814. private _highlightsExposure;
  75815. /**
  75816. * Gets the highlights Hue value.
  75817. * 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).
  75818. */
  75819. /**
  75820. * Sets the highlights Hue value.
  75821. * 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).
  75822. */
  75823. highlightsHue: number;
  75824. /**
  75825. * Gets the highlights Density value.
  75826. * 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.
  75827. * Values less than zero provide a filter of opposite hue.
  75828. */
  75829. /**
  75830. * Sets the highlights Density value.
  75831. * 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.
  75832. * Values less than zero provide a filter of opposite hue.
  75833. */
  75834. highlightsDensity: number;
  75835. /**
  75836. * Gets the highlights Saturation value.
  75837. * 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.
  75838. */
  75839. /**
  75840. * Sets the highlights Saturation value.
  75841. * 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.
  75842. */
  75843. highlightsSaturation: number;
  75844. /**
  75845. * Gets the highlights Exposure value.
  75846. * 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.
  75847. */
  75848. /**
  75849. * Sets the highlights Exposure value.
  75850. * 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.
  75851. */
  75852. highlightsExposure: number;
  75853. private _midtonesHue;
  75854. private _midtonesDensity;
  75855. private _midtonesSaturation;
  75856. private _midtonesExposure;
  75857. /**
  75858. * Gets the midtones Hue value.
  75859. * 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).
  75860. */
  75861. /**
  75862. * Sets the midtones Hue value.
  75863. * 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).
  75864. */
  75865. midtonesHue: number;
  75866. /**
  75867. * Gets the midtones Density value.
  75868. * 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.
  75869. * Values less than zero provide a filter of opposite hue.
  75870. */
  75871. /**
  75872. * Sets the midtones Density value.
  75873. * 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.
  75874. * Values less than zero provide a filter of opposite hue.
  75875. */
  75876. midtonesDensity: number;
  75877. /**
  75878. * Gets the midtones Saturation value.
  75879. * 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.
  75880. */
  75881. /**
  75882. * Sets the midtones Saturation value.
  75883. * 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.
  75884. */
  75885. midtonesSaturation: number;
  75886. /**
  75887. * Gets the midtones Exposure value.
  75888. * 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.
  75889. */
  75890. /**
  75891. * Sets the midtones Exposure value.
  75892. * 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.
  75893. */
  75894. midtonesExposure: number;
  75895. private _shadowsHue;
  75896. private _shadowsDensity;
  75897. private _shadowsSaturation;
  75898. private _shadowsExposure;
  75899. /**
  75900. * Gets the shadows Hue value.
  75901. * 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).
  75902. */
  75903. /**
  75904. * Sets the shadows Hue value.
  75905. * 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).
  75906. */
  75907. shadowsHue: number;
  75908. /**
  75909. * Gets the shadows Density value.
  75910. * 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.
  75911. * Values less than zero provide a filter of opposite hue.
  75912. */
  75913. /**
  75914. * Sets the shadows Density value.
  75915. * 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.
  75916. * Values less than zero provide a filter of opposite hue.
  75917. */
  75918. shadowsDensity: number;
  75919. /**
  75920. * Gets the shadows Saturation value.
  75921. * 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.
  75922. */
  75923. /**
  75924. * Sets the shadows Saturation value.
  75925. * 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.
  75926. */
  75927. shadowsSaturation: number;
  75928. /**
  75929. * Gets the shadows Exposure value.
  75930. * 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.
  75931. */
  75932. /**
  75933. * Sets the shadows Exposure value.
  75934. * 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.
  75935. */
  75936. shadowsExposure: number;
  75937. /**
  75938. * Returns the class name
  75939. * @returns The class name
  75940. */
  75941. getClassName(): string;
  75942. /**
  75943. * Binds the color curves to the shader.
  75944. * @param colorCurves The color curve to bind
  75945. * @param effect The effect to bind to
  75946. * @param positiveUniform The positive uniform shader parameter
  75947. * @param neutralUniform The neutral uniform shader parameter
  75948. * @param negativeUniform The negative uniform shader parameter
  75949. */
  75950. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75951. /**
  75952. * Prepare the list of uniforms associated with the ColorCurves effects.
  75953. * @param uniformsList The list of uniforms used in the effect
  75954. */
  75955. static PrepareUniforms(uniformsList: string[]): void;
  75956. /**
  75957. * Returns color grading data based on a hue, density, saturation and exposure value.
  75958. * @param filterHue The hue of the color filter.
  75959. * @param filterDensity The density of the color filter.
  75960. * @param saturation The saturation.
  75961. * @param exposure The exposure.
  75962. * @param result The result data container.
  75963. */
  75964. private getColorGradingDataToRef;
  75965. /**
  75966. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75967. * @param value The input slider value in range [-100,100].
  75968. * @returns Adjusted value.
  75969. */
  75970. private static applyColorGradingSliderNonlinear;
  75971. /**
  75972. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75973. * @param hue The hue (H) input.
  75974. * @param saturation The saturation (S) input.
  75975. * @param brightness The brightness (B) input.
  75976. * @result An RGBA color represented as Vector4.
  75977. */
  75978. private static fromHSBToRef;
  75979. /**
  75980. * Returns a value clamped between min and max
  75981. * @param value The value to clamp
  75982. * @param min The minimum of value
  75983. * @param max The maximum of value
  75984. * @returns The clamped value.
  75985. */
  75986. private static clamp;
  75987. /**
  75988. * Clones the current color curve instance.
  75989. * @return The cloned curves
  75990. */
  75991. clone(): ColorCurves;
  75992. /**
  75993. * Serializes the current color curve instance to a json representation.
  75994. * @return a JSON representation
  75995. */
  75996. serialize(): any;
  75997. /**
  75998. * Parses the color curve from a json representation.
  75999. * @param source the JSON source to parse
  76000. * @return The parsed curves
  76001. */
  76002. static Parse(source: any): ColorCurves;
  76003. }
  76004. }
  76005. declare module BABYLON {
  76006. /**
  76007. * Interface to follow in your material defines to integrate easily the
  76008. * Image proccessing functions.
  76009. * @hidden
  76010. */
  76011. export interface IImageProcessingConfigurationDefines {
  76012. IMAGEPROCESSING: boolean;
  76013. VIGNETTE: boolean;
  76014. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76015. VIGNETTEBLENDMODEOPAQUE: boolean;
  76016. TONEMAPPING: boolean;
  76017. TONEMAPPING_ACES: boolean;
  76018. CONTRAST: boolean;
  76019. EXPOSURE: boolean;
  76020. COLORCURVES: boolean;
  76021. COLORGRADING: boolean;
  76022. COLORGRADING3D: boolean;
  76023. SAMPLER3DGREENDEPTH: boolean;
  76024. SAMPLER3DBGRMAP: boolean;
  76025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76026. }
  76027. /**
  76028. * @hidden
  76029. */
  76030. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76031. IMAGEPROCESSING: boolean;
  76032. VIGNETTE: boolean;
  76033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76034. VIGNETTEBLENDMODEOPAQUE: boolean;
  76035. TONEMAPPING: boolean;
  76036. TONEMAPPING_ACES: boolean;
  76037. CONTRAST: boolean;
  76038. COLORCURVES: boolean;
  76039. COLORGRADING: boolean;
  76040. COLORGRADING3D: boolean;
  76041. SAMPLER3DGREENDEPTH: boolean;
  76042. SAMPLER3DBGRMAP: boolean;
  76043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76044. EXPOSURE: boolean;
  76045. constructor();
  76046. }
  76047. /**
  76048. * This groups together the common properties used for image processing either in direct forward pass
  76049. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76050. * or not.
  76051. */
  76052. export class ImageProcessingConfiguration {
  76053. /**
  76054. * Default tone mapping applied in BabylonJS.
  76055. */
  76056. static readonly TONEMAPPING_STANDARD: number;
  76057. /**
  76058. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76059. * to other engines rendering to increase portability.
  76060. */
  76061. static readonly TONEMAPPING_ACES: number;
  76062. /**
  76063. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76064. */
  76065. colorCurves: Nullable<ColorCurves>;
  76066. private _colorCurvesEnabled;
  76067. /**
  76068. * Gets wether the color curves effect is enabled.
  76069. */
  76070. /**
  76071. * Sets wether the color curves effect is enabled.
  76072. */
  76073. colorCurvesEnabled: boolean;
  76074. private _colorGradingTexture;
  76075. /**
  76076. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76077. */
  76078. /**
  76079. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76080. */
  76081. colorGradingTexture: Nullable<BaseTexture>;
  76082. private _colorGradingEnabled;
  76083. /**
  76084. * Gets wether the color grading effect is enabled.
  76085. */
  76086. /**
  76087. * Sets wether the color grading effect is enabled.
  76088. */
  76089. colorGradingEnabled: boolean;
  76090. private _colorGradingWithGreenDepth;
  76091. /**
  76092. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76093. */
  76094. /**
  76095. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76096. */
  76097. colorGradingWithGreenDepth: boolean;
  76098. private _colorGradingBGR;
  76099. /**
  76100. * Gets wether the color grading texture contains BGR values.
  76101. */
  76102. /**
  76103. * Sets wether the color grading texture contains BGR values.
  76104. */
  76105. colorGradingBGR: boolean;
  76106. /** @hidden */
  76107. _exposure: number;
  76108. /**
  76109. * Gets the Exposure used in the effect.
  76110. */
  76111. /**
  76112. * Sets the Exposure used in the effect.
  76113. */
  76114. exposure: number;
  76115. private _toneMappingEnabled;
  76116. /**
  76117. * Gets wether the tone mapping effect is enabled.
  76118. */
  76119. /**
  76120. * Sets wether the tone mapping effect is enabled.
  76121. */
  76122. toneMappingEnabled: boolean;
  76123. private _toneMappingType;
  76124. /**
  76125. * Gets the type of tone mapping effect.
  76126. */
  76127. /**
  76128. * Sets the type of tone mapping effect used in BabylonJS.
  76129. */
  76130. toneMappingType: number;
  76131. protected _contrast: number;
  76132. /**
  76133. * Gets the contrast used in the effect.
  76134. */
  76135. /**
  76136. * Sets the contrast used in the effect.
  76137. */
  76138. contrast: number;
  76139. /**
  76140. * Vignette stretch size.
  76141. */
  76142. vignetteStretch: number;
  76143. /**
  76144. * Vignette centre X Offset.
  76145. */
  76146. vignetteCentreX: number;
  76147. /**
  76148. * Vignette centre Y Offset.
  76149. */
  76150. vignetteCentreY: number;
  76151. /**
  76152. * Vignette weight or intensity of the vignette effect.
  76153. */
  76154. vignetteWeight: number;
  76155. /**
  76156. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76157. * if vignetteEnabled is set to true.
  76158. */
  76159. vignetteColor: Color4;
  76160. /**
  76161. * Camera field of view used by the Vignette effect.
  76162. */
  76163. vignetteCameraFov: number;
  76164. private _vignetteBlendMode;
  76165. /**
  76166. * Gets the vignette blend mode allowing different kind of effect.
  76167. */
  76168. /**
  76169. * Sets the vignette blend mode allowing different kind of effect.
  76170. */
  76171. vignetteBlendMode: number;
  76172. private _vignetteEnabled;
  76173. /**
  76174. * Gets wether the vignette effect is enabled.
  76175. */
  76176. /**
  76177. * Sets wether the vignette effect is enabled.
  76178. */
  76179. vignetteEnabled: boolean;
  76180. private _applyByPostProcess;
  76181. /**
  76182. * Gets wether the image processing is applied through a post process or not.
  76183. */
  76184. /**
  76185. * Sets wether the image processing is applied through a post process or not.
  76186. */
  76187. applyByPostProcess: boolean;
  76188. private _isEnabled;
  76189. /**
  76190. * Gets wether the image processing is enabled or not.
  76191. */
  76192. /**
  76193. * Sets wether the image processing is enabled or not.
  76194. */
  76195. isEnabled: boolean;
  76196. /**
  76197. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76198. */
  76199. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76200. /**
  76201. * Method called each time the image processing information changes requires to recompile the effect.
  76202. */
  76203. protected _updateParameters(): void;
  76204. /**
  76205. * Gets the current class name.
  76206. * @return "ImageProcessingConfiguration"
  76207. */
  76208. getClassName(): string;
  76209. /**
  76210. * Prepare the list of uniforms associated with the Image Processing effects.
  76211. * @param uniforms The list of uniforms used in the effect
  76212. * @param defines the list of defines currently in use
  76213. */
  76214. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76215. /**
  76216. * Prepare the list of samplers associated with the Image Processing effects.
  76217. * @param samplersList The list of uniforms used in the effect
  76218. * @param defines the list of defines currently in use
  76219. */
  76220. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76221. /**
  76222. * Prepare the list of defines associated to the shader.
  76223. * @param defines the list of defines to complete
  76224. * @param forPostProcess Define if we are currently in post process mode or not
  76225. */
  76226. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76227. /**
  76228. * Returns true if all the image processing information are ready.
  76229. * @returns True if ready, otherwise, false
  76230. */
  76231. isReady(): boolean;
  76232. /**
  76233. * Binds the image processing to the shader.
  76234. * @param effect The effect to bind to
  76235. * @param overrideAspectRatio Override the aspect ratio of the effect
  76236. */
  76237. bind(effect: Effect, overrideAspectRatio?: number): void;
  76238. /**
  76239. * Clones the current image processing instance.
  76240. * @return The cloned image processing
  76241. */
  76242. clone(): ImageProcessingConfiguration;
  76243. /**
  76244. * Serializes the current image processing instance to a json representation.
  76245. * @return a JSON representation
  76246. */
  76247. serialize(): any;
  76248. /**
  76249. * Parses the image processing from a json representation.
  76250. * @param source the JSON source to parse
  76251. * @return The parsed image processing
  76252. */
  76253. static Parse(source: any): ImageProcessingConfiguration;
  76254. private static _VIGNETTEMODE_MULTIPLY;
  76255. private static _VIGNETTEMODE_OPAQUE;
  76256. /**
  76257. * Used to apply the vignette as a mix with the pixel color.
  76258. */
  76259. static readonly VIGNETTEMODE_MULTIPLY: number;
  76260. /**
  76261. * Used to apply the vignette as a replacement of the pixel color.
  76262. */
  76263. static readonly VIGNETTEMODE_OPAQUE: number;
  76264. }
  76265. }
  76266. declare module BABYLON {
  76267. /** @hidden */
  76268. export var postprocessVertexShader: {
  76269. name: string;
  76270. shader: string;
  76271. };
  76272. }
  76273. declare module BABYLON {
  76274. interface ThinEngine {
  76275. /**
  76276. * Creates a new render target texture
  76277. * @param size defines the size of the texture
  76278. * @param options defines the options used to create the texture
  76279. * @returns a new render target texture stored in an InternalTexture
  76280. */
  76281. createRenderTargetTexture(size: number | {
  76282. width: number;
  76283. height: number;
  76284. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76285. /**
  76286. * Creates a depth stencil texture.
  76287. * This is only available in WebGL 2 or with the depth texture extension available.
  76288. * @param size The size of face edge in the texture.
  76289. * @param options The options defining the texture.
  76290. * @returns The texture
  76291. */
  76292. createDepthStencilTexture(size: number | {
  76293. width: number;
  76294. height: number;
  76295. }, options: DepthTextureCreationOptions): InternalTexture;
  76296. /** @hidden */
  76297. _createDepthStencilTexture(size: number | {
  76298. width: number;
  76299. height: number;
  76300. }, options: DepthTextureCreationOptions): InternalTexture;
  76301. }
  76302. }
  76303. declare module BABYLON {
  76304. /** Defines supported spaces */
  76305. export enum Space {
  76306. /** Local (object) space */
  76307. LOCAL = 0,
  76308. /** World space */
  76309. WORLD = 1,
  76310. /** Bone space */
  76311. BONE = 2
  76312. }
  76313. /** Defines the 3 main axes */
  76314. export class Axis {
  76315. /** X axis */
  76316. static X: Vector3;
  76317. /** Y axis */
  76318. static Y: Vector3;
  76319. /** Z axis */
  76320. static Z: Vector3;
  76321. }
  76322. }
  76323. declare module BABYLON {
  76324. /**
  76325. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76326. * This is the base of the follow, arc rotate cameras and Free camera
  76327. * @see http://doc.babylonjs.com/features/cameras
  76328. */
  76329. export class TargetCamera extends Camera {
  76330. private static _RigCamTransformMatrix;
  76331. private static _TargetTransformMatrix;
  76332. private static _TargetFocalPoint;
  76333. /**
  76334. * Define the current direction the camera is moving to
  76335. */
  76336. cameraDirection: Vector3;
  76337. /**
  76338. * Define the current rotation the camera is rotating to
  76339. */
  76340. cameraRotation: Vector2;
  76341. /**
  76342. * When set, the up vector of the camera will be updated by the rotation of the camera
  76343. */
  76344. updateUpVectorFromRotation: boolean;
  76345. private _tmpQuaternion;
  76346. /**
  76347. * Define the current rotation of the camera
  76348. */
  76349. rotation: Vector3;
  76350. /**
  76351. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76352. */
  76353. rotationQuaternion: Quaternion;
  76354. /**
  76355. * Define the current speed of the camera
  76356. */
  76357. speed: number;
  76358. /**
  76359. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76360. * around all axis.
  76361. */
  76362. noRotationConstraint: boolean;
  76363. /**
  76364. * Define the current target of the camera as an object or a position.
  76365. */
  76366. lockedTarget: any;
  76367. /** @hidden */
  76368. _currentTarget: Vector3;
  76369. /** @hidden */
  76370. _initialFocalDistance: number;
  76371. /** @hidden */
  76372. _viewMatrix: Matrix;
  76373. /** @hidden */
  76374. _camMatrix: Matrix;
  76375. /** @hidden */
  76376. _cameraTransformMatrix: Matrix;
  76377. /** @hidden */
  76378. _cameraRotationMatrix: Matrix;
  76379. /** @hidden */
  76380. _referencePoint: Vector3;
  76381. /** @hidden */
  76382. _transformedReferencePoint: Vector3;
  76383. protected _globalCurrentTarget: Vector3;
  76384. protected _globalCurrentUpVector: Vector3;
  76385. /** @hidden */
  76386. _reset: () => void;
  76387. private _defaultUp;
  76388. /**
  76389. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76390. * This is the base of the follow, arc rotate cameras and Free camera
  76391. * @see http://doc.babylonjs.com/features/cameras
  76392. * @param name Defines the name of the camera in the scene
  76393. * @param position Defines the start position of the camera in the scene
  76394. * @param scene Defines the scene the camera belongs to
  76395. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76396. */
  76397. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76398. /**
  76399. * Gets the position in front of the camera at a given distance.
  76400. * @param distance The distance from the camera we want the position to be
  76401. * @returns the position
  76402. */
  76403. getFrontPosition(distance: number): Vector3;
  76404. /** @hidden */
  76405. _getLockedTargetPosition(): Nullable<Vector3>;
  76406. private _storedPosition;
  76407. private _storedRotation;
  76408. private _storedRotationQuaternion;
  76409. /**
  76410. * Store current camera state of the camera (fov, position, rotation, etc..)
  76411. * @returns the camera
  76412. */
  76413. storeState(): Camera;
  76414. /**
  76415. * Restored camera state. You must call storeState() first
  76416. * @returns whether it was successful or not
  76417. * @hidden
  76418. */
  76419. _restoreStateValues(): boolean;
  76420. /** @hidden */
  76421. _initCache(): void;
  76422. /** @hidden */
  76423. _updateCache(ignoreParentClass?: boolean): void;
  76424. /** @hidden */
  76425. _isSynchronizedViewMatrix(): boolean;
  76426. /** @hidden */
  76427. _computeLocalCameraSpeed(): number;
  76428. /**
  76429. * Defines the target the camera should look at.
  76430. * @param target Defines the new target as a Vector or a mesh
  76431. */
  76432. setTarget(target: Vector3): void;
  76433. /**
  76434. * Return the current target position of the camera. This value is expressed in local space.
  76435. * @returns the target position
  76436. */
  76437. getTarget(): Vector3;
  76438. /** @hidden */
  76439. _decideIfNeedsToMove(): boolean;
  76440. /** @hidden */
  76441. _updatePosition(): void;
  76442. /** @hidden */
  76443. _checkInputs(): void;
  76444. protected _updateCameraRotationMatrix(): void;
  76445. /**
  76446. * 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)
  76447. * @returns the current camera
  76448. */
  76449. private _rotateUpVectorWithCameraRotationMatrix;
  76450. private _cachedRotationZ;
  76451. private _cachedQuaternionRotationZ;
  76452. /** @hidden */
  76453. _getViewMatrix(): Matrix;
  76454. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76455. /**
  76456. * @hidden
  76457. */
  76458. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76459. /**
  76460. * @hidden
  76461. */
  76462. _updateRigCameras(): void;
  76463. private _getRigCamPositionAndTarget;
  76464. /**
  76465. * Gets the current object class name.
  76466. * @return the class name
  76467. */
  76468. getClassName(): string;
  76469. }
  76470. }
  76471. declare module BABYLON {
  76472. /**
  76473. * Gather the list of keyboard event types as constants.
  76474. */
  76475. export class KeyboardEventTypes {
  76476. /**
  76477. * The keydown event is fired when a key becomes active (pressed).
  76478. */
  76479. static readonly KEYDOWN: number;
  76480. /**
  76481. * The keyup event is fired when a key has been released.
  76482. */
  76483. static readonly KEYUP: number;
  76484. }
  76485. /**
  76486. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76487. */
  76488. export class KeyboardInfo {
  76489. /**
  76490. * Defines the type of event (KeyboardEventTypes)
  76491. */
  76492. type: number;
  76493. /**
  76494. * Defines the related dom event
  76495. */
  76496. event: KeyboardEvent;
  76497. /**
  76498. * Instantiates a new keyboard info.
  76499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76500. * @param type Defines the type of event (KeyboardEventTypes)
  76501. * @param event Defines the related dom event
  76502. */
  76503. constructor(
  76504. /**
  76505. * Defines the type of event (KeyboardEventTypes)
  76506. */
  76507. type: number,
  76508. /**
  76509. * Defines the related dom event
  76510. */
  76511. event: KeyboardEvent);
  76512. }
  76513. /**
  76514. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76515. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76516. */
  76517. export class KeyboardInfoPre extends KeyboardInfo {
  76518. /**
  76519. * Defines the type of event (KeyboardEventTypes)
  76520. */
  76521. type: number;
  76522. /**
  76523. * Defines the related dom event
  76524. */
  76525. event: KeyboardEvent;
  76526. /**
  76527. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76528. */
  76529. skipOnPointerObservable: boolean;
  76530. /**
  76531. * Instantiates a new keyboard pre info.
  76532. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76533. * @param type Defines the type of event (KeyboardEventTypes)
  76534. * @param event Defines the related dom event
  76535. */
  76536. constructor(
  76537. /**
  76538. * Defines the type of event (KeyboardEventTypes)
  76539. */
  76540. type: number,
  76541. /**
  76542. * Defines the related dom event
  76543. */
  76544. event: KeyboardEvent);
  76545. }
  76546. }
  76547. declare module BABYLON {
  76548. /**
  76549. * Manage the keyboard inputs to control the movement of a free camera.
  76550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76551. */
  76552. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76553. /**
  76554. * Defines the camera the input is attached to.
  76555. */
  76556. camera: FreeCamera;
  76557. /**
  76558. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76559. */
  76560. keysUp: number[];
  76561. /**
  76562. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76563. */
  76564. keysDown: number[];
  76565. /**
  76566. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76567. */
  76568. keysLeft: number[];
  76569. /**
  76570. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76571. */
  76572. keysRight: number[];
  76573. private _keys;
  76574. private _onCanvasBlurObserver;
  76575. private _onKeyboardObserver;
  76576. private _engine;
  76577. private _scene;
  76578. /**
  76579. * Attach the input controls to a specific dom element to get the input from.
  76580. * @param element Defines the element the controls should be listened from
  76581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76582. */
  76583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76584. /**
  76585. * Detach the current controls from the specified dom element.
  76586. * @param element Defines the element to stop listening the inputs from
  76587. */
  76588. detachControl(element: Nullable<HTMLElement>): void;
  76589. /**
  76590. * Update the current camera state depending on the inputs that have been used this frame.
  76591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76592. */
  76593. checkInputs(): void;
  76594. /**
  76595. * Gets the class name of the current intput.
  76596. * @returns the class name
  76597. */
  76598. getClassName(): string;
  76599. /** @hidden */
  76600. _onLostFocus(): void;
  76601. /**
  76602. * Get the friendly name associated with the input class.
  76603. * @returns the input friendly name
  76604. */
  76605. getSimpleName(): string;
  76606. }
  76607. }
  76608. declare module BABYLON {
  76609. /**
  76610. * Interface describing all the common properties and methods a shadow light needs to implement.
  76611. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76612. * as well as binding the different shadow properties to the effects.
  76613. */
  76614. export interface IShadowLight extends Light {
  76615. /**
  76616. * The light id in the scene (used in scene.findLighById for instance)
  76617. */
  76618. id: string;
  76619. /**
  76620. * The position the shdow will be casted from.
  76621. */
  76622. position: Vector3;
  76623. /**
  76624. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76625. */
  76626. direction: Vector3;
  76627. /**
  76628. * The transformed position. Position of the light in world space taking parenting in account.
  76629. */
  76630. transformedPosition: Vector3;
  76631. /**
  76632. * The transformed direction. Direction of the light in world space taking parenting in account.
  76633. */
  76634. transformedDirection: Vector3;
  76635. /**
  76636. * The friendly name of the light in the scene.
  76637. */
  76638. name: string;
  76639. /**
  76640. * Defines the shadow projection clipping minimum z value.
  76641. */
  76642. shadowMinZ: number;
  76643. /**
  76644. * Defines the shadow projection clipping maximum z value.
  76645. */
  76646. shadowMaxZ: number;
  76647. /**
  76648. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76649. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76650. */
  76651. computeTransformedInformation(): boolean;
  76652. /**
  76653. * Gets the scene the light belongs to.
  76654. * @returns The scene
  76655. */
  76656. getScene(): Scene;
  76657. /**
  76658. * Callback defining a custom Projection Matrix Builder.
  76659. * This can be used to override the default projection matrix computation.
  76660. */
  76661. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76662. /**
  76663. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76664. * @param matrix The materix to updated with the projection information
  76665. * @param viewMatrix The transform matrix of the light
  76666. * @param renderList The list of mesh to render in the map
  76667. * @returns The current light
  76668. */
  76669. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76670. /**
  76671. * Gets the current depth scale used in ESM.
  76672. * @returns The scale
  76673. */
  76674. getDepthScale(): number;
  76675. /**
  76676. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76677. * @returns true if a cube texture needs to be use
  76678. */
  76679. needCube(): boolean;
  76680. /**
  76681. * Detects if the projection matrix requires to be recomputed this frame.
  76682. * @returns true if it requires to be recomputed otherwise, false.
  76683. */
  76684. needProjectionMatrixCompute(): boolean;
  76685. /**
  76686. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76687. */
  76688. forceProjectionMatrixCompute(): void;
  76689. /**
  76690. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76691. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76692. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76693. */
  76694. getShadowDirection(faceIndex?: number): Vector3;
  76695. /**
  76696. * Gets the minZ used for shadow according to both the scene and the light.
  76697. * @param activeCamera The camera we are returning the min for
  76698. * @returns the depth min z
  76699. */
  76700. getDepthMinZ(activeCamera: Camera): number;
  76701. /**
  76702. * Gets the maxZ used for shadow according to both the scene and the light.
  76703. * @param activeCamera The camera we are returning the max for
  76704. * @returns the depth max z
  76705. */
  76706. getDepthMaxZ(activeCamera: Camera): number;
  76707. }
  76708. /**
  76709. * Base implementation IShadowLight
  76710. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76711. */
  76712. export abstract class ShadowLight extends Light implements IShadowLight {
  76713. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76714. protected _position: Vector3;
  76715. protected _setPosition(value: Vector3): void;
  76716. /**
  76717. * Sets the position the shadow will be casted from. Also use as the light position for both
  76718. * point and spot lights.
  76719. */
  76720. /**
  76721. * Sets the position the shadow will be casted from. Also use as the light position for both
  76722. * point and spot lights.
  76723. */
  76724. position: Vector3;
  76725. protected _direction: Vector3;
  76726. protected _setDirection(value: Vector3): void;
  76727. /**
  76728. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76729. * Also use as the light direction on spot and directional lights.
  76730. */
  76731. /**
  76732. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76733. * Also use as the light direction on spot and directional lights.
  76734. */
  76735. direction: Vector3;
  76736. private _shadowMinZ;
  76737. /**
  76738. * Gets the shadow projection clipping minimum z value.
  76739. */
  76740. /**
  76741. * Sets the shadow projection clipping minimum z value.
  76742. */
  76743. shadowMinZ: number;
  76744. private _shadowMaxZ;
  76745. /**
  76746. * Sets the shadow projection clipping maximum z value.
  76747. */
  76748. /**
  76749. * Gets the shadow projection clipping maximum z value.
  76750. */
  76751. shadowMaxZ: number;
  76752. /**
  76753. * Callback defining a custom Projection Matrix Builder.
  76754. * This can be used to override the default projection matrix computation.
  76755. */
  76756. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76757. /**
  76758. * The transformed position. Position of the light in world space taking parenting in account.
  76759. */
  76760. transformedPosition: Vector3;
  76761. /**
  76762. * The transformed direction. Direction of the light in world space taking parenting in account.
  76763. */
  76764. transformedDirection: Vector3;
  76765. private _needProjectionMatrixCompute;
  76766. /**
  76767. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76768. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76769. */
  76770. computeTransformedInformation(): boolean;
  76771. /**
  76772. * Return the depth scale used for the shadow map.
  76773. * @returns the depth scale.
  76774. */
  76775. getDepthScale(): number;
  76776. /**
  76777. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76778. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76779. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76780. */
  76781. getShadowDirection(faceIndex?: number): Vector3;
  76782. /**
  76783. * Returns the ShadowLight absolute position in the World.
  76784. * @returns the position vector in world space
  76785. */
  76786. getAbsolutePosition(): Vector3;
  76787. /**
  76788. * Sets the ShadowLight direction toward the passed target.
  76789. * @param target The point to target in local space
  76790. * @returns the updated ShadowLight direction
  76791. */
  76792. setDirectionToTarget(target: Vector3): Vector3;
  76793. /**
  76794. * Returns the light rotation in euler definition.
  76795. * @returns the x y z rotation in local space.
  76796. */
  76797. getRotation(): Vector3;
  76798. /**
  76799. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76800. * @returns true if a cube texture needs to be use
  76801. */
  76802. needCube(): boolean;
  76803. /**
  76804. * Detects if the projection matrix requires to be recomputed this frame.
  76805. * @returns true if it requires to be recomputed otherwise, false.
  76806. */
  76807. needProjectionMatrixCompute(): boolean;
  76808. /**
  76809. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76810. */
  76811. forceProjectionMatrixCompute(): void;
  76812. /** @hidden */
  76813. _initCache(): void;
  76814. /** @hidden */
  76815. _isSynchronized(): boolean;
  76816. /**
  76817. * Computes the world matrix of the node
  76818. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76819. * @returns the world matrix
  76820. */
  76821. computeWorldMatrix(force?: boolean): Matrix;
  76822. /**
  76823. * Gets the minZ used for shadow according to both the scene and the light.
  76824. * @param activeCamera The camera we are returning the min for
  76825. * @returns the depth min z
  76826. */
  76827. getDepthMinZ(activeCamera: Camera): number;
  76828. /**
  76829. * Gets the maxZ used for shadow according to both the scene and the light.
  76830. * @param activeCamera The camera we are returning the max for
  76831. * @returns the depth max z
  76832. */
  76833. getDepthMaxZ(activeCamera: Camera): number;
  76834. /**
  76835. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76836. * @param matrix The materix to updated with the projection information
  76837. * @param viewMatrix The transform matrix of the light
  76838. * @param renderList The list of mesh to render in the map
  76839. * @returns The current light
  76840. */
  76841. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76842. }
  76843. }
  76844. declare module BABYLON {
  76845. /**
  76846. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76847. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76848. */
  76849. export class EffectFallbacks implements IEffectFallbacks {
  76850. private _defines;
  76851. private _currentRank;
  76852. private _maxRank;
  76853. private _mesh;
  76854. /**
  76855. * Removes the fallback from the bound mesh.
  76856. */
  76857. unBindMesh(): void;
  76858. /**
  76859. * Adds a fallback on the specified property.
  76860. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76861. * @param define The name of the define in the shader
  76862. */
  76863. addFallback(rank: number, define: string): void;
  76864. /**
  76865. * Sets the mesh to use CPU skinning when needing to fallback.
  76866. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76867. * @param mesh The mesh to use the fallbacks.
  76868. */
  76869. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76870. /**
  76871. * Checks to see if more fallbacks are still availible.
  76872. */
  76873. readonly hasMoreFallbacks: boolean;
  76874. /**
  76875. * Removes the defines that should be removed when falling back.
  76876. * @param currentDefines defines the current define statements for the shader.
  76877. * @param effect defines the current effect we try to compile
  76878. * @returns The resulting defines with defines of the current rank removed.
  76879. */
  76880. reduce(currentDefines: string, effect: Effect): string;
  76881. }
  76882. }
  76883. declare module BABYLON {
  76884. /**
  76885. * "Static Class" containing the most commonly used helper while dealing with material for
  76886. * rendering purpose.
  76887. *
  76888. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76889. *
  76890. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76891. */
  76892. export class MaterialHelper {
  76893. /**
  76894. * Bind the current view position to an effect.
  76895. * @param effect The effect to be bound
  76896. * @param scene The scene the eyes position is used from
  76897. */
  76898. static BindEyePosition(effect: Effect, scene: Scene): void;
  76899. /**
  76900. * Helps preparing the defines values about the UVs in used in the effect.
  76901. * UVs are shared as much as we can accross channels in the shaders.
  76902. * @param texture The texture we are preparing the UVs for
  76903. * @param defines The defines to update
  76904. * @param key The channel key "diffuse", "specular"... used in the shader
  76905. */
  76906. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76907. /**
  76908. * Binds a texture matrix value to its corrsponding uniform
  76909. * @param texture The texture to bind the matrix for
  76910. * @param uniformBuffer The uniform buffer receivin the data
  76911. * @param key The channel key "diffuse", "specular"... used in the shader
  76912. */
  76913. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76914. /**
  76915. * Gets the current status of the fog (should it be enabled?)
  76916. * @param mesh defines the mesh to evaluate for fog support
  76917. * @param scene defines the hosting scene
  76918. * @returns true if fog must be enabled
  76919. */
  76920. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76921. /**
  76922. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76923. * @param mesh defines the current mesh
  76924. * @param scene defines the current scene
  76925. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76926. * @param pointsCloud defines if point cloud rendering has to be turned on
  76927. * @param fogEnabled defines if fog has to be turned on
  76928. * @param alphaTest defines if alpha testing has to be turned on
  76929. * @param defines defines the current list of defines
  76930. */
  76931. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76932. /**
  76933. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76934. * @param scene defines the current scene
  76935. * @param engine defines the current engine
  76936. * @param defines specifies the list of active defines
  76937. * @param useInstances defines if instances have to be turned on
  76938. * @param useClipPlane defines if clip plane have to be turned on
  76939. */
  76940. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76941. /**
  76942. * Prepares the defines for bones
  76943. * @param mesh The mesh containing the geometry data we will draw
  76944. * @param defines The defines to update
  76945. */
  76946. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76947. /**
  76948. * Prepares the defines for morph targets
  76949. * @param mesh The mesh containing the geometry data we will draw
  76950. * @param defines The defines to update
  76951. */
  76952. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76953. /**
  76954. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76955. * @param mesh The mesh containing the geometry data we will draw
  76956. * @param defines The defines to update
  76957. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76958. * @param useBones Precise whether bones should be used or not (override mesh info)
  76959. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76960. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76961. * @returns false if defines are considered not dirty and have not been checked
  76962. */
  76963. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76964. /**
  76965. * Prepares the defines related to multiview
  76966. * @param scene The scene we are intending to draw
  76967. * @param defines The defines to update
  76968. */
  76969. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76970. /**
  76971. * Prepares the defines related to the light information passed in parameter
  76972. * @param scene The scene we are intending to draw
  76973. * @param mesh The mesh the effect is compiling for
  76974. * @param light The light the effect is compiling for
  76975. * @param lightIndex The index of the light
  76976. * @param defines The defines to update
  76977. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76978. * @param state Defines the current state regarding what is needed (normals, etc...)
  76979. */
  76980. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76981. needNormals: boolean;
  76982. needRebuild: boolean;
  76983. shadowEnabled: boolean;
  76984. specularEnabled: boolean;
  76985. lightmapMode: boolean;
  76986. }): void;
  76987. /**
  76988. * Prepares the defines related to the light information passed in parameter
  76989. * @param scene The scene we are intending to draw
  76990. * @param mesh The mesh the effect is compiling for
  76991. * @param defines The defines to update
  76992. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76993. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76994. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76995. * @returns true if normals will be required for the rest of the effect
  76996. */
  76997. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76998. /**
  76999. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77000. * @param lightIndex defines the light index
  77001. * @param uniformsList The uniform list
  77002. * @param samplersList The sampler list
  77003. * @param projectedLightTexture defines if projected texture must be used
  77004. * @param uniformBuffersList defines an optional list of uniform buffers
  77005. */
  77006. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77007. /**
  77008. * Prepares the uniforms and samplers list to be used in the effect
  77009. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77010. * @param samplersList The sampler list
  77011. * @param defines The defines helping in the list generation
  77012. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77013. */
  77014. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77015. /**
  77016. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77017. * @param defines The defines to update while falling back
  77018. * @param fallbacks The authorized effect fallbacks
  77019. * @param maxSimultaneousLights The maximum number of lights allowed
  77020. * @param rank the current rank of the Effect
  77021. * @returns The newly affected rank
  77022. */
  77023. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77024. private static _TmpMorphInfluencers;
  77025. /**
  77026. * Prepares the list of attributes required for morph targets according to the effect defines.
  77027. * @param attribs The current list of supported attribs
  77028. * @param mesh The mesh to prepare the morph targets attributes for
  77029. * @param influencers The number of influencers
  77030. */
  77031. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77032. /**
  77033. * Prepares the list of attributes required for morph targets according to the effect defines.
  77034. * @param attribs The current list of supported attribs
  77035. * @param mesh The mesh to prepare the morph targets attributes for
  77036. * @param defines The current Defines of the effect
  77037. */
  77038. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77039. /**
  77040. * Prepares the list of attributes required for bones according to the effect defines.
  77041. * @param attribs The current list of supported attribs
  77042. * @param mesh The mesh to prepare the bones attributes for
  77043. * @param defines The current Defines of the effect
  77044. * @param fallbacks The current efffect fallback strategy
  77045. */
  77046. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77047. /**
  77048. * Check and prepare the list of attributes required for instances according to the effect defines.
  77049. * @param attribs The current list of supported attribs
  77050. * @param defines The current MaterialDefines of the effect
  77051. */
  77052. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77053. /**
  77054. * Add the list of attributes required for instances to the attribs array.
  77055. * @param attribs The current list of supported attribs
  77056. */
  77057. static PushAttributesForInstances(attribs: string[]): void;
  77058. /**
  77059. * Binds the light information to the effect.
  77060. * @param light The light containing the generator
  77061. * @param effect The effect we are binding the data to
  77062. * @param lightIndex The light index in the effect used to render
  77063. */
  77064. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77065. /**
  77066. * Binds the lights information from the scene to the effect for the given mesh.
  77067. * @param light Light to bind
  77068. * @param lightIndex Light index
  77069. * @param scene The scene where the light belongs to
  77070. * @param effect The effect we are binding the data to
  77071. * @param useSpecular Defines if specular is supported
  77072. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77073. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77074. */
  77075. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77076. /**
  77077. * Binds the lights information from the scene to the effect for the given mesh.
  77078. * @param scene The scene the lights belongs to
  77079. * @param mesh The mesh we are binding the information to render
  77080. * @param effect The effect we are binding the data to
  77081. * @param defines The generated defines for the effect
  77082. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77083. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77084. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77085. */
  77086. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77087. private static _tempFogColor;
  77088. /**
  77089. * Binds the fog information from the scene to the effect for the given mesh.
  77090. * @param scene The scene the lights belongs to
  77091. * @param mesh The mesh we are binding the information to render
  77092. * @param effect The effect we are binding the data to
  77093. * @param linearSpace Defines if the fog effect is applied in linear space
  77094. */
  77095. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77096. /**
  77097. * Binds the bones information from the mesh to the effect.
  77098. * @param mesh The mesh we are binding the information to render
  77099. * @param effect The effect we are binding the data to
  77100. */
  77101. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77102. /**
  77103. * Binds the morph targets information from the mesh to the effect.
  77104. * @param abstractMesh The mesh we are binding the information to render
  77105. * @param effect The effect we are binding the data to
  77106. */
  77107. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77108. /**
  77109. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77110. * @param defines The generated defines used in the effect
  77111. * @param effect The effect we are binding the data to
  77112. * @param scene The scene we are willing to render with logarithmic scale for
  77113. */
  77114. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77115. /**
  77116. * Binds the clip plane information from the scene to the effect.
  77117. * @param scene The scene the clip plane information are extracted from
  77118. * @param effect The effect we are binding the data to
  77119. */
  77120. static BindClipPlane(effect: Effect, scene: Scene): void;
  77121. }
  77122. }
  77123. declare module BABYLON {
  77124. /** @hidden */
  77125. export var packingFunctions: {
  77126. name: string;
  77127. shader: string;
  77128. };
  77129. }
  77130. declare module BABYLON {
  77131. /** @hidden */
  77132. export var shadowMapPixelShader: {
  77133. name: string;
  77134. shader: string;
  77135. };
  77136. }
  77137. declare module BABYLON {
  77138. /** @hidden */
  77139. export var bonesDeclaration: {
  77140. name: string;
  77141. shader: string;
  77142. };
  77143. }
  77144. declare module BABYLON {
  77145. /** @hidden */
  77146. export var morphTargetsVertexGlobalDeclaration: {
  77147. name: string;
  77148. shader: string;
  77149. };
  77150. }
  77151. declare module BABYLON {
  77152. /** @hidden */
  77153. export var morphTargetsVertexDeclaration: {
  77154. name: string;
  77155. shader: string;
  77156. };
  77157. }
  77158. declare module BABYLON {
  77159. /** @hidden */
  77160. export var instancesDeclaration: {
  77161. name: string;
  77162. shader: string;
  77163. };
  77164. }
  77165. declare module BABYLON {
  77166. /** @hidden */
  77167. export var helperFunctions: {
  77168. name: string;
  77169. shader: string;
  77170. };
  77171. }
  77172. declare module BABYLON {
  77173. /** @hidden */
  77174. export var morphTargetsVertex: {
  77175. name: string;
  77176. shader: string;
  77177. };
  77178. }
  77179. declare module BABYLON {
  77180. /** @hidden */
  77181. export var instancesVertex: {
  77182. name: string;
  77183. shader: string;
  77184. };
  77185. }
  77186. declare module BABYLON {
  77187. /** @hidden */
  77188. export var bonesVertex: {
  77189. name: string;
  77190. shader: string;
  77191. };
  77192. }
  77193. declare module BABYLON {
  77194. /** @hidden */
  77195. export var shadowMapVertexShader: {
  77196. name: string;
  77197. shader: string;
  77198. };
  77199. }
  77200. declare module BABYLON {
  77201. /** @hidden */
  77202. export var depthBoxBlurPixelShader: {
  77203. name: string;
  77204. shader: string;
  77205. };
  77206. }
  77207. declare module BABYLON {
  77208. /**
  77209. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77210. */
  77211. export interface ICustomShaderOptions {
  77212. /**
  77213. * Gets or sets the custom shader name to use
  77214. */
  77215. shaderName: string;
  77216. /**
  77217. * The list of attribute names used in the shader
  77218. */
  77219. attributes?: string[];
  77220. /**
  77221. * The list of unifrom names used in the shader
  77222. */
  77223. uniforms?: string[];
  77224. /**
  77225. * The list of sampler names used in the shader
  77226. */
  77227. samplers?: string[];
  77228. /**
  77229. * The list of defines used in the shader
  77230. */
  77231. defines?: string[];
  77232. }
  77233. /**
  77234. * Interface to implement to create a shadow generator compatible with BJS.
  77235. */
  77236. export interface IShadowGenerator {
  77237. /**
  77238. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77239. * @returns The render target texture if present otherwise, null
  77240. */
  77241. getShadowMap(): Nullable<RenderTargetTexture>;
  77242. /**
  77243. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77244. * @returns The render target texture if the shadow map is present otherwise, null
  77245. */
  77246. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77247. /**
  77248. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77249. * @param subMesh The submesh we want to render in the shadow map
  77250. * @param useInstances Defines wether will draw in the map using instances
  77251. * @returns true if ready otherwise, false
  77252. */
  77253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77254. /**
  77255. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77256. * @param defines Defines of the material we want to update
  77257. * @param lightIndex Index of the light in the enabled light list of the material
  77258. */
  77259. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77260. /**
  77261. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77262. * defined in the generator but impacting the effect).
  77263. * It implies the unifroms available on the materials are the standard BJS ones.
  77264. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77265. * @param effect The effect we are binfing the information for
  77266. */
  77267. bindShadowLight(lightIndex: string, effect: Effect): void;
  77268. /**
  77269. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77270. * (eq to shadow prjection matrix * light transform matrix)
  77271. * @returns The transform matrix used to create the shadow map
  77272. */
  77273. getTransformMatrix(): Matrix;
  77274. /**
  77275. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77276. * Cube and 2D textures for instance.
  77277. */
  77278. recreateShadowMap(): void;
  77279. /**
  77280. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77281. * @param onCompiled Callback triggered at the and of the effects compilation
  77282. * @param options Sets of optional options forcing the compilation with different modes
  77283. */
  77284. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77285. useInstances: boolean;
  77286. }>): void;
  77287. /**
  77288. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77289. * @param options Sets of optional options forcing the compilation with different modes
  77290. * @returns A promise that resolves when the compilation completes
  77291. */
  77292. forceCompilationAsync(options?: Partial<{
  77293. useInstances: boolean;
  77294. }>): Promise<void>;
  77295. /**
  77296. * Serializes the shadow generator setup to a json object.
  77297. * @returns The serialized JSON object
  77298. */
  77299. serialize(): any;
  77300. /**
  77301. * Disposes the Shadow map and related Textures and effects.
  77302. */
  77303. dispose(): void;
  77304. }
  77305. /**
  77306. * Default implementation IShadowGenerator.
  77307. * This is the main object responsible of generating shadows in the framework.
  77308. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77309. */
  77310. export class ShadowGenerator implements IShadowGenerator {
  77311. /**
  77312. * Shadow generator mode None: no filtering applied.
  77313. */
  77314. static readonly FILTER_NONE: number;
  77315. /**
  77316. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77317. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77318. */
  77319. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77320. /**
  77321. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77322. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77323. */
  77324. static readonly FILTER_POISSONSAMPLING: number;
  77325. /**
  77326. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77328. */
  77329. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77330. /**
  77331. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77332. * edge artifacts on steep falloff.
  77333. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77334. */
  77335. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77336. /**
  77337. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77338. * edge artifacts on steep falloff.
  77339. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77340. */
  77341. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77342. /**
  77343. * Shadow generator mode PCF: Percentage Closer Filtering
  77344. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77345. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77346. */
  77347. static readonly FILTER_PCF: number;
  77348. /**
  77349. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77350. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77351. * Contact Hardening
  77352. */
  77353. static readonly FILTER_PCSS: number;
  77354. /**
  77355. * Reserved for PCF and PCSS
  77356. * Highest Quality.
  77357. *
  77358. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77359. *
  77360. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77361. */
  77362. static readonly QUALITY_HIGH: number;
  77363. /**
  77364. * Reserved for PCF and PCSS
  77365. * Good tradeoff for quality/perf cross devices
  77366. *
  77367. * Execute PCF on a 3*3 kernel.
  77368. *
  77369. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77370. */
  77371. static readonly QUALITY_MEDIUM: number;
  77372. /**
  77373. * Reserved for PCF and PCSS
  77374. * The lowest quality but the fastest.
  77375. *
  77376. * Execute PCF on a 1*1 kernel.
  77377. *
  77378. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77379. */
  77380. static readonly QUALITY_LOW: number;
  77381. /** Gets or sets the custom shader name to use */
  77382. customShaderOptions: ICustomShaderOptions;
  77383. /**
  77384. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77385. */
  77386. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77387. /**
  77388. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77389. */
  77390. onAfterShadowMapRenderObservable: Observable<Effect>;
  77391. /**
  77392. * Observable triggered before a mesh is rendered in the shadow map.
  77393. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77394. */
  77395. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77396. /**
  77397. * Observable triggered after a mesh is rendered in the shadow map.
  77398. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77399. */
  77400. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77401. private _bias;
  77402. /**
  77403. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77404. */
  77405. /**
  77406. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77407. */
  77408. bias: number;
  77409. private _normalBias;
  77410. /**
  77411. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77412. */
  77413. /**
  77414. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77415. */
  77416. normalBias: number;
  77417. private _blurBoxOffset;
  77418. /**
  77419. * Gets the blur box offset: offset applied during the blur pass.
  77420. * Only useful if useKernelBlur = false
  77421. */
  77422. /**
  77423. * Sets the blur box offset: offset applied during the blur pass.
  77424. * Only useful if useKernelBlur = false
  77425. */
  77426. blurBoxOffset: number;
  77427. private _blurScale;
  77428. /**
  77429. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77430. * 2 means half of the size.
  77431. */
  77432. /**
  77433. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77434. * 2 means half of the size.
  77435. */
  77436. blurScale: number;
  77437. private _blurKernel;
  77438. /**
  77439. * Gets the blur kernel: kernel size of the blur pass.
  77440. * Only useful if useKernelBlur = true
  77441. */
  77442. /**
  77443. * Sets the blur kernel: kernel size of the blur pass.
  77444. * Only useful if useKernelBlur = true
  77445. */
  77446. blurKernel: number;
  77447. private _useKernelBlur;
  77448. /**
  77449. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77450. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77451. */
  77452. /**
  77453. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77454. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77455. */
  77456. useKernelBlur: boolean;
  77457. private _depthScale;
  77458. /**
  77459. * Gets the depth scale used in ESM mode.
  77460. */
  77461. /**
  77462. * Sets the depth scale used in ESM mode.
  77463. * This can override the scale stored on the light.
  77464. */
  77465. depthScale: number;
  77466. private _filter;
  77467. /**
  77468. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77469. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77470. */
  77471. /**
  77472. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77473. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77474. */
  77475. filter: number;
  77476. /**
  77477. * Gets if the current filter is set to Poisson Sampling.
  77478. */
  77479. /**
  77480. * Sets the current filter to Poisson Sampling.
  77481. */
  77482. usePoissonSampling: boolean;
  77483. /**
  77484. * Gets if the current filter is set to ESM.
  77485. */
  77486. /**
  77487. * Sets the current filter is to ESM.
  77488. */
  77489. useExponentialShadowMap: boolean;
  77490. /**
  77491. * Gets if the current filter is set to filtered ESM.
  77492. */
  77493. /**
  77494. * Gets if the current filter is set to filtered ESM.
  77495. */
  77496. useBlurExponentialShadowMap: boolean;
  77497. /**
  77498. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77499. * exponential to prevent steep falloff artifacts).
  77500. */
  77501. /**
  77502. * Sets the current filter to "close ESM" (using the inverse of the
  77503. * exponential to prevent steep falloff artifacts).
  77504. */
  77505. useCloseExponentialShadowMap: boolean;
  77506. /**
  77507. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77508. * exponential to prevent steep falloff artifacts).
  77509. */
  77510. /**
  77511. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77512. * exponential to prevent steep falloff artifacts).
  77513. */
  77514. useBlurCloseExponentialShadowMap: boolean;
  77515. /**
  77516. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77517. */
  77518. /**
  77519. * Sets the current filter to "PCF" (percentage closer filtering).
  77520. */
  77521. usePercentageCloserFiltering: boolean;
  77522. private _filteringQuality;
  77523. /**
  77524. * Gets the PCF or PCSS Quality.
  77525. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77526. */
  77527. /**
  77528. * Sets the PCF or PCSS Quality.
  77529. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77530. */
  77531. filteringQuality: number;
  77532. /**
  77533. * Gets if the current filter is set to "PCSS" (contact hardening).
  77534. */
  77535. /**
  77536. * Sets the current filter to "PCSS" (contact hardening).
  77537. */
  77538. useContactHardeningShadow: boolean;
  77539. private _contactHardeningLightSizeUVRatio;
  77540. /**
  77541. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77542. * Using a ratio helps keeping shape stability independently of the map size.
  77543. *
  77544. * It does not account for the light projection as it was having too much
  77545. * instability during the light setup or during light position changes.
  77546. *
  77547. * Only valid if useContactHardeningShadow is true.
  77548. */
  77549. /**
  77550. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77551. * Using a ratio helps keeping shape stability independently of the map size.
  77552. *
  77553. * It does not account for the light projection as it was having too much
  77554. * instability during the light setup or during light position changes.
  77555. *
  77556. * Only valid if useContactHardeningShadow is true.
  77557. */
  77558. contactHardeningLightSizeUVRatio: number;
  77559. private _darkness;
  77560. /** Gets or sets the actual darkness of a shadow */
  77561. darkness: number;
  77562. /**
  77563. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77564. * 0 means strongest and 1 would means no shadow.
  77565. * @returns the darkness.
  77566. */
  77567. getDarkness(): number;
  77568. /**
  77569. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77570. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77571. * @returns the shadow generator allowing fluent coding.
  77572. */
  77573. setDarkness(darkness: number): ShadowGenerator;
  77574. private _transparencyShadow;
  77575. /** Gets or sets the ability to have transparent shadow */
  77576. transparencyShadow: boolean;
  77577. /**
  77578. * Sets the ability to have transparent shadow (boolean).
  77579. * @param transparent True if transparent else False
  77580. * @returns the shadow generator allowing fluent coding
  77581. */
  77582. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77583. private _shadowMap;
  77584. private _shadowMap2;
  77585. /**
  77586. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77587. * @returns The render target texture if present otherwise, null
  77588. */
  77589. getShadowMap(): Nullable<RenderTargetTexture>;
  77590. /**
  77591. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77592. * @returns The render target texture if the shadow map is present otherwise, null
  77593. */
  77594. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77595. /**
  77596. * Gets the class name of that object
  77597. * @returns "ShadowGenerator"
  77598. */
  77599. getClassName(): string;
  77600. /**
  77601. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77602. * @param mesh Mesh to add
  77603. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77604. * @returns the Shadow Generator itself
  77605. */
  77606. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77607. /**
  77608. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77609. * @param mesh Mesh to remove
  77610. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77611. * @returns the Shadow Generator itself
  77612. */
  77613. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77614. /**
  77615. * Controls the extent to which the shadows fade out at the edge of the frustum
  77616. * Used only by directionals and spots
  77617. */
  77618. frustumEdgeFalloff: number;
  77619. private _light;
  77620. /**
  77621. * Returns the associated light object.
  77622. * @returns the light generating the shadow
  77623. */
  77624. getLight(): IShadowLight;
  77625. /**
  77626. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77627. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77628. * It might on the other hand introduce peter panning.
  77629. */
  77630. forceBackFacesOnly: boolean;
  77631. private _scene;
  77632. private _lightDirection;
  77633. private _effect;
  77634. private _viewMatrix;
  77635. private _projectionMatrix;
  77636. private _transformMatrix;
  77637. private _cachedPosition;
  77638. private _cachedDirection;
  77639. private _cachedDefines;
  77640. private _currentRenderID;
  77641. private _boxBlurPostprocess;
  77642. private _kernelBlurXPostprocess;
  77643. private _kernelBlurYPostprocess;
  77644. private _blurPostProcesses;
  77645. private _mapSize;
  77646. private _currentFaceIndex;
  77647. private _currentFaceIndexCache;
  77648. private _textureType;
  77649. private _defaultTextureMatrix;
  77650. private _storedUniqueId;
  77651. /** @hidden */
  77652. static _SceneComponentInitialization: (scene: Scene) => void;
  77653. /**
  77654. * Creates a ShadowGenerator object.
  77655. * A ShadowGenerator is the required tool to use the shadows.
  77656. * Each light casting shadows needs to use its own ShadowGenerator.
  77657. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77658. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77659. * @param light The light object generating the shadows.
  77660. * @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.
  77661. */
  77662. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77663. private _initializeGenerator;
  77664. private _initializeShadowMap;
  77665. private _initializeBlurRTTAndPostProcesses;
  77666. private _renderForShadowMap;
  77667. private _renderSubMeshForShadowMap;
  77668. private _applyFilterValues;
  77669. /**
  77670. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77671. * @param onCompiled Callback triggered at the and of the effects compilation
  77672. * @param options Sets of optional options forcing the compilation with different modes
  77673. */
  77674. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77675. useInstances: boolean;
  77676. }>): void;
  77677. /**
  77678. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77679. * @param options Sets of optional options forcing the compilation with different modes
  77680. * @returns A promise that resolves when the compilation completes
  77681. */
  77682. forceCompilationAsync(options?: Partial<{
  77683. useInstances: boolean;
  77684. }>): Promise<void>;
  77685. /**
  77686. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77687. * @param subMesh The submesh we want to render in the shadow map
  77688. * @param useInstances Defines wether will draw in the map using instances
  77689. * @returns true if ready otherwise, false
  77690. */
  77691. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77692. /**
  77693. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77694. * @param defines Defines of the material we want to update
  77695. * @param lightIndex Index of the light in the enabled light list of the material
  77696. */
  77697. prepareDefines(defines: any, lightIndex: number): void;
  77698. /**
  77699. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77700. * defined in the generator but impacting the effect).
  77701. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77702. * @param effect The effect we are binfing the information for
  77703. */
  77704. bindShadowLight(lightIndex: string, effect: Effect): void;
  77705. /**
  77706. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77707. * (eq to shadow prjection matrix * light transform matrix)
  77708. * @returns The transform matrix used to create the shadow map
  77709. */
  77710. getTransformMatrix(): Matrix;
  77711. /**
  77712. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77713. * Cube and 2D textures for instance.
  77714. */
  77715. recreateShadowMap(): void;
  77716. private _disposeBlurPostProcesses;
  77717. private _disposeRTTandPostProcesses;
  77718. /**
  77719. * Disposes the ShadowGenerator.
  77720. * Returns nothing.
  77721. */
  77722. dispose(): void;
  77723. /**
  77724. * Serializes the shadow generator setup to a json object.
  77725. * @returns The serialized JSON object
  77726. */
  77727. serialize(): any;
  77728. /**
  77729. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77730. * @param parsedShadowGenerator The JSON object to parse
  77731. * @param scene The scene to create the shadow map for
  77732. * @returns The parsed shadow generator
  77733. */
  77734. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77735. }
  77736. }
  77737. declare module BABYLON {
  77738. /**
  77739. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77740. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77741. * 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.
  77742. */
  77743. export abstract class Light extends Node {
  77744. /**
  77745. * Falloff Default: light is falling off following the material specification:
  77746. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77747. */
  77748. static readonly FALLOFF_DEFAULT: number;
  77749. /**
  77750. * Falloff Physical: light is falling off following the inverse squared distance law.
  77751. */
  77752. static readonly FALLOFF_PHYSICAL: number;
  77753. /**
  77754. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77755. * to enhance interoperability with other engines.
  77756. */
  77757. static readonly FALLOFF_GLTF: number;
  77758. /**
  77759. * Falloff Standard: light is falling off like in the standard material
  77760. * to enhance interoperability with other materials.
  77761. */
  77762. static readonly FALLOFF_STANDARD: number;
  77763. /**
  77764. * If every light affecting the material is in this lightmapMode,
  77765. * material.lightmapTexture adds or multiplies
  77766. * (depends on material.useLightmapAsShadowmap)
  77767. * after every other light calculations.
  77768. */
  77769. static readonly LIGHTMAP_DEFAULT: number;
  77770. /**
  77771. * material.lightmapTexture as only diffuse lighting from this light
  77772. * adds only specular lighting from this light
  77773. * adds dynamic shadows
  77774. */
  77775. static readonly LIGHTMAP_SPECULAR: number;
  77776. /**
  77777. * material.lightmapTexture as only lighting
  77778. * no light calculation from this light
  77779. * only adds dynamic shadows from this light
  77780. */
  77781. static readonly LIGHTMAP_SHADOWSONLY: number;
  77782. /**
  77783. * Each light type uses the default quantity according to its type:
  77784. * point/spot lights use luminous intensity
  77785. * directional lights use illuminance
  77786. */
  77787. static readonly INTENSITYMODE_AUTOMATIC: number;
  77788. /**
  77789. * lumen (lm)
  77790. */
  77791. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77792. /**
  77793. * candela (lm/sr)
  77794. */
  77795. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77796. /**
  77797. * lux (lm/m^2)
  77798. */
  77799. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77800. /**
  77801. * nit (cd/m^2)
  77802. */
  77803. static readonly INTENSITYMODE_LUMINANCE: number;
  77804. /**
  77805. * Light type const id of the point light.
  77806. */
  77807. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77808. /**
  77809. * Light type const id of the directional light.
  77810. */
  77811. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77812. /**
  77813. * Light type const id of the spot light.
  77814. */
  77815. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77816. /**
  77817. * Light type const id of the hemispheric light.
  77818. */
  77819. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77820. /**
  77821. * Diffuse gives the basic color to an object.
  77822. */
  77823. diffuse: Color3;
  77824. /**
  77825. * Specular produces a highlight color on an object.
  77826. * Note: This is note affecting PBR materials.
  77827. */
  77828. specular: Color3;
  77829. /**
  77830. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77831. * falling off base on range or angle.
  77832. * This can be set to any values in Light.FALLOFF_x.
  77833. *
  77834. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77835. * other types of materials.
  77836. */
  77837. falloffType: number;
  77838. /**
  77839. * Strength of the light.
  77840. * Note: By default it is define in the framework own unit.
  77841. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77842. */
  77843. intensity: number;
  77844. private _range;
  77845. protected _inverseSquaredRange: number;
  77846. /**
  77847. * Defines how far from the source the light is impacting in scene units.
  77848. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77849. */
  77850. /**
  77851. * Defines how far from the source the light is impacting in scene units.
  77852. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77853. */
  77854. range: number;
  77855. /**
  77856. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77857. * of light.
  77858. */
  77859. private _photometricScale;
  77860. private _intensityMode;
  77861. /**
  77862. * Gets the photometric scale used to interpret the intensity.
  77863. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77864. */
  77865. /**
  77866. * Sets the photometric scale used to interpret the intensity.
  77867. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77868. */
  77869. intensityMode: number;
  77870. private _radius;
  77871. /**
  77872. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77873. */
  77874. /**
  77875. * sets the light radius used by PBR Materials to simulate soft area lights.
  77876. */
  77877. radius: number;
  77878. private _renderPriority;
  77879. /**
  77880. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77881. * exceeding the number allowed of the materials.
  77882. */
  77883. renderPriority: number;
  77884. private _shadowEnabled;
  77885. /**
  77886. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77887. * the current shadow generator.
  77888. */
  77889. /**
  77890. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77891. * the current shadow generator.
  77892. */
  77893. shadowEnabled: boolean;
  77894. private _includedOnlyMeshes;
  77895. /**
  77896. * Gets the only meshes impacted by this light.
  77897. */
  77898. /**
  77899. * Sets the only meshes impacted by this light.
  77900. */
  77901. includedOnlyMeshes: AbstractMesh[];
  77902. private _excludedMeshes;
  77903. /**
  77904. * Gets the meshes not impacted by this light.
  77905. */
  77906. /**
  77907. * Sets the meshes not impacted by this light.
  77908. */
  77909. excludedMeshes: AbstractMesh[];
  77910. private _excludeWithLayerMask;
  77911. /**
  77912. * Gets the layer id use to find what meshes are not impacted by the light.
  77913. * Inactive if 0
  77914. */
  77915. /**
  77916. * Sets the layer id use to find what meshes are not impacted by the light.
  77917. * Inactive if 0
  77918. */
  77919. excludeWithLayerMask: number;
  77920. private _includeOnlyWithLayerMask;
  77921. /**
  77922. * Gets the layer id use to find what meshes are impacted by the light.
  77923. * Inactive if 0
  77924. */
  77925. /**
  77926. * Sets the layer id use to find what meshes are impacted by the light.
  77927. * Inactive if 0
  77928. */
  77929. includeOnlyWithLayerMask: number;
  77930. private _lightmapMode;
  77931. /**
  77932. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77933. */
  77934. /**
  77935. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77936. */
  77937. lightmapMode: number;
  77938. /**
  77939. * Shadow generator associted to the light.
  77940. * @hidden Internal use only.
  77941. */
  77942. _shadowGenerator: Nullable<IShadowGenerator>;
  77943. /**
  77944. * @hidden Internal use only.
  77945. */
  77946. _excludedMeshesIds: string[];
  77947. /**
  77948. * @hidden Internal use only.
  77949. */
  77950. _includedOnlyMeshesIds: string[];
  77951. /**
  77952. * The current light unifom buffer.
  77953. * @hidden Internal use only.
  77954. */
  77955. _uniformBuffer: UniformBuffer;
  77956. /** @hidden */
  77957. _renderId: number;
  77958. /**
  77959. * Creates a Light object in the scene.
  77960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77961. * @param name The firendly name of the light
  77962. * @param scene The scene the light belongs too
  77963. */
  77964. constructor(name: string, scene: Scene);
  77965. protected abstract _buildUniformLayout(): void;
  77966. /**
  77967. * Sets the passed Effect "effect" with the Light information.
  77968. * @param effect The effect to update
  77969. * @param lightIndex The index of the light in the effect to update
  77970. * @returns The light
  77971. */
  77972. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77973. /**
  77974. * Sets the passed Effect "effect" with the Light information.
  77975. * @param effect The effect to update
  77976. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77977. * @returns The light
  77978. */
  77979. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77980. /**
  77981. * Returns the string "Light".
  77982. * @returns the class name
  77983. */
  77984. getClassName(): string;
  77985. /** @hidden */
  77986. readonly _isLight: boolean;
  77987. /**
  77988. * Converts the light information to a readable string for debug purpose.
  77989. * @param fullDetails Supports for multiple levels of logging within scene loading
  77990. * @returns the human readable light info
  77991. */
  77992. toString(fullDetails?: boolean): string;
  77993. /** @hidden */
  77994. protected _syncParentEnabledState(): void;
  77995. /**
  77996. * Set the enabled state of this node.
  77997. * @param value - the new enabled state
  77998. */
  77999. setEnabled(value: boolean): void;
  78000. /**
  78001. * Returns the Light associated shadow generator if any.
  78002. * @return the associated shadow generator.
  78003. */
  78004. getShadowGenerator(): Nullable<IShadowGenerator>;
  78005. /**
  78006. * Returns a Vector3, the absolute light position in the World.
  78007. * @returns the world space position of the light
  78008. */
  78009. getAbsolutePosition(): Vector3;
  78010. /**
  78011. * Specifies if the light will affect the passed mesh.
  78012. * @param mesh The mesh to test against the light
  78013. * @return true the mesh is affected otherwise, false.
  78014. */
  78015. canAffectMesh(mesh: AbstractMesh): boolean;
  78016. /**
  78017. * Sort function to order lights for rendering.
  78018. * @param a First Light object to compare to second.
  78019. * @param b Second Light object to compare first.
  78020. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78021. */
  78022. static CompareLightsPriority(a: Light, b: Light): number;
  78023. /**
  78024. * Releases resources associated with this node.
  78025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78027. */
  78028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78029. /**
  78030. * Returns the light type ID (integer).
  78031. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78032. */
  78033. getTypeID(): number;
  78034. /**
  78035. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78036. * @returns the scaled intensity in intensity mode unit
  78037. */
  78038. getScaledIntensity(): number;
  78039. /**
  78040. * Returns a new Light object, named "name", from the current one.
  78041. * @param name The name of the cloned light
  78042. * @returns the new created light
  78043. */
  78044. clone(name: string): Nullable<Light>;
  78045. /**
  78046. * Serializes the current light into a Serialization object.
  78047. * @returns the serialized object.
  78048. */
  78049. serialize(): any;
  78050. /**
  78051. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78052. * This new light is named "name" and added to the passed scene.
  78053. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78054. * @param name The friendly name of the light
  78055. * @param scene The scene the new light will belong to
  78056. * @returns the constructor function
  78057. */
  78058. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78059. /**
  78060. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78061. * @param parsedLight The JSON representation of the light
  78062. * @param scene The scene to create the parsed light in
  78063. * @returns the created light after parsing
  78064. */
  78065. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78066. private _hookArrayForExcluded;
  78067. private _hookArrayForIncludedOnly;
  78068. private _resyncMeshes;
  78069. /**
  78070. * Forces the meshes to update their light related information in their rendering used effects
  78071. * @hidden Internal Use Only
  78072. */
  78073. _markMeshesAsLightDirty(): void;
  78074. /**
  78075. * Recomputes the cached photometric scale if needed.
  78076. */
  78077. private _computePhotometricScale;
  78078. /**
  78079. * Returns the Photometric Scale according to the light type and intensity mode.
  78080. */
  78081. private _getPhotometricScale;
  78082. /**
  78083. * Reorder the light in the scene according to their defined priority.
  78084. * @hidden Internal Use Only
  78085. */
  78086. _reorderLightsInScene(): void;
  78087. /**
  78088. * Prepares the list of defines specific to the light type.
  78089. * @param defines the list of defines
  78090. * @param lightIndex defines the index of the light for the effect
  78091. */
  78092. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78093. }
  78094. }
  78095. declare module BABYLON {
  78096. /**
  78097. * Interface used to define Action
  78098. */
  78099. export interface IAction {
  78100. /**
  78101. * Trigger for the action
  78102. */
  78103. trigger: number;
  78104. /** Options of the trigger */
  78105. triggerOptions: any;
  78106. /**
  78107. * Gets the trigger parameters
  78108. * @returns the trigger parameters
  78109. */
  78110. getTriggerParameter(): any;
  78111. /**
  78112. * Internal only - executes current action event
  78113. * @hidden
  78114. */
  78115. _executeCurrent(evt?: ActionEvent): void;
  78116. /**
  78117. * Serialize placeholder for child classes
  78118. * @param parent of child
  78119. * @returns the serialized object
  78120. */
  78121. serialize(parent: any): any;
  78122. /**
  78123. * Internal only
  78124. * @hidden
  78125. */
  78126. _prepare(): void;
  78127. /**
  78128. * Internal only - manager for action
  78129. * @hidden
  78130. */
  78131. _actionManager: AbstractActionManager;
  78132. /**
  78133. * Adds action to chain of actions, may be a DoNothingAction
  78134. * @param action defines the next action to execute
  78135. * @returns The action passed in
  78136. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78137. */
  78138. then(action: IAction): IAction;
  78139. }
  78140. /**
  78141. * The action to be carried out following a trigger
  78142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78143. */
  78144. export class Action implements IAction {
  78145. /** the trigger, with or without parameters, for the action */
  78146. triggerOptions: any;
  78147. /**
  78148. * Trigger for the action
  78149. */
  78150. trigger: number;
  78151. /**
  78152. * Internal only - manager for action
  78153. * @hidden
  78154. */
  78155. _actionManager: ActionManager;
  78156. private _nextActiveAction;
  78157. private _child;
  78158. private _condition?;
  78159. private _triggerParameter;
  78160. /**
  78161. * An event triggered prior to action being executed.
  78162. */
  78163. onBeforeExecuteObservable: Observable<Action>;
  78164. /**
  78165. * Creates a new Action
  78166. * @param triggerOptions the trigger, with or without parameters, for the action
  78167. * @param condition an optional determinant of action
  78168. */
  78169. constructor(
  78170. /** the trigger, with or without parameters, for the action */
  78171. triggerOptions: any, condition?: Condition);
  78172. /**
  78173. * Internal only
  78174. * @hidden
  78175. */
  78176. _prepare(): void;
  78177. /**
  78178. * Gets the trigger parameters
  78179. * @returns the trigger parameters
  78180. */
  78181. getTriggerParameter(): any;
  78182. /**
  78183. * Internal only - executes current action event
  78184. * @hidden
  78185. */
  78186. _executeCurrent(evt?: ActionEvent): void;
  78187. /**
  78188. * Execute placeholder for child classes
  78189. * @param evt optional action event
  78190. */
  78191. execute(evt?: ActionEvent): void;
  78192. /**
  78193. * Skips to next active action
  78194. */
  78195. skipToNextActiveAction(): void;
  78196. /**
  78197. * Adds action to chain of actions, may be a DoNothingAction
  78198. * @param action defines the next action to execute
  78199. * @returns The action passed in
  78200. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78201. */
  78202. then(action: Action): Action;
  78203. /**
  78204. * Internal only
  78205. * @hidden
  78206. */
  78207. _getProperty(propertyPath: string): string;
  78208. /**
  78209. * Internal only
  78210. * @hidden
  78211. */
  78212. _getEffectiveTarget(target: any, propertyPath: string): any;
  78213. /**
  78214. * Serialize placeholder for child classes
  78215. * @param parent of child
  78216. * @returns the serialized object
  78217. */
  78218. serialize(parent: any): any;
  78219. /**
  78220. * Internal only called by serialize
  78221. * @hidden
  78222. */
  78223. protected _serialize(serializedAction: any, parent?: any): any;
  78224. /**
  78225. * Internal only
  78226. * @hidden
  78227. */
  78228. static _SerializeValueAsString: (value: any) => string;
  78229. /**
  78230. * Internal only
  78231. * @hidden
  78232. */
  78233. static _GetTargetProperty: (target: Node | Scene) => {
  78234. name: string;
  78235. targetType: string;
  78236. value: string;
  78237. };
  78238. }
  78239. }
  78240. declare module BABYLON {
  78241. /**
  78242. * A Condition applied to an Action
  78243. */
  78244. export class Condition {
  78245. /**
  78246. * Internal only - manager for action
  78247. * @hidden
  78248. */
  78249. _actionManager: ActionManager;
  78250. /**
  78251. * Internal only
  78252. * @hidden
  78253. */
  78254. _evaluationId: number;
  78255. /**
  78256. * Internal only
  78257. * @hidden
  78258. */
  78259. _currentResult: boolean;
  78260. /**
  78261. * Creates a new Condition
  78262. * @param actionManager the manager of the action the condition is applied to
  78263. */
  78264. constructor(actionManager: ActionManager);
  78265. /**
  78266. * Check if the current condition is valid
  78267. * @returns a boolean
  78268. */
  78269. isValid(): boolean;
  78270. /**
  78271. * Internal only
  78272. * @hidden
  78273. */
  78274. _getProperty(propertyPath: string): string;
  78275. /**
  78276. * Internal only
  78277. * @hidden
  78278. */
  78279. _getEffectiveTarget(target: any, propertyPath: string): any;
  78280. /**
  78281. * Serialize placeholder for child classes
  78282. * @returns the serialized object
  78283. */
  78284. serialize(): any;
  78285. /**
  78286. * Internal only
  78287. * @hidden
  78288. */
  78289. protected _serialize(serializedCondition: any): any;
  78290. }
  78291. /**
  78292. * Defines specific conditional operators as extensions of Condition
  78293. */
  78294. export class ValueCondition extends Condition {
  78295. /** path to specify the property of the target the conditional operator uses */
  78296. propertyPath: string;
  78297. /** the value compared by the conditional operator against the current value of the property */
  78298. value: any;
  78299. /** the conditional operator, default ValueCondition.IsEqual */
  78300. operator: number;
  78301. /**
  78302. * Internal only
  78303. * @hidden
  78304. */
  78305. private static _IsEqual;
  78306. /**
  78307. * Internal only
  78308. * @hidden
  78309. */
  78310. private static _IsDifferent;
  78311. /**
  78312. * Internal only
  78313. * @hidden
  78314. */
  78315. private static _IsGreater;
  78316. /**
  78317. * Internal only
  78318. * @hidden
  78319. */
  78320. private static _IsLesser;
  78321. /**
  78322. * returns the number for IsEqual
  78323. */
  78324. static readonly IsEqual: number;
  78325. /**
  78326. * Returns the number for IsDifferent
  78327. */
  78328. static readonly IsDifferent: number;
  78329. /**
  78330. * Returns the number for IsGreater
  78331. */
  78332. static readonly IsGreater: number;
  78333. /**
  78334. * Returns the number for IsLesser
  78335. */
  78336. static readonly IsLesser: number;
  78337. /**
  78338. * Internal only The action manager for the condition
  78339. * @hidden
  78340. */
  78341. _actionManager: ActionManager;
  78342. /**
  78343. * Internal only
  78344. * @hidden
  78345. */
  78346. private _target;
  78347. /**
  78348. * Internal only
  78349. * @hidden
  78350. */
  78351. private _effectiveTarget;
  78352. /**
  78353. * Internal only
  78354. * @hidden
  78355. */
  78356. private _property;
  78357. /**
  78358. * Creates a new ValueCondition
  78359. * @param actionManager manager for the action the condition applies to
  78360. * @param target for the action
  78361. * @param propertyPath path to specify the property of the target the conditional operator uses
  78362. * @param value the value compared by the conditional operator against the current value of the property
  78363. * @param operator the conditional operator, default ValueCondition.IsEqual
  78364. */
  78365. constructor(actionManager: ActionManager, target: any,
  78366. /** path to specify the property of the target the conditional operator uses */
  78367. propertyPath: string,
  78368. /** the value compared by the conditional operator against the current value of the property */
  78369. value: any,
  78370. /** the conditional operator, default ValueCondition.IsEqual */
  78371. operator?: number);
  78372. /**
  78373. * Compares the given value with the property value for the specified conditional operator
  78374. * @returns the result of the comparison
  78375. */
  78376. isValid(): boolean;
  78377. /**
  78378. * Serialize the ValueCondition into a JSON compatible object
  78379. * @returns serialization object
  78380. */
  78381. serialize(): any;
  78382. /**
  78383. * Gets the name of the conditional operator for the ValueCondition
  78384. * @param operator the conditional operator
  78385. * @returns the name
  78386. */
  78387. static GetOperatorName(operator: number): string;
  78388. }
  78389. /**
  78390. * Defines a predicate condition as an extension of Condition
  78391. */
  78392. export class PredicateCondition extends Condition {
  78393. /** defines the predicate function used to validate the condition */
  78394. predicate: () => boolean;
  78395. /**
  78396. * Internal only - manager for action
  78397. * @hidden
  78398. */
  78399. _actionManager: ActionManager;
  78400. /**
  78401. * Creates a new PredicateCondition
  78402. * @param actionManager manager for the action the condition applies to
  78403. * @param predicate defines the predicate function used to validate the condition
  78404. */
  78405. constructor(actionManager: ActionManager,
  78406. /** defines the predicate function used to validate the condition */
  78407. predicate: () => boolean);
  78408. /**
  78409. * @returns the validity of the predicate condition
  78410. */
  78411. isValid(): boolean;
  78412. }
  78413. /**
  78414. * Defines a state condition as an extension of Condition
  78415. */
  78416. export class StateCondition extends Condition {
  78417. /** Value to compare with target state */
  78418. value: string;
  78419. /**
  78420. * Internal only - manager for action
  78421. * @hidden
  78422. */
  78423. _actionManager: ActionManager;
  78424. /**
  78425. * Internal only
  78426. * @hidden
  78427. */
  78428. private _target;
  78429. /**
  78430. * Creates a new StateCondition
  78431. * @param actionManager manager for the action the condition applies to
  78432. * @param target of the condition
  78433. * @param value to compare with target state
  78434. */
  78435. constructor(actionManager: ActionManager, target: any,
  78436. /** Value to compare with target state */
  78437. value: string);
  78438. /**
  78439. * Gets a boolean indicating if the current condition is met
  78440. * @returns the validity of the state
  78441. */
  78442. isValid(): boolean;
  78443. /**
  78444. * Serialize the StateCondition into a JSON compatible object
  78445. * @returns serialization object
  78446. */
  78447. serialize(): any;
  78448. }
  78449. }
  78450. declare module BABYLON {
  78451. /**
  78452. * This defines an action responsible to toggle a boolean once triggered.
  78453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78454. */
  78455. export class SwitchBooleanAction extends Action {
  78456. /**
  78457. * The path to the boolean property in the target object
  78458. */
  78459. propertyPath: string;
  78460. private _target;
  78461. private _effectiveTarget;
  78462. private _property;
  78463. /**
  78464. * Instantiate the action
  78465. * @param triggerOptions defines the trigger options
  78466. * @param target defines the object containing the boolean
  78467. * @param propertyPath defines the path to the boolean property in the target object
  78468. * @param condition defines the trigger related conditions
  78469. */
  78470. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78471. /** @hidden */
  78472. _prepare(): void;
  78473. /**
  78474. * Execute the action toggle the boolean value.
  78475. */
  78476. execute(): void;
  78477. /**
  78478. * Serializes the actions and its related information.
  78479. * @param parent defines the object to serialize in
  78480. * @returns the serialized object
  78481. */
  78482. serialize(parent: any): any;
  78483. }
  78484. /**
  78485. * This defines an action responsible to set a the state field of the target
  78486. * to a desired value once triggered.
  78487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78488. */
  78489. export class SetStateAction extends Action {
  78490. /**
  78491. * The value to store in the state field.
  78492. */
  78493. value: string;
  78494. private _target;
  78495. /**
  78496. * Instantiate the action
  78497. * @param triggerOptions defines the trigger options
  78498. * @param target defines the object containing the state property
  78499. * @param value defines the value to store in the state field
  78500. * @param condition defines the trigger related conditions
  78501. */
  78502. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78503. /**
  78504. * Execute the action and store the value on the target state property.
  78505. */
  78506. execute(): void;
  78507. /**
  78508. * Serializes the actions and its related information.
  78509. * @param parent defines the object to serialize in
  78510. * @returns the serialized object
  78511. */
  78512. serialize(parent: any): any;
  78513. }
  78514. /**
  78515. * This defines an action responsible to set a property of the target
  78516. * to a desired value once triggered.
  78517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78518. */
  78519. export class SetValueAction extends Action {
  78520. /**
  78521. * The path of the property to set in the target.
  78522. */
  78523. propertyPath: string;
  78524. /**
  78525. * The value to set in the property
  78526. */
  78527. value: any;
  78528. private _target;
  78529. private _effectiveTarget;
  78530. private _property;
  78531. /**
  78532. * Instantiate the action
  78533. * @param triggerOptions defines the trigger options
  78534. * @param target defines the object containing the property
  78535. * @param propertyPath defines the path of the property to set in the target
  78536. * @param value defines the value to set in the property
  78537. * @param condition defines the trigger related conditions
  78538. */
  78539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78540. /** @hidden */
  78541. _prepare(): void;
  78542. /**
  78543. * Execute the action and set the targetted property to the desired value.
  78544. */
  78545. execute(): void;
  78546. /**
  78547. * Serializes the actions and its related information.
  78548. * @param parent defines the object to serialize in
  78549. * @returns the serialized object
  78550. */
  78551. serialize(parent: any): any;
  78552. }
  78553. /**
  78554. * This defines an action responsible to increment the target value
  78555. * to a desired value once triggered.
  78556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78557. */
  78558. export class IncrementValueAction extends Action {
  78559. /**
  78560. * The path of the property to increment in the target.
  78561. */
  78562. propertyPath: string;
  78563. /**
  78564. * The value we should increment the property by.
  78565. */
  78566. value: any;
  78567. private _target;
  78568. private _effectiveTarget;
  78569. private _property;
  78570. /**
  78571. * Instantiate the action
  78572. * @param triggerOptions defines the trigger options
  78573. * @param target defines the object containing the property
  78574. * @param propertyPath defines the path of the property to increment in the target
  78575. * @param value defines the value value we should increment the property by
  78576. * @param condition defines the trigger related conditions
  78577. */
  78578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78579. /** @hidden */
  78580. _prepare(): void;
  78581. /**
  78582. * Execute the action and increment the target of the value amount.
  78583. */
  78584. execute(): void;
  78585. /**
  78586. * Serializes the actions and its related information.
  78587. * @param parent defines the object to serialize in
  78588. * @returns the serialized object
  78589. */
  78590. serialize(parent: any): any;
  78591. }
  78592. /**
  78593. * This defines an action responsible to start an animation once triggered.
  78594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78595. */
  78596. export class PlayAnimationAction extends Action {
  78597. /**
  78598. * Where the animation should start (animation frame)
  78599. */
  78600. from: number;
  78601. /**
  78602. * Where the animation should stop (animation frame)
  78603. */
  78604. to: number;
  78605. /**
  78606. * Define if the animation should loop or stop after the first play.
  78607. */
  78608. loop?: boolean;
  78609. private _target;
  78610. /**
  78611. * Instantiate the action
  78612. * @param triggerOptions defines the trigger options
  78613. * @param target defines the target animation or animation name
  78614. * @param from defines from where the animation should start (animation frame)
  78615. * @param end defines where the animation should stop (animation frame)
  78616. * @param loop defines if the animation should loop or stop after the first play
  78617. * @param condition defines the trigger related conditions
  78618. */
  78619. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78620. /** @hidden */
  78621. _prepare(): void;
  78622. /**
  78623. * Execute the action and play the animation.
  78624. */
  78625. execute(): void;
  78626. /**
  78627. * Serializes the actions and its related information.
  78628. * @param parent defines the object to serialize in
  78629. * @returns the serialized object
  78630. */
  78631. serialize(parent: any): any;
  78632. }
  78633. /**
  78634. * This defines an action responsible to stop an animation once triggered.
  78635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78636. */
  78637. export class StopAnimationAction extends Action {
  78638. private _target;
  78639. /**
  78640. * Instantiate the action
  78641. * @param triggerOptions defines the trigger options
  78642. * @param target defines the target animation or animation name
  78643. * @param condition defines the trigger related conditions
  78644. */
  78645. constructor(triggerOptions: any, target: any, condition?: Condition);
  78646. /** @hidden */
  78647. _prepare(): void;
  78648. /**
  78649. * Execute the action and stop the animation.
  78650. */
  78651. execute(): void;
  78652. /**
  78653. * Serializes the actions and its related information.
  78654. * @param parent defines the object to serialize in
  78655. * @returns the serialized object
  78656. */
  78657. serialize(parent: any): any;
  78658. }
  78659. /**
  78660. * This defines an action responsible that does nothing once triggered.
  78661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78662. */
  78663. export class DoNothingAction extends Action {
  78664. /**
  78665. * Instantiate the action
  78666. * @param triggerOptions defines the trigger options
  78667. * @param condition defines the trigger related conditions
  78668. */
  78669. constructor(triggerOptions?: any, condition?: Condition);
  78670. /**
  78671. * Execute the action and do nothing.
  78672. */
  78673. execute(): void;
  78674. /**
  78675. * Serializes the actions and its related information.
  78676. * @param parent defines the object to serialize in
  78677. * @returns the serialized object
  78678. */
  78679. serialize(parent: any): any;
  78680. }
  78681. /**
  78682. * This defines an action responsible to trigger several actions once triggered.
  78683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78684. */
  78685. export class CombineAction extends Action {
  78686. /**
  78687. * The list of aggregated animations to run.
  78688. */
  78689. children: Action[];
  78690. /**
  78691. * Instantiate the action
  78692. * @param triggerOptions defines the trigger options
  78693. * @param children defines the list of aggregated animations to run
  78694. * @param condition defines the trigger related conditions
  78695. */
  78696. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78697. /** @hidden */
  78698. _prepare(): void;
  78699. /**
  78700. * Execute the action and executes all the aggregated actions.
  78701. */
  78702. execute(evt: ActionEvent): void;
  78703. /**
  78704. * Serializes the actions and its related information.
  78705. * @param parent defines the object to serialize in
  78706. * @returns the serialized object
  78707. */
  78708. serialize(parent: any): any;
  78709. }
  78710. /**
  78711. * This defines an action responsible to run code (external event) once triggered.
  78712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78713. */
  78714. export class ExecuteCodeAction extends Action {
  78715. /**
  78716. * The callback function to run.
  78717. */
  78718. func: (evt: ActionEvent) => void;
  78719. /**
  78720. * Instantiate the action
  78721. * @param triggerOptions defines the trigger options
  78722. * @param func defines the callback function to run
  78723. * @param condition defines the trigger related conditions
  78724. */
  78725. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78726. /**
  78727. * Execute the action and run the attached code.
  78728. */
  78729. execute(evt: ActionEvent): void;
  78730. }
  78731. /**
  78732. * This defines an action responsible to set the parent property of the target once triggered.
  78733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78734. */
  78735. export class SetParentAction extends Action {
  78736. private _parent;
  78737. private _target;
  78738. /**
  78739. * Instantiate the action
  78740. * @param triggerOptions defines the trigger options
  78741. * @param target defines the target containing the parent property
  78742. * @param parent defines from where the animation should start (animation frame)
  78743. * @param condition defines the trigger related conditions
  78744. */
  78745. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78746. /** @hidden */
  78747. _prepare(): void;
  78748. /**
  78749. * Execute the action and set the parent property.
  78750. */
  78751. execute(): void;
  78752. /**
  78753. * Serializes the actions and its related information.
  78754. * @param parent defines the object to serialize in
  78755. * @returns the serialized object
  78756. */
  78757. serialize(parent: any): any;
  78758. }
  78759. }
  78760. declare module BABYLON {
  78761. /**
  78762. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78763. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78765. */
  78766. export class ActionManager extends AbstractActionManager {
  78767. /**
  78768. * Nothing
  78769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78770. */
  78771. static readonly NothingTrigger: number;
  78772. /**
  78773. * On pick
  78774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78775. */
  78776. static readonly OnPickTrigger: number;
  78777. /**
  78778. * On left pick
  78779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78780. */
  78781. static readonly OnLeftPickTrigger: number;
  78782. /**
  78783. * On right pick
  78784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78785. */
  78786. static readonly OnRightPickTrigger: number;
  78787. /**
  78788. * On center pick
  78789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78790. */
  78791. static readonly OnCenterPickTrigger: number;
  78792. /**
  78793. * On pick down
  78794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78795. */
  78796. static readonly OnPickDownTrigger: number;
  78797. /**
  78798. * On double pick
  78799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78800. */
  78801. static readonly OnDoublePickTrigger: number;
  78802. /**
  78803. * On pick up
  78804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78805. */
  78806. static readonly OnPickUpTrigger: number;
  78807. /**
  78808. * On pick out.
  78809. * This trigger will only be raised if you also declared a OnPickDown
  78810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78811. */
  78812. static readonly OnPickOutTrigger: number;
  78813. /**
  78814. * On long press
  78815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78816. */
  78817. static readonly OnLongPressTrigger: number;
  78818. /**
  78819. * On pointer over
  78820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78821. */
  78822. static readonly OnPointerOverTrigger: number;
  78823. /**
  78824. * On pointer out
  78825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78826. */
  78827. static readonly OnPointerOutTrigger: number;
  78828. /**
  78829. * On every frame
  78830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78831. */
  78832. static readonly OnEveryFrameTrigger: number;
  78833. /**
  78834. * On intersection enter
  78835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78836. */
  78837. static readonly OnIntersectionEnterTrigger: number;
  78838. /**
  78839. * On intersection exit
  78840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78841. */
  78842. static readonly OnIntersectionExitTrigger: number;
  78843. /**
  78844. * On key down
  78845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78846. */
  78847. static readonly OnKeyDownTrigger: number;
  78848. /**
  78849. * On key up
  78850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78851. */
  78852. static readonly OnKeyUpTrigger: number;
  78853. private _scene;
  78854. /**
  78855. * Creates a new action manager
  78856. * @param scene defines the hosting scene
  78857. */
  78858. constructor(scene: Scene);
  78859. /**
  78860. * Releases all associated resources
  78861. */
  78862. dispose(): void;
  78863. /**
  78864. * Gets hosting scene
  78865. * @returns the hosting scene
  78866. */
  78867. getScene(): Scene;
  78868. /**
  78869. * Does this action manager handles actions of any of the given triggers
  78870. * @param triggers defines the triggers to be tested
  78871. * @return a boolean indicating whether one (or more) of the triggers is handled
  78872. */
  78873. hasSpecificTriggers(triggers: number[]): boolean;
  78874. /**
  78875. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78876. * speed.
  78877. * @param triggerA defines the trigger to be tested
  78878. * @param triggerB defines the trigger to be tested
  78879. * @return a boolean indicating whether one (or more) of the triggers is handled
  78880. */
  78881. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78882. /**
  78883. * Does this action manager handles actions of a given trigger
  78884. * @param trigger defines the trigger to be tested
  78885. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78886. * @return whether the trigger is handled
  78887. */
  78888. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78889. /**
  78890. * Does this action manager has pointer triggers
  78891. */
  78892. readonly hasPointerTriggers: boolean;
  78893. /**
  78894. * Does this action manager has pick triggers
  78895. */
  78896. readonly hasPickTriggers: boolean;
  78897. /**
  78898. * Registers an action to this action manager
  78899. * @param action defines the action to be registered
  78900. * @return the action amended (prepared) after registration
  78901. */
  78902. registerAction(action: IAction): Nullable<IAction>;
  78903. /**
  78904. * Unregisters an action to this action manager
  78905. * @param action defines the action to be unregistered
  78906. * @return a boolean indicating whether the action has been unregistered
  78907. */
  78908. unregisterAction(action: IAction): Boolean;
  78909. /**
  78910. * Process a specific trigger
  78911. * @param trigger defines the trigger to process
  78912. * @param evt defines the event details to be processed
  78913. */
  78914. processTrigger(trigger: number, evt?: IActionEvent): void;
  78915. /** @hidden */
  78916. _getEffectiveTarget(target: any, propertyPath: string): any;
  78917. /** @hidden */
  78918. _getProperty(propertyPath: string): string;
  78919. /**
  78920. * Serialize this manager to a JSON object
  78921. * @param name defines the property name to store this manager
  78922. * @returns a JSON representation of this manager
  78923. */
  78924. serialize(name: string): any;
  78925. /**
  78926. * Creates a new ActionManager from a JSON data
  78927. * @param parsedActions defines the JSON data to read from
  78928. * @param object defines the hosting mesh
  78929. * @param scene defines the hosting scene
  78930. */
  78931. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78932. /**
  78933. * Get a trigger name by index
  78934. * @param trigger defines the trigger index
  78935. * @returns a trigger name
  78936. */
  78937. static GetTriggerName(trigger: number): string;
  78938. }
  78939. }
  78940. declare module BABYLON {
  78941. /**
  78942. * Class representing a ray with position and direction
  78943. */
  78944. export class Ray {
  78945. /** origin point */
  78946. origin: Vector3;
  78947. /** direction */
  78948. direction: Vector3;
  78949. /** length of the ray */
  78950. length: number;
  78951. private static readonly TmpVector3;
  78952. private _tmpRay;
  78953. /**
  78954. * Creates a new ray
  78955. * @param origin origin point
  78956. * @param direction direction
  78957. * @param length length of the ray
  78958. */
  78959. constructor(
  78960. /** origin point */
  78961. origin: Vector3,
  78962. /** direction */
  78963. direction: Vector3,
  78964. /** length of the ray */
  78965. length?: number);
  78966. /**
  78967. * Checks if the ray intersects a box
  78968. * @param minimum bound of the box
  78969. * @param maximum bound of the box
  78970. * @param intersectionTreshold extra extend to be added to the box in all direction
  78971. * @returns if the box was hit
  78972. */
  78973. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78974. /**
  78975. * Checks if the ray intersects a box
  78976. * @param box the bounding box to check
  78977. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78978. * @returns if the box was hit
  78979. */
  78980. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78981. /**
  78982. * If the ray hits a sphere
  78983. * @param sphere the bounding sphere to check
  78984. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78985. * @returns true if it hits the sphere
  78986. */
  78987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78988. /**
  78989. * If the ray hits a triange
  78990. * @param vertex0 triangle vertex
  78991. * @param vertex1 triangle vertex
  78992. * @param vertex2 triangle vertex
  78993. * @returns intersection information if hit
  78994. */
  78995. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78996. /**
  78997. * Checks if ray intersects a plane
  78998. * @param plane the plane to check
  78999. * @returns the distance away it was hit
  79000. */
  79001. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79002. /**
  79003. * Calculate the intercept of a ray on a given axis
  79004. * @param axis to check 'x' | 'y' | 'z'
  79005. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79006. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79007. */
  79008. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79009. /**
  79010. * Checks if ray intersects a mesh
  79011. * @param mesh the mesh to check
  79012. * @param fastCheck if only the bounding box should checked
  79013. * @returns picking info of the intersecton
  79014. */
  79015. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79016. /**
  79017. * Checks if ray intersects a mesh
  79018. * @param meshes the meshes to check
  79019. * @param fastCheck if only the bounding box should checked
  79020. * @param results array to store result in
  79021. * @returns Array of picking infos
  79022. */
  79023. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79024. private _comparePickingInfo;
  79025. private static smallnum;
  79026. private static rayl;
  79027. /**
  79028. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79029. * @param sega the first point of the segment to test the intersection against
  79030. * @param segb the second point of the segment to test the intersection against
  79031. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79032. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79033. */
  79034. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79035. /**
  79036. * Update the ray from viewport position
  79037. * @param x position
  79038. * @param y y position
  79039. * @param viewportWidth viewport width
  79040. * @param viewportHeight viewport height
  79041. * @param world world matrix
  79042. * @param view view matrix
  79043. * @param projection projection matrix
  79044. * @returns this ray updated
  79045. */
  79046. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79047. /**
  79048. * Creates a ray with origin and direction of 0,0,0
  79049. * @returns the new ray
  79050. */
  79051. static Zero(): Ray;
  79052. /**
  79053. * Creates a new ray from screen space and viewport
  79054. * @param x position
  79055. * @param y y position
  79056. * @param viewportWidth viewport width
  79057. * @param viewportHeight viewport height
  79058. * @param world world matrix
  79059. * @param view view matrix
  79060. * @param projection projection matrix
  79061. * @returns new ray
  79062. */
  79063. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79064. /**
  79065. * 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
  79066. * transformed to the given world matrix.
  79067. * @param origin The origin point
  79068. * @param end The end point
  79069. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79070. * @returns the new ray
  79071. */
  79072. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79073. /**
  79074. * Transforms a ray by a matrix
  79075. * @param ray ray to transform
  79076. * @param matrix matrix to apply
  79077. * @returns the resulting new ray
  79078. */
  79079. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79080. /**
  79081. * Transforms a ray by a matrix
  79082. * @param ray ray to transform
  79083. * @param matrix matrix to apply
  79084. * @param result ray to store result in
  79085. */
  79086. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79087. /**
  79088. * Unproject a ray from screen space to object space
  79089. * @param sourceX defines the screen space x coordinate to use
  79090. * @param sourceY defines the screen space y coordinate to use
  79091. * @param viewportWidth defines the current width of the viewport
  79092. * @param viewportHeight defines the current height of the viewport
  79093. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79094. * @param view defines the view matrix to use
  79095. * @param projection defines the projection matrix to use
  79096. */
  79097. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79098. }
  79099. /**
  79100. * Type used to define predicate used to select faces when a mesh intersection is detected
  79101. */
  79102. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79103. interface Scene {
  79104. /** @hidden */
  79105. _tempPickingRay: Nullable<Ray>;
  79106. /** @hidden */
  79107. _cachedRayForTransform: Ray;
  79108. /** @hidden */
  79109. _pickWithRayInverseMatrix: Matrix;
  79110. /** @hidden */
  79111. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79112. /** @hidden */
  79113. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79114. }
  79115. }
  79116. declare module BABYLON {
  79117. /**
  79118. * Groups all the scene component constants in one place to ease maintenance.
  79119. * @hidden
  79120. */
  79121. export class SceneComponentConstants {
  79122. static readonly NAME_EFFECTLAYER: string;
  79123. static readonly NAME_LAYER: string;
  79124. static readonly NAME_LENSFLARESYSTEM: string;
  79125. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79126. static readonly NAME_PARTICLESYSTEM: string;
  79127. static readonly NAME_GAMEPAD: string;
  79128. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79129. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79130. static readonly NAME_DEPTHRENDERER: string;
  79131. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79132. static readonly NAME_SPRITE: string;
  79133. static readonly NAME_OUTLINERENDERER: string;
  79134. static readonly NAME_PROCEDURALTEXTURE: string;
  79135. static readonly NAME_SHADOWGENERATOR: string;
  79136. static readonly NAME_OCTREE: string;
  79137. static readonly NAME_PHYSICSENGINE: string;
  79138. static readonly NAME_AUDIO: string;
  79139. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79140. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79141. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79142. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79143. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79144. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79145. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79146. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79147. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79148. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79149. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79150. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79151. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79152. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79153. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79154. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79155. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79156. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79157. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79158. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79159. static readonly STEP_AFTERRENDER_AUDIO: number;
  79160. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79161. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79162. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79163. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79164. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79165. static readonly STEP_POINTERMOVE_SPRITE: number;
  79166. static readonly STEP_POINTERDOWN_SPRITE: number;
  79167. static readonly STEP_POINTERUP_SPRITE: number;
  79168. }
  79169. /**
  79170. * This represents a scene component.
  79171. *
  79172. * This is used to decouple the dependency the scene is having on the different workloads like
  79173. * layers, post processes...
  79174. */
  79175. export interface ISceneComponent {
  79176. /**
  79177. * The name of the component. Each component must have a unique name.
  79178. */
  79179. name: string;
  79180. /**
  79181. * The scene the component belongs to.
  79182. */
  79183. scene: Scene;
  79184. /**
  79185. * Register the component to one instance of a scene.
  79186. */
  79187. register(): void;
  79188. /**
  79189. * Rebuilds the elements related to this component in case of
  79190. * context lost for instance.
  79191. */
  79192. rebuild(): void;
  79193. /**
  79194. * Disposes the component and the associated ressources.
  79195. */
  79196. dispose(): void;
  79197. }
  79198. /**
  79199. * This represents a SERIALIZABLE scene component.
  79200. *
  79201. * This extends Scene Component to add Serialization methods on top.
  79202. */
  79203. export interface ISceneSerializableComponent extends ISceneComponent {
  79204. /**
  79205. * Adds all the elements from the container to the scene
  79206. * @param container the container holding the elements
  79207. */
  79208. addFromContainer(container: AbstractScene): void;
  79209. /**
  79210. * Removes all the elements in the container from the scene
  79211. * @param container contains the elements to remove
  79212. * @param dispose if the removed element should be disposed (default: false)
  79213. */
  79214. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79215. /**
  79216. * Serializes the component data to the specified json object
  79217. * @param serializationObject The object to serialize to
  79218. */
  79219. serialize(serializationObject: any): void;
  79220. }
  79221. /**
  79222. * Strong typing of a Mesh related stage step action
  79223. */
  79224. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79225. /**
  79226. * Strong typing of a Evaluate Sub Mesh related stage step action
  79227. */
  79228. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79229. /**
  79230. * Strong typing of a Active Mesh related stage step action
  79231. */
  79232. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79233. /**
  79234. * Strong typing of a Camera related stage step action
  79235. */
  79236. export type CameraStageAction = (camera: Camera) => void;
  79237. /**
  79238. * Strong typing of a Camera Frame buffer related stage step action
  79239. */
  79240. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79241. /**
  79242. * Strong typing of a Render Target related stage step action
  79243. */
  79244. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79245. /**
  79246. * Strong typing of a RenderingGroup related stage step action
  79247. */
  79248. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79249. /**
  79250. * Strong typing of a Mesh Render related stage step action
  79251. */
  79252. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79253. /**
  79254. * Strong typing of a simple stage step action
  79255. */
  79256. export type SimpleStageAction = () => void;
  79257. /**
  79258. * Strong typing of a render target action.
  79259. */
  79260. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79261. /**
  79262. * Strong typing of a pointer move action.
  79263. */
  79264. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79265. /**
  79266. * Strong typing of a pointer up/down action.
  79267. */
  79268. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79269. /**
  79270. * Representation of a stage in the scene (Basically a list of ordered steps)
  79271. * @hidden
  79272. */
  79273. export class Stage<T extends Function> extends Array<{
  79274. index: number;
  79275. component: ISceneComponent;
  79276. action: T;
  79277. }> {
  79278. /**
  79279. * Hide ctor from the rest of the world.
  79280. * @param items The items to add.
  79281. */
  79282. private constructor();
  79283. /**
  79284. * Creates a new Stage.
  79285. * @returns A new instance of a Stage
  79286. */
  79287. static Create<T extends Function>(): Stage<T>;
  79288. /**
  79289. * Registers a step in an ordered way in the targeted stage.
  79290. * @param index Defines the position to register the step in
  79291. * @param component Defines the component attached to the step
  79292. * @param action Defines the action to launch during the step
  79293. */
  79294. registerStep(index: number, component: ISceneComponent, action: T): void;
  79295. /**
  79296. * Clears all the steps from the stage.
  79297. */
  79298. clear(): void;
  79299. }
  79300. }
  79301. declare module BABYLON {
  79302. interface Scene {
  79303. /** @hidden */
  79304. _pointerOverSprite: Nullable<Sprite>;
  79305. /** @hidden */
  79306. _pickedDownSprite: Nullable<Sprite>;
  79307. /** @hidden */
  79308. _tempSpritePickingRay: Nullable<Ray>;
  79309. /**
  79310. * All of the sprite managers added to this scene
  79311. * @see http://doc.babylonjs.com/babylon101/sprites
  79312. */
  79313. spriteManagers: Array<ISpriteManager>;
  79314. /**
  79315. * An event triggered when sprites rendering is about to start
  79316. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79317. */
  79318. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79319. /**
  79320. * An event triggered when sprites rendering is done
  79321. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79322. */
  79323. onAfterSpritesRenderingObservable: Observable<Scene>;
  79324. /** @hidden */
  79325. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79326. /** Launch a ray to try to pick a sprite in the scene
  79327. * @param x position on screen
  79328. * @param y position on screen
  79329. * @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
  79330. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79331. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79332. * @returns a PickingInfo
  79333. */
  79334. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79335. /** Use the given ray to pick a sprite in the scene
  79336. * @param ray The ray (in world space) to use to pick meshes
  79337. * @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
  79338. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79339. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79340. * @returns a PickingInfo
  79341. */
  79342. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79343. /** @hidden */
  79344. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79345. /** Launch a ray to try to pick sprites in the scene
  79346. * @param x position on screen
  79347. * @param y position on screen
  79348. * @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
  79349. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79350. * @returns a PickingInfo array
  79351. */
  79352. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79353. /** Use the given ray to pick sprites in the scene
  79354. * @param ray The ray (in world space) to use to pick meshes
  79355. * @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
  79356. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79357. * @returns a PickingInfo array
  79358. */
  79359. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79360. /**
  79361. * Force the sprite under the pointer
  79362. * @param sprite defines the sprite to use
  79363. */
  79364. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79365. /**
  79366. * Gets the sprite under the pointer
  79367. * @returns a Sprite or null if no sprite is under the pointer
  79368. */
  79369. getPointerOverSprite(): Nullable<Sprite>;
  79370. }
  79371. /**
  79372. * Defines the sprite scene component responsible to manage sprites
  79373. * in a given scene.
  79374. */
  79375. export class SpriteSceneComponent implements ISceneComponent {
  79376. /**
  79377. * The component name helpfull to identify the component in the list of scene components.
  79378. */
  79379. readonly name: string;
  79380. /**
  79381. * The scene the component belongs to.
  79382. */
  79383. scene: Scene;
  79384. /** @hidden */
  79385. private _spritePredicate;
  79386. /**
  79387. * Creates a new instance of the component for the given scene
  79388. * @param scene Defines the scene to register the component in
  79389. */
  79390. constructor(scene: Scene);
  79391. /**
  79392. * Registers the component in a given scene
  79393. */
  79394. register(): void;
  79395. /**
  79396. * Rebuilds the elements related to this component in case of
  79397. * context lost for instance.
  79398. */
  79399. rebuild(): void;
  79400. /**
  79401. * Disposes the component and the associated ressources.
  79402. */
  79403. dispose(): void;
  79404. private _pickSpriteButKeepRay;
  79405. private _pointerMove;
  79406. private _pointerDown;
  79407. private _pointerUp;
  79408. }
  79409. }
  79410. declare module BABYLON {
  79411. /** @hidden */
  79412. export var fogFragmentDeclaration: {
  79413. name: string;
  79414. shader: string;
  79415. };
  79416. }
  79417. declare module BABYLON {
  79418. /** @hidden */
  79419. export var fogFragment: {
  79420. name: string;
  79421. shader: string;
  79422. };
  79423. }
  79424. declare module BABYLON {
  79425. /** @hidden */
  79426. export var spritesPixelShader: {
  79427. name: string;
  79428. shader: string;
  79429. };
  79430. }
  79431. declare module BABYLON {
  79432. /** @hidden */
  79433. export var fogVertexDeclaration: {
  79434. name: string;
  79435. shader: string;
  79436. };
  79437. }
  79438. declare module BABYLON {
  79439. /** @hidden */
  79440. export var spritesVertexShader: {
  79441. name: string;
  79442. shader: string;
  79443. };
  79444. }
  79445. declare module BABYLON {
  79446. /**
  79447. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79448. */
  79449. export interface ISpriteManager extends IDisposable {
  79450. /**
  79451. * Restricts the camera to viewing objects with the same layerMask.
  79452. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79453. */
  79454. layerMask: number;
  79455. /**
  79456. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79457. */
  79458. isPickable: boolean;
  79459. /**
  79460. * Specifies the rendering group id for this mesh (0 by default)
  79461. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79462. */
  79463. renderingGroupId: number;
  79464. /**
  79465. * Defines the list of sprites managed by the manager.
  79466. */
  79467. sprites: Array<Sprite>;
  79468. /**
  79469. * Tests the intersection of a sprite with a specific ray.
  79470. * @param ray The ray we are sending to test the collision
  79471. * @param camera The camera space we are sending rays in
  79472. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79473. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79474. * @returns picking info or null.
  79475. */
  79476. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79477. /**
  79478. * Intersects the sprites with a ray
  79479. * @param ray defines the ray to intersect with
  79480. * @param camera defines the current active camera
  79481. * @param predicate defines a predicate used to select candidate sprites
  79482. * @returns null if no hit or a PickingInfo array
  79483. */
  79484. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79485. /**
  79486. * Renders the list of sprites on screen.
  79487. */
  79488. render(): void;
  79489. }
  79490. /**
  79491. * Class used to manage multiple sprites on the same spritesheet
  79492. * @see http://doc.babylonjs.com/babylon101/sprites
  79493. */
  79494. export class SpriteManager implements ISpriteManager {
  79495. /** defines the manager's name */
  79496. name: string;
  79497. /** Gets the list of sprites */
  79498. sprites: Sprite[];
  79499. /** Gets or sets the rendering group id (0 by default) */
  79500. renderingGroupId: number;
  79501. /** Gets or sets camera layer mask */
  79502. layerMask: number;
  79503. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79504. fogEnabled: boolean;
  79505. /** Gets or sets a boolean indicating if the sprites are pickable */
  79506. isPickable: boolean;
  79507. /** Defines the default width of a cell in the spritesheet */
  79508. cellWidth: number;
  79509. /** Defines the default height of a cell in the spritesheet */
  79510. cellHeight: number;
  79511. /** Associative array from JSON sprite data file */
  79512. private _cellData;
  79513. /** Array of sprite names from JSON sprite data file */
  79514. private _spriteMap;
  79515. /** True when packed cell data from JSON file is ready*/
  79516. private _packedAndReady;
  79517. /**
  79518. * An event triggered when the manager is disposed.
  79519. */
  79520. onDisposeObservable: Observable<SpriteManager>;
  79521. private _onDisposeObserver;
  79522. /**
  79523. * Callback called when the manager is disposed
  79524. */
  79525. onDispose: () => void;
  79526. private _capacity;
  79527. private _fromPacked;
  79528. private _spriteTexture;
  79529. private _epsilon;
  79530. private _scene;
  79531. private _vertexData;
  79532. private _buffer;
  79533. private _vertexBuffers;
  79534. private _indexBuffer;
  79535. private _effectBase;
  79536. private _effectFog;
  79537. /**
  79538. * Gets or sets the spritesheet texture
  79539. */
  79540. texture: Texture;
  79541. /**
  79542. * Creates a new sprite manager
  79543. * @param name defines the manager's name
  79544. * @param imgUrl defines the sprite sheet url
  79545. * @param capacity defines the maximum allowed number of sprites
  79546. * @param cellSize defines the size of a sprite cell
  79547. * @param scene defines the hosting scene
  79548. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79549. * @param samplingMode defines the smapling mode to use with spritesheet
  79550. * @param fromPacked set to false; do not alter
  79551. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79552. */
  79553. constructor(
  79554. /** defines the manager's name */
  79555. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79556. private _makePacked;
  79557. private _appendSpriteVertex;
  79558. /**
  79559. * Intersects the sprites with a ray
  79560. * @param ray defines the ray to intersect with
  79561. * @param camera defines the current active camera
  79562. * @param predicate defines a predicate used to select candidate sprites
  79563. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79564. * @returns null if no hit or a PickingInfo
  79565. */
  79566. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79567. /**
  79568. * Intersects the sprites with a ray
  79569. * @param ray defines the ray to intersect with
  79570. * @param camera defines the current active camera
  79571. * @param predicate defines a predicate used to select candidate sprites
  79572. * @returns null if no hit or a PickingInfo array
  79573. */
  79574. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79575. /**
  79576. * Render all child sprites
  79577. */
  79578. render(): void;
  79579. /**
  79580. * Release associated resources
  79581. */
  79582. dispose(): void;
  79583. }
  79584. }
  79585. declare module BABYLON {
  79586. /**
  79587. * Class used to represent a sprite
  79588. * @see http://doc.babylonjs.com/babylon101/sprites
  79589. */
  79590. export class Sprite {
  79591. /** defines the name */
  79592. name: string;
  79593. /** Gets or sets the current world position */
  79594. position: Vector3;
  79595. /** Gets or sets the main color */
  79596. color: Color4;
  79597. /** Gets or sets the width */
  79598. width: number;
  79599. /** Gets or sets the height */
  79600. height: number;
  79601. /** Gets or sets rotation angle */
  79602. angle: number;
  79603. /** Gets or sets the cell index in the sprite sheet */
  79604. cellIndex: number;
  79605. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79606. cellRef: string;
  79607. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79608. invertU: number;
  79609. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79610. invertV: number;
  79611. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79612. disposeWhenFinishedAnimating: boolean;
  79613. /** Gets the list of attached animations */
  79614. animations: Animation[];
  79615. /** Gets or sets a boolean indicating if the sprite can be picked */
  79616. isPickable: boolean;
  79617. /**
  79618. * Gets or sets the associated action manager
  79619. */
  79620. actionManager: Nullable<ActionManager>;
  79621. private _animationStarted;
  79622. private _loopAnimation;
  79623. private _fromIndex;
  79624. private _toIndex;
  79625. private _delay;
  79626. private _direction;
  79627. private _manager;
  79628. private _time;
  79629. private _onAnimationEnd;
  79630. /**
  79631. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79632. */
  79633. isVisible: boolean;
  79634. /**
  79635. * Gets or sets the sprite size
  79636. */
  79637. size: number;
  79638. /**
  79639. * Creates a new Sprite
  79640. * @param name defines the name
  79641. * @param manager defines the manager
  79642. */
  79643. constructor(
  79644. /** defines the name */
  79645. name: string, manager: ISpriteManager);
  79646. /**
  79647. * Starts an animation
  79648. * @param from defines the initial key
  79649. * @param to defines the end key
  79650. * @param loop defines if the animation must loop
  79651. * @param delay defines the start delay (in ms)
  79652. * @param onAnimationEnd defines a callback to call when animation ends
  79653. */
  79654. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79655. /** Stops current animation (if any) */
  79656. stopAnimation(): void;
  79657. /** @hidden */
  79658. _animate(deltaTime: number): void;
  79659. /** Release associated resources */
  79660. dispose(): void;
  79661. }
  79662. }
  79663. declare module BABYLON {
  79664. /**
  79665. * Information about the result of picking within a scene
  79666. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79667. */
  79668. export class PickingInfo {
  79669. /** @hidden */
  79670. _pickingUnavailable: boolean;
  79671. /**
  79672. * If the pick collided with an object
  79673. */
  79674. hit: boolean;
  79675. /**
  79676. * Distance away where the pick collided
  79677. */
  79678. distance: number;
  79679. /**
  79680. * The location of pick collision
  79681. */
  79682. pickedPoint: Nullable<Vector3>;
  79683. /**
  79684. * The mesh corresponding the the pick collision
  79685. */
  79686. pickedMesh: Nullable<AbstractMesh>;
  79687. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79688. bu: number;
  79689. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79690. bv: number;
  79691. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79692. faceId: number;
  79693. /** Id of the the submesh that was picked */
  79694. subMeshId: number;
  79695. /** If a sprite was picked, this will be the sprite the pick collided with */
  79696. pickedSprite: Nullable<Sprite>;
  79697. /**
  79698. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79699. */
  79700. originMesh: Nullable<AbstractMesh>;
  79701. /**
  79702. * The ray that was used to perform the picking.
  79703. */
  79704. ray: Nullable<Ray>;
  79705. /**
  79706. * Gets the normal correspodning to the face the pick collided with
  79707. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79708. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79709. * @returns The normal correspodning to the face the pick collided with
  79710. */
  79711. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79712. /**
  79713. * Gets the texture coordinates of where the pick occured
  79714. * @returns the vector containing the coordnates of the texture
  79715. */
  79716. getTextureCoordinates(): Nullable<Vector2>;
  79717. }
  79718. }
  79719. declare module BABYLON {
  79720. /**
  79721. * Gather the list of pointer event types as constants.
  79722. */
  79723. export class PointerEventTypes {
  79724. /**
  79725. * 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.
  79726. */
  79727. static readonly POINTERDOWN: number;
  79728. /**
  79729. * The pointerup event is fired when a pointer is no longer active.
  79730. */
  79731. static readonly POINTERUP: number;
  79732. /**
  79733. * The pointermove event is fired when a pointer changes coordinates.
  79734. */
  79735. static readonly POINTERMOVE: number;
  79736. /**
  79737. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79738. */
  79739. static readonly POINTERWHEEL: number;
  79740. /**
  79741. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79742. */
  79743. static readonly POINTERPICK: number;
  79744. /**
  79745. * The pointertap event is fired when a the object has been touched and released without drag.
  79746. */
  79747. static readonly POINTERTAP: number;
  79748. /**
  79749. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79750. */
  79751. static readonly POINTERDOUBLETAP: number;
  79752. }
  79753. /**
  79754. * Base class of pointer info types.
  79755. */
  79756. export class PointerInfoBase {
  79757. /**
  79758. * Defines the type of event (PointerEventTypes)
  79759. */
  79760. type: number;
  79761. /**
  79762. * Defines the related dom event
  79763. */
  79764. event: PointerEvent | MouseWheelEvent;
  79765. /**
  79766. * Instantiates the base class of pointers info.
  79767. * @param type Defines the type of event (PointerEventTypes)
  79768. * @param event Defines the related dom event
  79769. */
  79770. constructor(
  79771. /**
  79772. * Defines the type of event (PointerEventTypes)
  79773. */
  79774. type: number,
  79775. /**
  79776. * Defines the related dom event
  79777. */
  79778. event: PointerEvent | MouseWheelEvent);
  79779. }
  79780. /**
  79781. * This class is used to store pointer related info for the onPrePointerObservable event.
  79782. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79783. */
  79784. export class PointerInfoPre extends PointerInfoBase {
  79785. /**
  79786. * Ray from a pointer if availible (eg. 6dof controller)
  79787. */
  79788. ray: Nullable<Ray>;
  79789. /**
  79790. * Defines the local position of the pointer on the canvas.
  79791. */
  79792. localPosition: Vector2;
  79793. /**
  79794. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79795. */
  79796. skipOnPointerObservable: boolean;
  79797. /**
  79798. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79799. * @param type Defines the type of event (PointerEventTypes)
  79800. * @param event Defines the related dom event
  79801. * @param localX Defines the local x coordinates of the pointer when the event occured
  79802. * @param localY Defines the local y coordinates of the pointer when the event occured
  79803. */
  79804. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79805. }
  79806. /**
  79807. * This type contains all the data related to a pointer event in Babylon.js.
  79808. * 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.
  79809. */
  79810. export class PointerInfo extends PointerInfoBase {
  79811. /**
  79812. * Defines the picking info associated to the info (if any)\
  79813. */
  79814. pickInfo: Nullable<PickingInfo>;
  79815. /**
  79816. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79817. * @param type Defines the type of event (PointerEventTypes)
  79818. * @param event Defines the related dom event
  79819. * @param pickInfo Defines the picking info associated to the info (if any)\
  79820. */
  79821. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79822. /**
  79823. * Defines the picking info associated to the info (if any)\
  79824. */
  79825. pickInfo: Nullable<PickingInfo>);
  79826. }
  79827. /**
  79828. * Data relating to a touch event on the screen.
  79829. */
  79830. export interface PointerTouch {
  79831. /**
  79832. * X coordinate of touch.
  79833. */
  79834. x: number;
  79835. /**
  79836. * Y coordinate of touch.
  79837. */
  79838. y: number;
  79839. /**
  79840. * Id of touch. Unique for each finger.
  79841. */
  79842. pointerId: number;
  79843. /**
  79844. * Event type passed from DOM.
  79845. */
  79846. type: any;
  79847. }
  79848. }
  79849. declare module BABYLON {
  79850. /**
  79851. * Manage the mouse inputs to control the movement of a free camera.
  79852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79853. */
  79854. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79855. /**
  79856. * Define if touch is enabled in the mouse input
  79857. */
  79858. touchEnabled: boolean;
  79859. /**
  79860. * Defines the camera the input is attached to.
  79861. */
  79862. camera: FreeCamera;
  79863. /**
  79864. * Defines the buttons associated with the input to handle camera move.
  79865. */
  79866. buttons: number[];
  79867. /**
  79868. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79869. */
  79870. angularSensibility: number;
  79871. private _pointerInput;
  79872. private _onMouseMove;
  79873. private _observer;
  79874. private previousPosition;
  79875. /**
  79876. * Observable for when a pointer move event occurs containing the move offset
  79877. */
  79878. onPointerMovedObservable: Observable<{
  79879. offsetX: number;
  79880. offsetY: number;
  79881. }>;
  79882. /**
  79883. * @hidden
  79884. * If the camera should be rotated automatically based on pointer movement
  79885. */
  79886. _allowCameraRotation: boolean;
  79887. /**
  79888. * Manage the mouse inputs to control the movement of a free camera.
  79889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79890. * @param touchEnabled Defines if touch is enabled or not
  79891. */
  79892. constructor(
  79893. /**
  79894. * Define if touch is enabled in the mouse input
  79895. */
  79896. touchEnabled?: boolean);
  79897. /**
  79898. * Attach the input controls to a specific dom element to get the input from.
  79899. * @param element Defines the element the controls should be listened from
  79900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79901. */
  79902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79903. /**
  79904. * Called on JS contextmenu event.
  79905. * Override this method to provide functionality.
  79906. */
  79907. protected onContextMenu(evt: PointerEvent): void;
  79908. /**
  79909. * Detach the current controls from the specified dom element.
  79910. * @param element Defines the element to stop listening the inputs from
  79911. */
  79912. detachControl(element: Nullable<HTMLElement>): void;
  79913. /**
  79914. * Gets the class name of the current intput.
  79915. * @returns the class name
  79916. */
  79917. getClassName(): string;
  79918. /**
  79919. * Get the friendly name associated with the input class.
  79920. * @returns the input friendly name
  79921. */
  79922. getSimpleName(): string;
  79923. }
  79924. }
  79925. declare module BABYLON {
  79926. /**
  79927. * Manage the touch inputs to control the movement of a free camera.
  79928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79929. */
  79930. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79931. /**
  79932. * Defines the camera the input is attached to.
  79933. */
  79934. camera: FreeCamera;
  79935. /**
  79936. * Defines the touch sensibility for rotation.
  79937. * The higher the faster.
  79938. */
  79939. touchAngularSensibility: number;
  79940. /**
  79941. * Defines the touch sensibility for move.
  79942. * The higher the faster.
  79943. */
  79944. touchMoveSensibility: number;
  79945. private _offsetX;
  79946. private _offsetY;
  79947. private _pointerPressed;
  79948. private _pointerInput;
  79949. private _observer;
  79950. private _onLostFocus;
  79951. /**
  79952. * Attach the input controls to a specific dom element to get the input from.
  79953. * @param element Defines the element the controls should be listened from
  79954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79955. */
  79956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79957. /**
  79958. * Detach the current controls from the specified dom element.
  79959. * @param element Defines the element to stop listening the inputs from
  79960. */
  79961. detachControl(element: Nullable<HTMLElement>): void;
  79962. /**
  79963. * Update the current camera state depending on the inputs that have been used this frame.
  79964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79965. */
  79966. checkInputs(): void;
  79967. /**
  79968. * Gets the class name of the current intput.
  79969. * @returns the class name
  79970. */
  79971. getClassName(): string;
  79972. /**
  79973. * Get the friendly name associated with the input class.
  79974. * @returns the input friendly name
  79975. */
  79976. getSimpleName(): string;
  79977. }
  79978. }
  79979. declare module BABYLON {
  79980. /**
  79981. * Default Inputs manager for the FreeCamera.
  79982. * It groups all the default supported inputs for ease of use.
  79983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79984. */
  79985. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79986. /**
  79987. * @hidden
  79988. */
  79989. _mouseInput: Nullable<FreeCameraMouseInput>;
  79990. /**
  79991. * Instantiates a new FreeCameraInputsManager.
  79992. * @param camera Defines the camera the inputs belong to
  79993. */
  79994. constructor(camera: FreeCamera);
  79995. /**
  79996. * Add keyboard input support to the input manager.
  79997. * @returns the current input manager
  79998. */
  79999. addKeyboard(): FreeCameraInputsManager;
  80000. /**
  80001. * Add mouse input support to the input manager.
  80002. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80003. * @returns the current input manager
  80004. */
  80005. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80006. /**
  80007. * Removes the mouse input support from the manager
  80008. * @returns the current input manager
  80009. */
  80010. removeMouse(): FreeCameraInputsManager;
  80011. /**
  80012. * Add touch input support to the input manager.
  80013. * @returns the current input manager
  80014. */
  80015. addTouch(): FreeCameraInputsManager;
  80016. /**
  80017. * Remove all attached input methods from a camera
  80018. */
  80019. clear(): void;
  80020. }
  80021. }
  80022. declare module BABYLON {
  80023. /**
  80024. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80025. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80026. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80027. */
  80028. export class FreeCamera extends TargetCamera {
  80029. /**
  80030. * Define the collision ellipsoid of the camera.
  80031. * This is helpful to simulate a camera body like the player body around the camera
  80032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80033. */
  80034. ellipsoid: Vector3;
  80035. /**
  80036. * Define an offset for the position of the ellipsoid around the camera.
  80037. * This can be helpful to determine the center of the body near the gravity center of the body
  80038. * instead of its head.
  80039. */
  80040. ellipsoidOffset: Vector3;
  80041. /**
  80042. * Enable or disable collisions of the camera with the rest of the scene objects.
  80043. */
  80044. checkCollisions: boolean;
  80045. /**
  80046. * Enable or disable gravity on the camera.
  80047. */
  80048. applyGravity: boolean;
  80049. /**
  80050. * Define the input manager associated to the camera.
  80051. */
  80052. inputs: FreeCameraInputsManager;
  80053. /**
  80054. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80055. * Higher values reduce sensitivity.
  80056. */
  80057. /**
  80058. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80059. * Higher values reduce sensitivity.
  80060. */
  80061. angularSensibility: number;
  80062. /**
  80063. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80064. */
  80065. keysUp: number[];
  80066. /**
  80067. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80068. */
  80069. keysDown: number[];
  80070. /**
  80071. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80072. */
  80073. keysLeft: number[];
  80074. /**
  80075. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80076. */
  80077. keysRight: number[];
  80078. /**
  80079. * Event raised when the camera collide with a mesh in the scene.
  80080. */
  80081. onCollide: (collidedMesh: AbstractMesh) => void;
  80082. private _collider;
  80083. private _needMoveForGravity;
  80084. private _oldPosition;
  80085. private _diffPosition;
  80086. private _newPosition;
  80087. /** @hidden */
  80088. _localDirection: Vector3;
  80089. /** @hidden */
  80090. _transformedDirection: Vector3;
  80091. /**
  80092. * Instantiates a Free Camera.
  80093. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80094. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80096. * @param name Define the name of the camera in the scene
  80097. * @param position Define the start position of the camera in the scene
  80098. * @param scene Define the scene the camera belongs to
  80099. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80100. */
  80101. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80102. /**
  80103. * Attached controls to the current camera.
  80104. * @param element Defines the element the controls should be listened from
  80105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80106. */
  80107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80108. /**
  80109. * Detach the current controls from the camera.
  80110. * The camera will stop reacting to inputs.
  80111. * @param element Defines the element to stop listening the inputs from
  80112. */
  80113. detachControl(element: HTMLElement): void;
  80114. private _collisionMask;
  80115. /**
  80116. * Define a collision mask to limit the list of object the camera can collide with
  80117. */
  80118. collisionMask: number;
  80119. /** @hidden */
  80120. _collideWithWorld(displacement: Vector3): void;
  80121. private _onCollisionPositionChange;
  80122. /** @hidden */
  80123. _checkInputs(): void;
  80124. /** @hidden */
  80125. _decideIfNeedsToMove(): boolean;
  80126. /** @hidden */
  80127. _updatePosition(): void;
  80128. /**
  80129. * Destroy the camera and release the current resources hold by it.
  80130. */
  80131. dispose(): void;
  80132. /**
  80133. * Gets the current object class name.
  80134. * @return the class name
  80135. */
  80136. getClassName(): string;
  80137. }
  80138. }
  80139. declare module BABYLON {
  80140. /**
  80141. * Represents a gamepad control stick position
  80142. */
  80143. export class StickValues {
  80144. /**
  80145. * The x component of the control stick
  80146. */
  80147. x: number;
  80148. /**
  80149. * The y component of the control stick
  80150. */
  80151. y: number;
  80152. /**
  80153. * Initializes the gamepad x and y control stick values
  80154. * @param x The x component of the gamepad control stick value
  80155. * @param y The y component of the gamepad control stick value
  80156. */
  80157. constructor(
  80158. /**
  80159. * The x component of the control stick
  80160. */
  80161. x: number,
  80162. /**
  80163. * The y component of the control stick
  80164. */
  80165. y: number);
  80166. }
  80167. /**
  80168. * An interface which manages callbacks for gamepad button changes
  80169. */
  80170. export interface GamepadButtonChanges {
  80171. /**
  80172. * Called when a gamepad has been changed
  80173. */
  80174. changed: boolean;
  80175. /**
  80176. * Called when a gamepad press event has been triggered
  80177. */
  80178. pressChanged: boolean;
  80179. /**
  80180. * Called when a touch event has been triggered
  80181. */
  80182. touchChanged: boolean;
  80183. /**
  80184. * Called when a value has changed
  80185. */
  80186. valueChanged: boolean;
  80187. }
  80188. /**
  80189. * Represents a gamepad
  80190. */
  80191. export class Gamepad {
  80192. /**
  80193. * The id of the gamepad
  80194. */
  80195. id: string;
  80196. /**
  80197. * The index of the gamepad
  80198. */
  80199. index: number;
  80200. /**
  80201. * The browser gamepad
  80202. */
  80203. browserGamepad: any;
  80204. /**
  80205. * Specifies what type of gamepad this represents
  80206. */
  80207. type: number;
  80208. private _leftStick;
  80209. private _rightStick;
  80210. /** @hidden */
  80211. _isConnected: boolean;
  80212. private _leftStickAxisX;
  80213. private _leftStickAxisY;
  80214. private _rightStickAxisX;
  80215. private _rightStickAxisY;
  80216. /**
  80217. * Triggered when the left control stick has been changed
  80218. */
  80219. private _onleftstickchanged;
  80220. /**
  80221. * Triggered when the right control stick has been changed
  80222. */
  80223. private _onrightstickchanged;
  80224. /**
  80225. * Represents a gamepad controller
  80226. */
  80227. static GAMEPAD: number;
  80228. /**
  80229. * Represents a generic controller
  80230. */
  80231. static GENERIC: number;
  80232. /**
  80233. * Represents an XBox controller
  80234. */
  80235. static XBOX: number;
  80236. /**
  80237. * Represents a pose-enabled controller
  80238. */
  80239. static POSE_ENABLED: number;
  80240. /**
  80241. * Represents an Dual Shock controller
  80242. */
  80243. static DUALSHOCK: number;
  80244. /**
  80245. * Specifies whether the left control stick should be Y-inverted
  80246. */
  80247. protected _invertLeftStickY: boolean;
  80248. /**
  80249. * Specifies if the gamepad has been connected
  80250. */
  80251. readonly isConnected: boolean;
  80252. /**
  80253. * Initializes the gamepad
  80254. * @param id The id of the gamepad
  80255. * @param index The index of the gamepad
  80256. * @param browserGamepad The browser gamepad
  80257. * @param leftStickX The x component of the left joystick
  80258. * @param leftStickY The y component of the left joystick
  80259. * @param rightStickX The x component of the right joystick
  80260. * @param rightStickY The y component of the right joystick
  80261. */
  80262. constructor(
  80263. /**
  80264. * The id of the gamepad
  80265. */
  80266. id: string,
  80267. /**
  80268. * The index of the gamepad
  80269. */
  80270. index: number,
  80271. /**
  80272. * The browser gamepad
  80273. */
  80274. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80275. /**
  80276. * Callback triggered when the left joystick has changed
  80277. * @param callback
  80278. */
  80279. onleftstickchanged(callback: (values: StickValues) => void): void;
  80280. /**
  80281. * Callback triggered when the right joystick has changed
  80282. * @param callback
  80283. */
  80284. onrightstickchanged(callback: (values: StickValues) => void): void;
  80285. /**
  80286. * Gets the left joystick
  80287. */
  80288. /**
  80289. * Sets the left joystick values
  80290. */
  80291. leftStick: StickValues;
  80292. /**
  80293. * Gets the right joystick
  80294. */
  80295. /**
  80296. * Sets the right joystick value
  80297. */
  80298. rightStick: StickValues;
  80299. /**
  80300. * Updates the gamepad joystick positions
  80301. */
  80302. update(): void;
  80303. /**
  80304. * Disposes the gamepad
  80305. */
  80306. dispose(): void;
  80307. }
  80308. /**
  80309. * Represents a generic gamepad
  80310. */
  80311. export class GenericPad extends Gamepad {
  80312. private _buttons;
  80313. private _onbuttondown;
  80314. private _onbuttonup;
  80315. /**
  80316. * Observable triggered when a button has been pressed
  80317. */
  80318. onButtonDownObservable: Observable<number>;
  80319. /**
  80320. * Observable triggered when a button has been released
  80321. */
  80322. onButtonUpObservable: Observable<number>;
  80323. /**
  80324. * Callback triggered when a button has been pressed
  80325. * @param callback Called when a button has been pressed
  80326. */
  80327. onbuttondown(callback: (buttonPressed: number) => void): void;
  80328. /**
  80329. * Callback triggered when a button has been released
  80330. * @param callback Called when a button has been released
  80331. */
  80332. onbuttonup(callback: (buttonReleased: number) => void): void;
  80333. /**
  80334. * Initializes the generic gamepad
  80335. * @param id The id of the generic gamepad
  80336. * @param index The index of the generic gamepad
  80337. * @param browserGamepad The browser gamepad
  80338. */
  80339. constructor(id: string, index: number, browserGamepad: any);
  80340. private _setButtonValue;
  80341. /**
  80342. * Updates the generic gamepad
  80343. */
  80344. update(): void;
  80345. /**
  80346. * Disposes the generic gamepad
  80347. */
  80348. dispose(): void;
  80349. }
  80350. }
  80351. declare module BABYLON {
  80352. interface Engine {
  80353. /**
  80354. * Creates a raw texture
  80355. * @param data defines the data to store in the texture
  80356. * @param width defines the width of the texture
  80357. * @param height defines the height of the texture
  80358. * @param format defines the format of the data
  80359. * @param generateMipMaps defines if the engine should generate the mip levels
  80360. * @param invertY defines if data must be stored with Y axis inverted
  80361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80362. * @param compression defines the compression used (null by default)
  80363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80364. * @returns the raw texture inside an InternalTexture
  80365. */
  80366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80367. /**
  80368. * Update a raw texture
  80369. * @param texture defines the texture to update
  80370. * @param data defines the data to store in the texture
  80371. * @param format defines the format of the data
  80372. * @param invertY defines if data must be stored with Y axis inverted
  80373. */
  80374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80375. /**
  80376. * Update a raw texture
  80377. * @param texture defines the texture to update
  80378. * @param data defines the data to store in the texture
  80379. * @param format defines the format of the data
  80380. * @param invertY defines if data must be stored with Y axis inverted
  80381. * @param compression defines the compression used (null by default)
  80382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80383. */
  80384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80385. /**
  80386. * Creates a new raw cube texture
  80387. * @param data defines the array of data to use to create each face
  80388. * @param size defines the size of the textures
  80389. * @param format defines the format of the data
  80390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80391. * @param generateMipMaps defines if the engine should generate the mip levels
  80392. * @param invertY defines if data must be stored with Y axis inverted
  80393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80394. * @param compression defines the compression used (null by default)
  80395. * @returns the cube texture as an InternalTexture
  80396. */
  80397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80398. /**
  80399. * Update a raw cube texture
  80400. * @param texture defines the texture to udpdate
  80401. * @param data defines the data to store
  80402. * @param format defines the data format
  80403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80404. * @param invertY defines if data must be stored with Y axis inverted
  80405. */
  80406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80407. /**
  80408. * Update a raw cube texture
  80409. * @param texture defines the texture to udpdate
  80410. * @param data defines the data to store
  80411. * @param format defines the data format
  80412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80413. * @param invertY defines if data must be stored with Y axis inverted
  80414. * @param compression defines the compression used (null by default)
  80415. */
  80416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80417. /**
  80418. * Update a raw cube texture
  80419. * @param texture defines the texture to udpdate
  80420. * @param data defines the data to store
  80421. * @param format defines the data format
  80422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80423. * @param invertY defines if data must be stored with Y axis inverted
  80424. * @param compression defines the compression used (null by default)
  80425. * @param level defines which level of the texture to update
  80426. */
  80427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80428. /**
  80429. * Creates a new raw cube texture from a specified url
  80430. * @param url defines the url where the data is located
  80431. * @param scene defines the current scene
  80432. * @param size defines the size of the textures
  80433. * @param format defines the format of the data
  80434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80435. * @param noMipmap defines if the engine should avoid generating the mip levels
  80436. * @param callback defines a callback used to extract texture data from loaded data
  80437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80438. * @param onLoad defines a callback called when texture is loaded
  80439. * @param onError defines a callback called if there is an error
  80440. * @returns the cube texture as an InternalTexture
  80441. */
  80442. 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;
  80443. /**
  80444. * Creates a new raw cube texture from a specified url
  80445. * @param url defines the url where the data is located
  80446. * @param scene defines the current scene
  80447. * @param size defines the size of the textures
  80448. * @param format defines the format of the data
  80449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80450. * @param noMipmap defines if the engine should avoid generating the mip levels
  80451. * @param callback defines a callback used to extract texture data from loaded data
  80452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80453. * @param onLoad defines a callback called when texture is loaded
  80454. * @param onError defines a callback called if there is an error
  80455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80456. * @param invertY defines if data must be stored with Y axis inverted
  80457. * @returns the cube texture as an InternalTexture
  80458. */
  80459. 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;
  80460. /**
  80461. * Creates a new raw 3D texture
  80462. * @param data defines the data used to create the texture
  80463. * @param width defines the width of the texture
  80464. * @param height defines the height of the texture
  80465. * @param depth defines the depth of the texture
  80466. * @param format defines the format of the texture
  80467. * @param generateMipMaps defines if the engine must generate mip levels
  80468. * @param invertY defines if data must be stored with Y axis inverted
  80469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80470. * @param compression defines the compressed used (can be null)
  80471. * @param textureType defines the compressed used (can be null)
  80472. * @returns a new raw 3D texture (stored in an InternalTexture)
  80473. */
  80474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80475. /**
  80476. * Update a raw 3D texture
  80477. * @param texture defines the texture to update
  80478. * @param data defines the data to store
  80479. * @param format defines the data format
  80480. * @param invertY defines if data must be stored with Y axis inverted
  80481. */
  80482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80483. /**
  80484. * Update a raw 3D texture
  80485. * @param texture defines the texture to update
  80486. * @param data defines the data to store
  80487. * @param format defines the data format
  80488. * @param invertY defines if data must be stored with Y axis inverted
  80489. * @param compression defines the used compression (can be null)
  80490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80491. */
  80492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80493. /**
  80494. * Creates a new raw 2D array texture
  80495. * @param data defines the data used to create the texture
  80496. * @param width defines the width of the texture
  80497. * @param height defines the height of the texture
  80498. * @param depth defines the number of layers of the texture
  80499. * @param format defines the format of the texture
  80500. * @param generateMipMaps defines if the engine must generate mip levels
  80501. * @param invertY defines if data must be stored with Y axis inverted
  80502. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80503. * @param compression defines the compressed used (can be null)
  80504. * @param textureType defines the compressed used (can be null)
  80505. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80506. */
  80507. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80508. /**
  80509. * Update a raw 2D array texture
  80510. * @param texture defines the texture to update
  80511. * @param data defines the data to store
  80512. * @param format defines the data format
  80513. * @param invertY defines if data must be stored with Y axis inverted
  80514. */
  80515. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80516. /**
  80517. * Update a raw 2D array texture
  80518. * @param texture defines the texture to update
  80519. * @param data defines the data to store
  80520. * @param format defines the data format
  80521. * @param invertY defines if data must be stored with Y axis inverted
  80522. * @param compression defines the used compression (can be null)
  80523. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80524. */
  80525. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80526. }
  80527. }
  80528. declare module BABYLON {
  80529. /**
  80530. * Raw texture can help creating a texture directly from an array of data.
  80531. * This can be super useful if you either get the data from an uncompressed source or
  80532. * if you wish to create your texture pixel by pixel.
  80533. */
  80534. export class RawTexture extends Texture {
  80535. /**
  80536. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80537. */
  80538. format: number;
  80539. private _engine;
  80540. /**
  80541. * Instantiates a new RawTexture.
  80542. * Raw texture can help creating a texture directly from an array of data.
  80543. * This can be super useful if you either get the data from an uncompressed source or
  80544. * if you wish to create your texture pixel by pixel.
  80545. * @param data define the array of data to use to create the texture
  80546. * @param width define the width of the texture
  80547. * @param height define the height of the texture
  80548. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80549. * @param scene define the scene the texture belongs to
  80550. * @param generateMipMaps define whether mip maps should be generated or not
  80551. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80552. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80553. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80554. */
  80555. constructor(data: ArrayBufferView, width: number, height: number,
  80556. /**
  80557. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80558. */
  80559. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80560. /**
  80561. * Updates the texture underlying data.
  80562. * @param data Define the new data of the texture
  80563. */
  80564. update(data: ArrayBufferView): void;
  80565. /**
  80566. * Creates a luminance texture from some data.
  80567. * @param data Define the texture data
  80568. * @param width Define the width of the texture
  80569. * @param height Define the height of the texture
  80570. * @param scene Define the scene the texture belongs to
  80571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80574. * @returns the luminance texture
  80575. */
  80576. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80577. /**
  80578. * Creates a luminance alpha texture from some data.
  80579. * @param data Define the texture data
  80580. * @param width Define the width of the texture
  80581. * @param height Define the height of the texture
  80582. * @param scene Define the scene the texture belongs to
  80583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80586. * @returns the luminance alpha texture
  80587. */
  80588. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80589. /**
  80590. * Creates an alpha texture from some data.
  80591. * @param data Define the texture data
  80592. * @param width Define the width of the texture
  80593. * @param height Define the height of the texture
  80594. * @param scene Define the scene the texture belongs to
  80595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80598. * @returns the alpha texture
  80599. */
  80600. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80601. /**
  80602. * Creates a RGB texture from some data.
  80603. * @param data Define the texture data
  80604. * @param width Define the width of the texture
  80605. * @param height Define the height of the texture
  80606. * @param scene Define the scene the texture belongs to
  80607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80611. * @returns the RGB alpha texture
  80612. */
  80613. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80614. /**
  80615. * Creates a RGBA texture from some data.
  80616. * @param data Define the texture data
  80617. * @param width Define the width of the texture
  80618. * @param height Define the height of the texture
  80619. * @param scene Define the scene the texture belongs to
  80620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80623. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80624. * @returns the RGBA texture
  80625. */
  80626. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80627. /**
  80628. * Creates a R texture from some data.
  80629. * @param data Define the texture data
  80630. * @param width Define the width of the texture
  80631. * @param height Define the height of the texture
  80632. * @param scene Define the scene the texture belongs to
  80633. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80637. * @returns the R texture
  80638. */
  80639. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80640. }
  80641. }
  80642. declare module BABYLON {
  80643. /**
  80644. * Interface for the size containing width and height
  80645. */
  80646. export interface ISize {
  80647. /**
  80648. * Width
  80649. */
  80650. width: number;
  80651. /**
  80652. * Heighht
  80653. */
  80654. height: number;
  80655. }
  80656. /**
  80657. * Size containing widht and height
  80658. */
  80659. export class Size implements ISize {
  80660. /**
  80661. * Width
  80662. */
  80663. width: number;
  80664. /**
  80665. * Height
  80666. */
  80667. height: number;
  80668. /**
  80669. * Creates a Size object from the given width and height (floats).
  80670. * @param width width of the new size
  80671. * @param height height of the new size
  80672. */
  80673. constructor(width: number, height: number);
  80674. /**
  80675. * Returns a string with the Size width and height
  80676. * @returns a string with the Size width and height
  80677. */
  80678. toString(): string;
  80679. /**
  80680. * "Size"
  80681. * @returns the string "Size"
  80682. */
  80683. getClassName(): string;
  80684. /**
  80685. * Returns the Size hash code.
  80686. * @returns a hash code for a unique width and height
  80687. */
  80688. getHashCode(): number;
  80689. /**
  80690. * Updates the current size from the given one.
  80691. * @param src the given size
  80692. */
  80693. copyFrom(src: Size): void;
  80694. /**
  80695. * Updates in place the current Size from the given floats.
  80696. * @param width width of the new size
  80697. * @param height height of the new size
  80698. * @returns the updated Size.
  80699. */
  80700. copyFromFloats(width: number, height: number): Size;
  80701. /**
  80702. * Updates in place the current Size from the given floats.
  80703. * @param width width to set
  80704. * @param height height to set
  80705. * @returns the updated Size.
  80706. */
  80707. set(width: number, height: number): Size;
  80708. /**
  80709. * Multiplies the width and height by numbers
  80710. * @param w factor to multiple the width by
  80711. * @param h factor to multiple the height by
  80712. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80713. */
  80714. multiplyByFloats(w: number, h: number): Size;
  80715. /**
  80716. * Clones the size
  80717. * @returns a new Size copied from the given one.
  80718. */
  80719. clone(): Size;
  80720. /**
  80721. * True if the current Size and the given one width and height are strictly equal.
  80722. * @param other the other size to compare against
  80723. * @returns True if the current Size and the given one width and height are strictly equal.
  80724. */
  80725. equals(other: Size): boolean;
  80726. /**
  80727. * The surface of the Size : width * height (float).
  80728. */
  80729. readonly surface: number;
  80730. /**
  80731. * Create a new size of zero
  80732. * @returns a new Size set to (0.0, 0.0)
  80733. */
  80734. static Zero(): Size;
  80735. /**
  80736. * Sums the width and height of two sizes
  80737. * @param otherSize size to add to this size
  80738. * @returns a new Size set as the addition result of the current Size and the given one.
  80739. */
  80740. add(otherSize: Size): Size;
  80741. /**
  80742. * Subtracts the width and height of two
  80743. * @param otherSize size to subtract to this size
  80744. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80745. */
  80746. subtract(otherSize: Size): Size;
  80747. /**
  80748. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80749. * @param start starting size to lerp between
  80750. * @param end end size to lerp between
  80751. * @param amount amount to lerp between the start and end values
  80752. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80753. */
  80754. static Lerp(start: Size, end: Size, amount: number): Size;
  80755. }
  80756. }
  80757. declare module BABYLON {
  80758. /**
  80759. * Defines a runtime animation
  80760. */
  80761. export class RuntimeAnimation {
  80762. private _events;
  80763. /**
  80764. * The current frame of the runtime animation
  80765. */
  80766. private _currentFrame;
  80767. /**
  80768. * The animation used by the runtime animation
  80769. */
  80770. private _animation;
  80771. /**
  80772. * The target of the runtime animation
  80773. */
  80774. private _target;
  80775. /**
  80776. * The initiating animatable
  80777. */
  80778. private _host;
  80779. /**
  80780. * The original value of the runtime animation
  80781. */
  80782. private _originalValue;
  80783. /**
  80784. * The original blend value of the runtime animation
  80785. */
  80786. private _originalBlendValue;
  80787. /**
  80788. * The offsets cache of the runtime animation
  80789. */
  80790. private _offsetsCache;
  80791. /**
  80792. * The high limits cache of the runtime animation
  80793. */
  80794. private _highLimitsCache;
  80795. /**
  80796. * Specifies if the runtime animation has been stopped
  80797. */
  80798. private _stopped;
  80799. /**
  80800. * The blending factor of the runtime animation
  80801. */
  80802. private _blendingFactor;
  80803. /**
  80804. * The BabylonJS scene
  80805. */
  80806. private _scene;
  80807. /**
  80808. * The current value of the runtime animation
  80809. */
  80810. private _currentValue;
  80811. /** @hidden */
  80812. _animationState: _IAnimationState;
  80813. /**
  80814. * The active target of the runtime animation
  80815. */
  80816. private _activeTargets;
  80817. private _currentActiveTarget;
  80818. private _directTarget;
  80819. /**
  80820. * The target path of the runtime animation
  80821. */
  80822. private _targetPath;
  80823. /**
  80824. * The weight of the runtime animation
  80825. */
  80826. private _weight;
  80827. /**
  80828. * The ratio offset of the runtime animation
  80829. */
  80830. private _ratioOffset;
  80831. /**
  80832. * The previous delay of the runtime animation
  80833. */
  80834. private _previousDelay;
  80835. /**
  80836. * The previous ratio of the runtime animation
  80837. */
  80838. private _previousRatio;
  80839. private _enableBlending;
  80840. private _keys;
  80841. private _minFrame;
  80842. private _maxFrame;
  80843. private _minValue;
  80844. private _maxValue;
  80845. private _targetIsArray;
  80846. /**
  80847. * Gets the current frame of the runtime animation
  80848. */
  80849. readonly currentFrame: number;
  80850. /**
  80851. * Gets the weight of the runtime animation
  80852. */
  80853. readonly weight: number;
  80854. /**
  80855. * Gets the current value of the runtime animation
  80856. */
  80857. readonly currentValue: any;
  80858. /**
  80859. * Gets the target path of the runtime animation
  80860. */
  80861. readonly targetPath: string;
  80862. /**
  80863. * Gets the actual target of the runtime animation
  80864. */
  80865. readonly target: any;
  80866. /** @hidden */
  80867. _onLoop: () => void;
  80868. /**
  80869. * Create a new RuntimeAnimation object
  80870. * @param target defines the target of the animation
  80871. * @param animation defines the source animation object
  80872. * @param scene defines the hosting scene
  80873. * @param host defines the initiating Animatable
  80874. */
  80875. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80876. private _preparePath;
  80877. /**
  80878. * Gets the animation from the runtime animation
  80879. */
  80880. readonly animation: Animation;
  80881. /**
  80882. * Resets the runtime animation to the beginning
  80883. * @param restoreOriginal defines whether to restore the target property to the original value
  80884. */
  80885. reset(restoreOriginal?: boolean): void;
  80886. /**
  80887. * Specifies if the runtime animation is stopped
  80888. * @returns Boolean specifying if the runtime animation is stopped
  80889. */
  80890. isStopped(): boolean;
  80891. /**
  80892. * Disposes of the runtime animation
  80893. */
  80894. dispose(): void;
  80895. /**
  80896. * Apply the interpolated value to the target
  80897. * @param currentValue defines the value computed by the animation
  80898. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80899. */
  80900. setValue(currentValue: any, weight: number): void;
  80901. private _getOriginalValues;
  80902. private _setValue;
  80903. /**
  80904. * Gets the loop pmode of the runtime animation
  80905. * @returns Loop Mode
  80906. */
  80907. private _getCorrectLoopMode;
  80908. /**
  80909. * Move the current animation to a given frame
  80910. * @param frame defines the frame to move to
  80911. */
  80912. goToFrame(frame: number): void;
  80913. /**
  80914. * @hidden Internal use only
  80915. */
  80916. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80917. /**
  80918. * Execute the current animation
  80919. * @param delay defines the delay to add to the current frame
  80920. * @param from defines the lower bound of the animation range
  80921. * @param to defines the upper bound of the animation range
  80922. * @param loop defines if the current animation must loop
  80923. * @param speedRatio defines the current speed ratio
  80924. * @param weight defines the weight of the animation (default is -1 so no weight)
  80925. * @param onLoop optional callback called when animation loops
  80926. * @returns a boolean indicating if the animation is running
  80927. */
  80928. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80929. }
  80930. }
  80931. declare module BABYLON {
  80932. /**
  80933. * Class used to store an actual running animation
  80934. */
  80935. export class Animatable {
  80936. /** defines the target object */
  80937. target: any;
  80938. /** defines the starting frame number (default is 0) */
  80939. fromFrame: number;
  80940. /** defines the ending frame number (default is 100) */
  80941. toFrame: number;
  80942. /** defines if the animation must loop (default is false) */
  80943. loopAnimation: boolean;
  80944. /** defines a callback to call when animation ends if it is not looping */
  80945. onAnimationEnd?: (() => void) | null | undefined;
  80946. /** defines a callback to call when animation loops */
  80947. onAnimationLoop?: (() => void) | null | undefined;
  80948. private _localDelayOffset;
  80949. private _pausedDelay;
  80950. private _runtimeAnimations;
  80951. private _paused;
  80952. private _scene;
  80953. private _speedRatio;
  80954. private _weight;
  80955. private _syncRoot;
  80956. /**
  80957. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80958. * This will only apply for non looping animation (default is true)
  80959. */
  80960. disposeOnEnd: boolean;
  80961. /**
  80962. * Gets a boolean indicating if the animation has started
  80963. */
  80964. animationStarted: boolean;
  80965. /**
  80966. * Observer raised when the animation ends
  80967. */
  80968. onAnimationEndObservable: Observable<Animatable>;
  80969. /**
  80970. * Observer raised when the animation loops
  80971. */
  80972. onAnimationLoopObservable: Observable<Animatable>;
  80973. /**
  80974. * Gets the root Animatable used to synchronize and normalize animations
  80975. */
  80976. readonly syncRoot: Nullable<Animatable>;
  80977. /**
  80978. * Gets the current frame of the first RuntimeAnimation
  80979. * Used to synchronize Animatables
  80980. */
  80981. readonly masterFrame: number;
  80982. /**
  80983. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80984. */
  80985. weight: number;
  80986. /**
  80987. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80988. */
  80989. speedRatio: number;
  80990. /**
  80991. * Creates a new Animatable
  80992. * @param scene defines the hosting scene
  80993. * @param target defines the target object
  80994. * @param fromFrame defines the starting frame number (default is 0)
  80995. * @param toFrame defines the ending frame number (default is 100)
  80996. * @param loopAnimation defines if the animation must loop (default is false)
  80997. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80998. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80999. * @param animations defines a group of animation to add to the new Animatable
  81000. * @param onAnimationLoop defines a callback to call when animation loops
  81001. */
  81002. constructor(scene: Scene,
  81003. /** defines the target object */
  81004. target: any,
  81005. /** defines the starting frame number (default is 0) */
  81006. fromFrame?: number,
  81007. /** defines the ending frame number (default is 100) */
  81008. toFrame?: number,
  81009. /** defines if the animation must loop (default is false) */
  81010. loopAnimation?: boolean, speedRatio?: number,
  81011. /** defines a callback to call when animation ends if it is not looping */
  81012. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81013. /** defines a callback to call when animation loops */
  81014. onAnimationLoop?: (() => void) | null | undefined);
  81015. /**
  81016. * Synchronize and normalize current Animatable with a source Animatable
  81017. * This is useful when using animation weights and when animations are not of the same length
  81018. * @param root defines the root Animatable to synchronize with
  81019. * @returns the current Animatable
  81020. */
  81021. syncWith(root: Animatable): Animatable;
  81022. /**
  81023. * Gets the list of runtime animations
  81024. * @returns an array of RuntimeAnimation
  81025. */
  81026. getAnimations(): RuntimeAnimation[];
  81027. /**
  81028. * Adds more animations to the current animatable
  81029. * @param target defines the target of the animations
  81030. * @param animations defines the new animations to add
  81031. */
  81032. appendAnimations(target: any, animations: Animation[]): void;
  81033. /**
  81034. * Gets the source animation for a specific property
  81035. * @param property defines the propertyu to look for
  81036. * @returns null or the source animation for the given property
  81037. */
  81038. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81039. /**
  81040. * Gets the runtime animation for a specific property
  81041. * @param property defines the propertyu to look for
  81042. * @returns null or the runtime animation for the given property
  81043. */
  81044. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81045. /**
  81046. * Resets the animatable to its original state
  81047. */
  81048. reset(): void;
  81049. /**
  81050. * Allows the animatable to blend with current running animations
  81051. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81052. * @param blendingSpeed defines the blending speed to use
  81053. */
  81054. enableBlending(blendingSpeed: number): void;
  81055. /**
  81056. * Disable animation blending
  81057. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81058. */
  81059. disableBlending(): void;
  81060. /**
  81061. * Jump directly to a given frame
  81062. * @param frame defines the frame to jump to
  81063. */
  81064. goToFrame(frame: number): void;
  81065. /**
  81066. * Pause the animation
  81067. */
  81068. pause(): void;
  81069. /**
  81070. * Restart the animation
  81071. */
  81072. restart(): void;
  81073. private _raiseOnAnimationEnd;
  81074. /**
  81075. * Stop and delete the current animation
  81076. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81077. * @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)
  81078. */
  81079. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81080. /**
  81081. * Wait asynchronously for the animation to end
  81082. * @returns a promise which will be fullfilled when the animation ends
  81083. */
  81084. waitAsync(): Promise<Animatable>;
  81085. /** @hidden */
  81086. _animate(delay: number): boolean;
  81087. }
  81088. interface Scene {
  81089. /** @hidden */
  81090. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81091. /** @hidden */
  81092. _processLateAnimationBindingsForMatrices(holder: {
  81093. totalWeight: number;
  81094. animations: RuntimeAnimation[];
  81095. originalValue: Matrix;
  81096. }): any;
  81097. /** @hidden */
  81098. _processLateAnimationBindingsForQuaternions(holder: {
  81099. totalWeight: number;
  81100. animations: RuntimeAnimation[];
  81101. originalValue: Quaternion;
  81102. }, refQuaternion: Quaternion): Quaternion;
  81103. /** @hidden */
  81104. _processLateAnimationBindings(): void;
  81105. /**
  81106. * Will start the animation sequence of a given target
  81107. * @param target defines the target
  81108. * @param from defines from which frame should animation start
  81109. * @param to defines until which frame should animation run.
  81110. * @param weight defines the weight to apply to the animation (1.0 by default)
  81111. * @param loop defines if the animation loops
  81112. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81113. * @param onAnimationEnd defines the function to be executed when the animation ends
  81114. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81115. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81116. * @param onAnimationLoop defines the callback to call when an animation loops
  81117. * @returns the animatable object created for this animation
  81118. */
  81119. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81120. /**
  81121. * Will start the animation sequence of a given target
  81122. * @param target defines the target
  81123. * @param from defines from which frame should animation start
  81124. * @param to defines until which frame should animation run.
  81125. * @param loop defines if the animation loops
  81126. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81127. * @param onAnimationEnd defines the function to be executed when the animation ends
  81128. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81129. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81130. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81131. * @param onAnimationLoop defines the callback to call when an animation loops
  81132. * @returns the animatable object created for this animation
  81133. */
  81134. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81135. /**
  81136. * Will start the animation sequence of a given target and its hierarchy
  81137. * @param target defines the target
  81138. * @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.
  81139. * @param from defines from which frame should animation start
  81140. * @param to defines until which frame should animation run.
  81141. * @param loop defines if the animation loops
  81142. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81143. * @param onAnimationEnd defines the function to be executed when the animation ends
  81144. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81145. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81146. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81147. * @param onAnimationLoop defines the callback to call when an animation loops
  81148. * @returns the list of created animatables
  81149. */
  81150. 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[];
  81151. /**
  81152. * Begin a new animation on a given node
  81153. * @param target defines the target where the animation will take place
  81154. * @param animations defines the list of animations to start
  81155. * @param from defines the initial value
  81156. * @param to defines the final value
  81157. * @param loop defines if you want animation to loop (off by default)
  81158. * @param speedRatio defines the speed ratio to apply to all animations
  81159. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81160. * @param onAnimationLoop defines the callback to call when an animation loops
  81161. * @returns the list of created animatables
  81162. */
  81163. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81164. /**
  81165. * Begin a new animation on a given node and its hierarchy
  81166. * @param target defines the root node where the animation will take place
  81167. * @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.
  81168. * @param animations defines the list of animations to start
  81169. * @param from defines the initial value
  81170. * @param to defines the final value
  81171. * @param loop defines if you want animation to loop (off by default)
  81172. * @param speedRatio defines the speed ratio to apply to all animations
  81173. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81174. * @param onAnimationLoop defines the callback to call when an animation loops
  81175. * @returns the list of animatables created for all nodes
  81176. */
  81177. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81178. /**
  81179. * Gets the animatable associated with a specific target
  81180. * @param target defines the target of the animatable
  81181. * @returns the required animatable if found
  81182. */
  81183. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81184. /**
  81185. * Gets all animatables associated with a given target
  81186. * @param target defines the target to look animatables for
  81187. * @returns an array of Animatables
  81188. */
  81189. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81190. /**
  81191. * Stops and removes all animations that have been applied to the scene
  81192. */
  81193. stopAllAnimations(): void;
  81194. /**
  81195. * Gets the current delta time used by animation engine
  81196. */
  81197. deltaTime: number;
  81198. }
  81199. interface Bone {
  81200. /**
  81201. * Copy an animation range from another bone
  81202. * @param source defines the source bone
  81203. * @param rangeName defines the range name to copy
  81204. * @param frameOffset defines the frame offset
  81205. * @param rescaleAsRequired defines if rescaling must be applied if required
  81206. * @param skelDimensionsRatio defines the scaling ratio
  81207. * @returns true if operation was successful
  81208. */
  81209. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81210. }
  81211. }
  81212. declare module BABYLON {
  81213. /**
  81214. * Class used to override all child animations of a given target
  81215. */
  81216. export class AnimationPropertiesOverride {
  81217. /**
  81218. * Gets or sets a value indicating if animation blending must be used
  81219. */
  81220. enableBlending: boolean;
  81221. /**
  81222. * Gets or sets the blending speed to use when enableBlending is true
  81223. */
  81224. blendingSpeed: number;
  81225. /**
  81226. * Gets or sets the default loop mode to use
  81227. */
  81228. loopMode: number;
  81229. }
  81230. }
  81231. declare module BABYLON {
  81232. /**
  81233. * Class used to handle skinning animations
  81234. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81235. */
  81236. export class Skeleton implements IAnimatable {
  81237. /** defines the skeleton name */
  81238. name: string;
  81239. /** defines the skeleton Id */
  81240. id: string;
  81241. /**
  81242. * Defines the list of child bones
  81243. */
  81244. bones: Bone[];
  81245. /**
  81246. * Defines an estimate of the dimension of the skeleton at rest
  81247. */
  81248. dimensionsAtRest: Vector3;
  81249. /**
  81250. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81251. */
  81252. needInitialSkinMatrix: boolean;
  81253. /**
  81254. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81255. */
  81256. overrideMesh: Nullable<AbstractMesh>;
  81257. /**
  81258. * Gets the list of animations attached to this skeleton
  81259. */
  81260. animations: Array<Animation>;
  81261. private _scene;
  81262. private _isDirty;
  81263. private _transformMatrices;
  81264. private _transformMatrixTexture;
  81265. private _meshesWithPoseMatrix;
  81266. private _animatables;
  81267. private _identity;
  81268. private _synchronizedWithMesh;
  81269. private _ranges;
  81270. private _lastAbsoluteTransformsUpdateId;
  81271. private _canUseTextureForBones;
  81272. private _uniqueId;
  81273. /** @hidden */
  81274. _numBonesWithLinkedTransformNode: number;
  81275. /** @hidden */
  81276. _hasWaitingData: Nullable<boolean>;
  81277. /**
  81278. * Specifies if the skeleton should be serialized
  81279. */
  81280. doNotSerialize: boolean;
  81281. private _useTextureToStoreBoneMatrices;
  81282. /**
  81283. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81284. * Please note that this option is not available if the hardware does not support it
  81285. */
  81286. useTextureToStoreBoneMatrices: boolean;
  81287. private _animationPropertiesOverride;
  81288. /**
  81289. * Gets or sets the animation properties override
  81290. */
  81291. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81292. /**
  81293. * List of inspectable custom properties (used by the Inspector)
  81294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81295. */
  81296. inspectableCustomProperties: IInspectable[];
  81297. /**
  81298. * An observable triggered before computing the skeleton's matrices
  81299. */
  81300. onBeforeComputeObservable: Observable<Skeleton>;
  81301. /**
  81302. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81303. */
  81304. readonly isUsingTextureForMatrices: boolean;
  81305. /**
  81306. * Gets the unique ID of this skeleton
  81307. */
  81308. readonly uniqueId: number;
  81309. /**
  81310. * Creates a new skeleton
  81311. * @param name defines the skeleton name
  81312. * @param id defines the skeleton Id
  81313. * @param scene defines the hosting scene
  81314. */
  81315. constructor(
  81316. /** defines the skeleton name */
  81317. name: string,
  81318. /** defines the skeleton Id */
  81319. id: string, scene: Scene);
  81320. /**
  81321. * Gets the current object class name.
  81322. * @return the class name
  81323. */
  81324. getClassName(): string;
  81325. /**
  81326. * Returns an array containing the root bones
  81327. * @returns an array containing the root bones
  81328. */
  81329. getChildren(): Array<Bone>;
  81330. /**
  81331. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81332. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81333. * @returns a Float32Array containing matrices data
  81334. */
  81335. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81336. /**
  81337. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81338. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81339. * @returns a raw texture containing the data
  81340. */
  81341. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81342. /**
  81343. * Gets the current hosting scene
  81344. * @returns a scene object
  81345. */
  81346. getScene(): Scene;
  81347. /**
  81348. * Gets a string representing the current skeleton data
  81349. * @param fullDetails defines a boolean indicating if we want a verbose version
  81350. * @returns a string representing the current skeleton data
  81351. */
  81352. toString(fullDetails?: boolean): string;
  81353. /**
  81354. * Get bone's index searching by name
  81355. * @param name defines bone's name to search for
  81356. * @return the indice of the bone. Returns -1 if not found
  81357. */
  81358. getBoneIndexByName(name: string): number;
  81359. /**
  81360. * Creater a new animation range
  81361. * @param name defines the name of the range
  81362. * @param from defines the start key
  81363. * @param to defines the end key
  81364. */
  81365. createAnimationRange(name: string, from: number, to: number): void;
  81366. /**
  81367. * Delete a specific animation range
  81368. * @param name defines the name of the range
  81369. * @param deleteFrames defines if frames must be removed as well
  81370. */
  81371. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81372. /**
  81373. * Gets a specific animation range
  81374. * @param name defines the name of the range to look for
  81375. * @returns the requested animation range or null if not found
  81376. */
  81377. getAnimationRange(name: string): Nullable<AnimationRange>;
  81378. /**
  81379. * Gets the list of all animation ranges defined on this skeleton
  81380. * @returns an array
  81381. */
  81382. getAnimationRanges(): Nullable<AnimationRange>[];
  81383. /**
  81384. * Copy animation range from a source skeleton.
  81385. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81386. * @param source defines the source skeleton
  81387. * @param name defines the name of the range to copy
  81388. * @param rescaleAsRequired defines if rescaling must be applied if required
  81389. * @returns true if operation was successful
  81390. */
  81391. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81392. /**
  81393. * Forces the skeleton to go to rest pose
  81394. */
  81395. returnToRest(): void;
  81396. private _getHighestAnimationFrame;
  81397. /**
  81398. * Begin a specific animation range
  81399. * @param name defines the name of the range to start
  81400. * @param loop defines if looping must be turned on (false by default)
  81401. * @param speedRatio defines the speed ratio to apply (1 by default)
  81402. * @param onAnimationEnd defines a callback which will be called when animation will end
  81403. * @returns a new animatable
  81404. */
  81405. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81406. /** @hidden */
  81407. _markAsDirty(): void;
  81408. /** @hidden */
  81409. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81410. /** @hidden */
  81411. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81412. private _computeTransformMatrices;
  81413. /**
  81414. * Build all resources required to render a skeleton
  81415. */
  81416. prepare(): void;
  81417. /**
  81418. * Gets the list of animatables currently running for this skeleton
  81419. * @returns an array of animatables
  81420. */
  81421. getAnimatables(): IAnimatable[];
  81422. /**
  81423. * Clone the current skeleton
  81424. * @param name defines the name of the new skeleton
  81425. * @param id defines the id of the new skeleton
  81426. * @returns the new skeleton
  81427. */
  81428. clone(name: string, id?: string): Skeleton;
  81429. /**
  81430. * Enable animation blending for this skeleton
  81431. * @param blendingSpeed defines the blending speed to apply
  81432. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81433. */
  81434. enableBlending(blendingSpeed?: number): void;
  81435. /**
  81436. * Releases all resources associated with the current skeleton
  81437. */
  81438. dispose(): void;
  81439. /**
  81440. * Serialize the skeleton in a JSON object
  81441. * @returns a JSON object
  81442. */
  81443. serialize(): any;
  81444. /**
  81445. * Creates a new skeleton from serialized data
  81446. * @param parsedSkeleton defines the serialized data
  81447. * @param scene defines the hosting scene
  81448. * @returns a new skeleton
  81449. */
  81450. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81451. /**
  81452. * Compute all node absolute transforms
  81453. * @param forceUpdate defines if computation must be done even if cache is up to date
  81454. */
  81455. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81456. /**
  81457. * Gets the root pose matrix
  81458. * @returns a matrix
  81459. */
  81460. getPoseMatrix(): Nullable<Matrix>;
  81461. /**
  81462. * Sorts bones per internal index
  81463. */
  81464. sortBones(): void;
  81465. private _sortBones;
  81466. }
  81467. }
  81468. declare module BABYLON {
  81469. /**
  81470. * Class used to store bone information
  81471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81472. */
  81473. export class Bone extends Node {
  81474. /**
  81475. * defines the bone name
  81476. */
  81477. name: string;
  81478. private static _tmpVecs;
  81479. private static _tmpQuat;
  81480. private static _tmpMats;
  81481. /**
  81482. * Gets the list of child bones
  81483. */
  81484. children: Bone[];
  81485. /** Gets the animations associated with this bone */
  81486. animations: Animation[];
  81487. /**
  81488. * Gets or sets bone length
  81489. */
  81490. length: number;
  81491. /**
  81492. * @hidden Internal only
  81493. * Set this value to map this bone to a different index in the transform matrices
  81494. * Set this value to -1 to exclude the bone from the transform matrices
  81495. */
  81496. _index: Nullable<number>;
  81497. private _skeleton;
  81498. private _localMatrix;
  81499. private _restPose;
  81500. private _baseMatrix;
  81501. private _absoluteTransform;
  81502. private _invertedAbsoluteTransform;
  81503. private _parent;
  81504. private _scalingDeterminant;
  81505. private _worldTransform;
  81506. private _localScaling;
  81507. private _localRotation;
  81508. private _localPosition;
  81509. private _needToDecompose;
  81510. private _needToCompose;
  81511. /** @hidden */
  81512. _linkedTransformNode: Nullable<TransformNode>;
  81513. /** @hidden */
  81514. _waitingTransformNodeId: Nullable<string>;
  81515. /** @hidden */
  81516. /** @hidden */
  81517. _matrix: Matrix;
  81518. /**
  81519. * Create a new bone
  81520. * @param name defines the bone name
  81521. * @param skeleton defines the parent skeleton
  81522. * @param parentBone defines the parent (can be null if the bone is the root)
  81523. * @param localMatrix defines the local matrix
  81524. * @param restPose defines the rest pose matrix
  81525. * @param baseMatrix defines the base matrix
  81526. * @param index defines index of the bone in the hiearchy
  81527. */
  81528. constructor(
  81529. /**
  81530. * defines the bone name
  81531. */
  81532. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81533. /**
  81534. * Gets the current object class name.
  81535. * @return the class name
  81536. */
  81537. getClassName(): string;
  81538. /**
  81539. * Gets the parent skeleton
  81540. * @returns a skeleton
  81541. */
  81542. getSkeleton(): Skeleton;
  81543. /**
  81544. * Gets parent bone
  81545. * @returns a bone or null if the bone is the root of the bone hierarchy
  81546. */
  81547. getParent(): Nullable<Bone>;
  81548. /**
  81549. * Returns an array containing the root bones
  81550. * @returns an array containing the root bones
  81551. */
  81552. getChildren(): Array<Bone>;
  81553. /**
  81554. * Gets the node index in matrix array generated for rendering
  81555. * @returns the node index
  81556. */
  81557. getIndex(): number;
  81558. /**
  81559. * Sets the parent bone
  81560. * @param parent defines the parent (can be null if the bone is the root)
  81561. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81562. */
  81563. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81564. /**
  81565. * Gets the local matrix
  81566. * @returns a matrix
  81567. */
  81568. getLocalMatrix(): Matrix;
  81569. /**
  81570. * Gets the base matrix (initial matrix which remains unchanged)
  81571. * @returns a matrix
  81572. */
  81573. getBaseMatrix(): Matrix;
  81574. /**
  81575. * Gets the rest pose matrix
  81576. * @returns a matrix
  81577. */
  81578. getRestPose(): Matrix;
  81579. /**
  81580. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81581. */
  81582. getWorldMatrix(): Matrix;
  81583. /**
  81584. * Sets the local matrix to rest pose matrix
  81585. */
  81586. returnToRest(): void;
  81587. /**
  81588. * Gets the inverse of the absolute transform matrix.
  81589. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81590. * @returns a matrix
  81591. */
  81592. getInvertedAbsoluteTransform(): Matrix;
  81593. /**
  81594. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81595. * @returns a matrix
  81596. */
  81597. getAbsoluteTransform(): Matrix;
  81598. /**
  81599. * Links with the given transform node.
  81600. * The local matrix of this bone is copied from the transform node every frame.
  81601. * @param transformNode defines the transform node to link to
  81602. */
  81603. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81604. /**
  81605. * Gets the node used to drive the bone's transformation
  81606. * @returns a transform node or null
  81607. */
  81608. getTransformNode(): Nullable<TransformNode>;
  81609. /** Gets or sets current position (in local space) */
  81610. position: Vector3;
  81611. /** Gets or sets current rotation (in local space) */
  81612. rotation: Vector3;
  81613. /** Gets or sets current rotation quaternion (in local space) */
  81614. rotationQuaternion: Quaternion;
  81615. /** Gets or sets current scaling (in local space) */
  81616. scaling: Vector3;
  81617. /**
  81618. * Gets the animation properties override
  81619. */
  81620. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81621. private _decompose;
  81622. private _compose;
  81623. /**
  81624. * Update the base and local matrices
  81625. * @param matrix defines the new base or local matrix
  81626. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81627. * @param updateLocalMatrix defines if the local matrix should be updated
  81628. */
  81629. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81630. /** @hidden */
  81631. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81632. /**
  81633. * Flag the bone as dirty (Forcing it to update everything)
  81634. */
  81635. markAsDirty(): void;
  81636. /** @hidden */
  81637. _markAsDirtyAndCompose(): void;
  81638. private _markAsDirtyAndDecompose;
  81639. /**
  81640. * Translate the bone in local or world space
  81641. * @param vec The amount to translate the bone
  81642. * @param space The space that the translation is in
  81643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81644. */
  81645. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81646. /**
  81647. * Set the postion of the bone in local or world space
  81648. * @param position The position to set the bone
  81649. * @param space The space that the position is in
  81650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81651. */
  81652. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81653. /**
  81654. * Set the absolute position of the bone (world space)
  81655. * @param position The position to set the bone
  81656. * @param mesh The mesh that this bone is attached to
  81657. */
  81658. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81659. /**
  81660. * Scale the bone on the x, y and z axes (in local space)
  81661. * @param x The amount to scale the bone on the x axis
  81662. * @param y The amount to scale the bone on the y axis
  81663. * @param z The amount to scale the bone on the z axis
  81664. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81665. */
  81666. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81667. /**
  81668. * Set the bone scaling in local space
  81669. * @param scale defines the scaling vector
  81670. */
  81671. setScale(scale: Vector3): void;
  81672. /**
  81673. * Gets the current scaling in local space
  81674. * @returns the current scaling vector
  81675. */
  81676. getScale(): Vector3;
  81677. /**
  81678. * Gets the current scaling in local space and stores it in a target vector
  81679. * @param result defines the target vector
  81680. */
  81681. getScaleToRef(result: Vector3): void;
  81682. /**
  81683. * Set the yaw, pitch, and roll of the bone in local or world space
  81684. * @param yaw The rotation of the bone on the y axis
  81685. * @param pitch The rotation of the bone on the x axis
  81686. * @param roll The rotation of the bone on the z axis
  81687. * @param space The space that the axes of rotation are in
  81688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81689. */
  81690. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81691. /**
  81692. * Add a rotation to the bone on an axis in local or world space
  81693. * @param axis The axis to rotate the bone on
  81694. * @param amount The amount to rotate the bone
  81695. * @param space The space that the axis is in
  81696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81697. */
  81698. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81699. /**
  81700. * Set the rotation of the bone to a particular axis angle in local or world space
  81701. * @param axis The axis to rotate the bone on
  81702. * @param angle The angle that the bone should be rotated to
  81703. * @param space The space that the axis is in
  81704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81705. */
  81706. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81707. /**
  81708. * Set the euler rotation of the bone in local of world space
  81709. * @param rotation The euler rotation that the bone should be set to
  81710. * @param space The space that the rotation is in
  81711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81712. */
  81713. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81714. /**
  81715. * Set the quaternion rotation of the bone in local of world space
  81716. * @param quat The quaternion rotation that the bone should be set to
  81717. * @param space The space that the rotation is in
  81718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81719. */
  81720. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81721. /**
  81722. * Set the rotation matrix of the bone in local of world space
  81723. * @param rotMat The rotation matrix that the bone should be set to
  81724. * @param space The space that the rotation is in
  81725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81726. */
  81727. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81728. private _rotateWithMatrix;
  81729. private _getNegativeRotationToRef;
  81730. /**
  81731. * Get the position of the bone in local or world space
  81732. * @param space The space that the returned position is in
  81733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81734. * @returns The position of the bone
  81735. */
  81736. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81737. /**
  81738. * Copy the position of the bone to a vector3 in local or world space
  81739. * @param space The space that the returned position is in
  81740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81741. * @param result The vector3 to copy the position to
  81742. */
  81743. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81744. /**
  81745. * Get the absolute position of the bone (world space)
  81746. * @param mesh The mesh that this bone is attached to
  81747. * @returns The absolute position of the bone
  81748. */
  81749. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81750. /**
  81751. * Copy the absolute position of the bone (world space) to the result param
  81752. * @param mesh The mesh that this bone is attached to
  81753. * @param result The vector3 to copy the absolute position to
  81754. */
  81755. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81756. /**
  81757. * Compute the absolute transforms of this bone and its children
  81758. */
  81759. computeAbsoluteTransforms(): void;
  81760. /**
  81761. * Get the world direction from an axis that is in the local space of the bone
  81762. * @param localAxis The local direction that is used to compute the world direction
  81763. * @param mesh The mesh that this bone is attached to
  81764. * @returns The world direction
  81765. */
  81766. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81767. /**
  81768. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81769. * @param localAxis The local direction that is used to compute the world direction
  81770. * @param mesh The mesh that this bone is attached to
  81771. * @param result The vector3 that the world direction will be copied to
  81772. */
  81773. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81774. /**
  81775. * Get the euler rotation of the bone in local or world space
  81776. * @param space The space that the rotation should be in
  81777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81778. * @returns The euler rotation
  81779. */
  81780. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81781. /**
  81782. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81783. * @param space The space that the rotation should be in
  81784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81785. * @param result The vector3 that the rotation should be copied to
  81786. */
  81787. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81788. /**
  81789. * Get the quaternion rotation of the bone in either local or world space
  81790. * @param space The space that the rotation should be in
  81791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81792. * @returns The quaternion rotation
  81793. */
  81794. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81795. /**
  81796. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81797. * @param space The space that the rotation should be in
  81798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81799. * @param result The quaternion that the rotation should be copied to
  81800. */
  81801. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81802. /**
  81803. * Get the rotation matrix of the bone in local or world space
  81804. * @param space The space that the rotation should be in
  81805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81806. * @returns The rotation matrix
  81807. */
  81808. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81809. /**
  81810. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81811. * @param space The space that the rotation should be in
  81812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81813. * @param result The quaternion that the rotation should be copied to
  81814. */
  81815. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81816. /**
  81817. * Get the world position of a point that is in the local space of the bone
  81818. * @param position The local position
  81819. * @param mesh The mesh that this bone is attached to
  81820. * @returns The world position
  81821. */
  81822. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81823. /**
  81824. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81825. * @param position The local position
  81826. * @param mesh The mesh that this bone is attached to
  81827. * @param result The vector3 that the world position should be copied to
  81828. */
  81829. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81830. /**
  81831. * Get the local position of a point that is in world space
  81832. * @param position The world position
  81833. * @param mesh The mesh that this bone is attached to
  81834. * @returns The local position
  81835. */
  81836. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81837. /**
  81838. * Get the local position of a point that is in world space and copy it to the result param
  81839. * @param position The world position
  81840. * @param mesh The mesh that this bone is attached to
  81841. * @param result The vector3 that the local position should be copied to
  81842. */
  81843. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81844. }
  81845. }
  81846. declare module BABYLON {
  81847. /**
  81848. * 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.
  81849. * @see https://doc.babylonjs.com/how_to/transformnode
  81850. */
  81851. export class TransformNode extends Node {
  81852. /**
  81853. * Object will not rotate to face the camera
  81854. */
  81855. static BILLBOARDMODE_NONE: number;
  81856. /**
  81857. * Object will rotate to face the camera but only on the x axis
  81858. */
  81859. static BILLBOARDMODE_X: number;
  81860. /**
  81861. * Object will rotate to face the camera but only on the y axis
  81862. */
  81863. static BILLBOARDMODE_Y: number;
  81864. /**
  81865. * Object will rotate to face the camera but only on the z axis
  81866. */
  81867. static BILLBOARDMODE_Z: number;
  81868. /**
  81869. * Object will rotate to face the camera
  81870. */
  81871. static BILLBOARDMODE_ALL: number;
  81872. /**
  81873. * Object will rotate to face the camera's position instead of orientation
  81874. */
  81875. static BILLBOARDMODE_USE_POSITION: number;
  81876. private _forward;
  81877. private _forwardInverted;
  81878. private _up;
  81879. private _right;
  81880. private _rightInverted;
  81881. private _position;
  81882. private _rotation;
  81883. private _rotationQuaternion;
  81884. protected _scaling: Vector3;
  81885. protected _isDirty: boolean;
  81886. private _transformToBoneReferal;
  81887. private _isAbsoluteSynced;
  81888. private _billboardMode;
  81889. /**
  81890. * Gets or sets the billboard mode. Default is 0.
  81891. *
  81892. * | Value | Type | Description |
  81893. * | --- | --- | --- |
  81894. * | 0 | BILLBOARDMODE_NONE | |
  81895. * | 1 | BILLBOARDMODE_X | |
  81896. * | 2 | BILLBOARDMODE_Y | |
  81897. * | 4 | BILLBOARDMODE_Z | |
  81898. * | 7 | BILLBOARDMODE_ALL | |
  81899. *
  81900. */
  81901. billboardMode: number;
  81902. private _preserveParentRotationForBillboard;
  81903. /**
  81904. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81905. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81906. */
  81907. preserveParentRotationForBillboard: boolean;
  81908. /**
  81909. * 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
  81910. */
  81911. scalingDeterminant: number;
  81912. private _infiniteDistance;
  81913. /**
  81914. * Gets or sets the distance of the object to max, often used by skybox
  81915. */
  81916. infiniteDistance: boolean;
  81917. /**
  81918. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81919. * By default the system will update normals to compensate
  81920. */
  81921. ignoreNonUniformScaling: boolean;
  81922. /**
  81923. * 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
  81924. */
  81925. reIntegrateRotationIntoRotationQuaternion: boolean;
  81926. /** @hidden */
  81927. _poseMatrix: Nullable<Matrix>;
  81928. /** @hidden */
  81929. _localMatrix: Matrix;
  81930. private _usePivotMatrix;
  81931. private _absolutePosition;
  81932. private _absoluteScaling;
  81933. private _absoluteRotationQuaternion;
  81934. private _pivotMatrix;
  81935. private _pivotMatrixInverse;
  81936. protected _postMultiplyPivotMatrix: boolean;
  81937. protected _isWorldMatrixFrozen: boolean;
  81938. /** @hidden */
  81939. _indexInSceneTransformNodesArray: number;
  81940. /**
  81941. * An event triggered after the world matrix is updated
  81942. */
  81943. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81944. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81945. /**
  81946. * Gets a string identifying the name of the class
  81947. * @returns "TransformNode" string
  81948. */
  81949. getClassName(): string;
  81950. /**
  81951. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81952. */
  81953. position: Vector3;
  81954. /**
  81955. * 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)).
  81956. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81957. */
  81958. rotation: Vector3;
  81959. /**
  81960. * 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)).
  81961. */
  81962. scaling: Vector3;
  81963. /**
  81964. * 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).
  81965. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81966. */
  81967. rotationQuaternion: Nullable<Quaternion>;
  81968. /**
  81969. * The forward direction of that transform in world space.
  81970. */
  81971. readonly forward: Vector3;
  81972. /**
  81973. * The up direction of that transform in world space.
  81974. */
  81975. readonly up: Vector3;
  81976. /**
  81977. * The right direction of that transform in world space.
  81978. */
  81979. readonly right: Vector3;
  81980. /**
  81981. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81982. * @param matrix the matrix to copy the pose from
  81983. * @returns this TransformNode.
  81984. */
  81985. updatePoseMatrix(matrix: Matrix): TransformNode;
  81986. /**
  81987. * Returns the mesh Pose matrix.
  81988. * @returns the pose matrix
  81989. */
  81990. getPoseMatrix(): Matrix;
  81991. /** @hidden */
  81992. _isSynchronized(): boolean;
  81993. /** @hidden */
  81994. _initCache(): void;
  81995. /**
  81996. * Flag the transform node as dirty (Forcing it to update everything)
  81997. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81998. * @returns this transform node
  81999. */
  82000. markAsDirty(property: string): TransformNode;
  82001. /**
  82002. * Returns the current mesh absolute position.
  82003. * Returns a Vector3.
  82004. */
  82005. readonly absolutePosition: Vector3;
  82006. /**
  82007. * Returns the current mesh absolute scaling.
  82008. * Returns a Vector3.
  82009. */
  82010. readonly absoluteScaling: Vector3;
  82011. /**
  82012. * Returns the current mesh absolute rotation.
  82013. * Returns a Quaternion.
  82014. */
  82015. readonly absoluteRotationQuaternion: Quaternion;
  82016. /**
  82017. * Sets a new matrix to apply before all other transformation
  82018. * @param matrix defines the transform matrix
  82019. * @returns the current TransformNode
  82020. */
  82021. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82022. /**
  82023. * Sets a new pivot matrix to the current node
  82024. * @param matrix defines the new pivot matrix to use
  82025. * @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
  82026. * @returns the current TransformNode
  82027. */
  82028. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82029. /**
  82030. * Returns the mesh pivot matrix.
  82031. * Default : Identity.
  82032. * @returns the matrix
  82033. */
  82034. getPivotMatrix(): Matrix;
  82035. /**
  82036. * Instantiate (when possible) or clone that node with its hierarchy
  82037. * @param newParent defines the new parent to use for the instance (or clone)
  82038. * @param options defines options to configure how copy is done
  82039. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82040. * @returns an instance (or a clone) of the current node with its hiearchy
  82041. */
  82042. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82043. doNotInstantiate: boolean;
  82044. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82045. /**
  82046. * Prevents the World matrix to be computed any longer
  82047. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82048. * @returns the TransformNode.
  82049. */
  82050. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82051. /**
  82052. * Allows back the World matrix computation.
  82053. * @returns the TransformNode.
  82054. */
  82055. unfreezeWorldMatrix(): this;
  82056. /**
  82057. * True if the World matrix has been frozen.
  82058. */
  82059. readonly isWorldMatrixFrozen: boolean;
  82060. /**
  82061. * Retuns the mesh absolute position in the World.
  82062. * @returns a Vector3.
  82063. */
  82064. getAbsolutePosition(): Vector3;
  82065. /**
  82066. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82067. * @param absolutePosition the absolute position to set
  82068. * @returns the TransformNode.
  82069. */
  82070. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82071. /**
  82072. * Sets the mesh position in its local space.
  82073. * @param vector3 the position to set in localspace
  82074. * @returns the TransformNode.
  82075. */
  82076. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82077. /**
  82078. * Returns the mesh position in the local space from the current World matrix values.
  82079. * @returns a new Vector3.
  82080. */
  82081. getPositionExpressedInLocalSpace(): Vector3;
  82082. /**
  82083. * Translates the mesh along the passed Vector3 in its local space.
  82084. * @param vector3 the distance to translate in localspace
  82085. * @returns the TransformNode.
  82086. */
  82087. locallyTranslate(vector3: Vector3): TransformNode;
  82088. private static _lookAtVectorCache;
  82089. /**
  82090. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82091. * @param targetPoint the position (must be in same space as current mesh) to look at
  82092. * @param yawCor optional yaw (y-axis) correction in radians
  82093. * @param pitchCor optional pitch (x-axis) correction in radians
  82094. * @param rollCor optional roll (z-axis) correction in radians
  82095. * @param space the choosen space of the target
  82096. * @returns the TransformNode.
  82097. */
  82098. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82099. /**
  82100. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82101. * This Vector3 is expressed in the World space.
  82102. * @param localAxis axis to rotate
  82103. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82104. */
  82105. getDirection(localAxis: Vector3): Vector3;
  82106. /**
  82107. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82108. * localAxis is expressed in the mesh local space.
  82109. * result is computed in the Wordl space from the mesh World matrix.
  82110. * @param localAxis axis to rotate
  82111. * @param result the resulting transformnode
  82112. * @returns this TransformNode.
  82113. */
  82114. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82115. /**
  82116. * Sets this transform node rotation to the given local axis.
  82117. * @param localAxis the axis in local space
  82118. * @param yawCor optional yaw (y-axis) correction in radians
  82119. * @param pitchCor optional pitch (x-axis) correction in radians
  82120. * @param rollCor optional roll (z-axis) correction in radians
  82121. * @returns this TransformNode
  82122. */
  82123. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82124. /**
  82125. * Sets a new pivot point to the current node
  82126. * @param point defines the new pivot point to use
  82127. * @param space defines if the point is in world or local space (local by default)
  82128. * @returns the current TransformNode
  82129. */
  82130. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82131. /**
  82132. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82133. * @returns the pivot point
  82134. */
  82135. getPivotPoint(): Vector3;
  82136. /**
  82137. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82138. * @param result the vector3 to store the result
  82139. * @returns this TransformNode.
  82140. */
  82141. getPivotPointToRef(result: Vector3): TransformNode;
  82142. /**
  82143. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82144. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82145. */
  82146. getAbsolutePivotPoint(): Vector3;
  82147. /**
  82148. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82149. * @param result vector3 to store the result
  82150. * @returns this TransformNode.
  82151. */
  82152. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82153. /**
  82154. * Defines the passed node as the parent of the current node.
  82155. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82156. * @see https://doc.babylonjs.com/how_to/parenting
  82157. * @param node the node ot set as the parent
  82158. * @returns this TransformNode.
  82159. */
  82160. setParent(node: Nullable<Node>): TransformNode;
  82161. private _nonUniformScaling;
  82162. /**
  82163. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82164. */
  82165. readonly nonUniformScaling: boolean;
  82166. /** @hidden */
  82167. _updateNonUniformScalingState(value: boolean): boolean;
  82168. /**
  82169. * Attach the current TransformNode to another TransformNode associated with a bone
  82170. * @param bone Bone affecting the TransformNode
  82171. * @param affectedTransformNode TransformNode associated with the bone
  82172. * @returns this object
  82173. */
  82174. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82175. /**
  82176. * Detach the transform node if its associated with a bone
  82177. * @returns this object
  82178. */
  82179. detachFromBone(): TransformNode;
  82180. private static _rotationAxisCache;
  82181. /**
  82182. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82183. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82184. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82185. * The passed axis is also normalized.
  82186. * @param axis the axis to rotate around
  82187. * @param amount the amount to rotate in radians
  82188. * @param space Space to rotate in (Default: local)
  82189. * @returns the TransformNode.
  82190. */
  82191. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82192. /**
  82193. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82194. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82195. * The passed axis is also normalized. .
  82196. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82197. * @param point the point to rotate around
  82198. * @param axis the axis to rotate around
  82199. * @param amount the amount to rotate in radians
  82200. * @returns the TransformNode
  82201. */
  82202. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82203. /**
  82204. * Translates the mesh along the axis vector for the passed distance in the given space.
  82205. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82206. * @param axis the axis to translate in
  82207. * @param distance the distance to translate
  82208. * @param space Space to rotate in (Default: local)
  82209. * @returns the TransformNode.
  82210. */
  82211. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82212. /**
  82213. * Adds a rotation step to the mesh current rotation.
  82214. * x, y, z are Euler angles expressed in radians.
  82215. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82216. * This means this rotation is made in the mesh local space only.
  82217. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82218. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82219. * ```javascript
  82220. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82221. * ```
  82222. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82223. * 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.
  82224. * @param x Rotation to add
  82225. * @param y Rotation to add
  82226. * @param z Rotation to add
  82227. * @returns the TransformNode.
  82228. */
  82229. addRotation(x: number, y: number, z: number): TransformNode;
  82230. /**
  82231. * @hidden
  82232. */
  82233. protected _getEffectiveParent(): Nullable<Node>;
  82234. /**
  82235. * Computes the world matrix of the node
  82236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82237. * @returns the world matrix
  82238. */
  82239. computeWorldMatrix(force?: boolean): Matrix;
  82240. protected _afterComputeWorldMatrix(): void;
  82241. /**
  82242. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82243. * @param func callback function to add
  82244. *
  82245. * @returns the TransformNode.
  82246. */
  82247. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82248. /**
  82249. * Removes a registered callback function.
  82250. * @param func callback function to remove
  82251. * @returns the TransformNode.
  82252. */
  82253. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82254. /**
  82255. * Gets the position of the current mesh in camera space
  82256. * @param camera defines the camera to use
  82257. * @returns a position
  82258. */
  82259. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82260. /**
  82261. * Returns the distance from the mesh to the active camera
  82262. * @param camera defines the camera to use
  82263. * @returns the distance
  82264. */
  82265. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82266. /**
  82267. * Clone the current transform node
  82268. * @param name Name of the new clone
  82269. * @param newParent New parent for the clone
  82270. * @param doNotCloneChildren Do not clone children hierarchy
  82271. * @returns the new transform node
  82272. */
  82273. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82274. /**
  82275. * Serializes the objects information.
  82276. * @param currentSerializationObject defines the object to serialize in
  82277. * @returns the serialized object
  82278. */
  82279. serialize(currentSerializationObject?: any): any;
  82280. /**
  82281. * Returns a new TransformNode object parsed from the source provided.
  82282. * @param parsedTransformNode is the source.
  82283. * @param scene the scne the object belongs to
  82284. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82285. * @returns a new TransformNode object parsed from the source provided.
  82286. */
  82287. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82288. /**
  82289. * Get all child-transformNodes of this node
  82290. * @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
  82291. * @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
  82292. * @returns an array of TransformNode
  82293. */
  82294. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82295. /**
  82296. * Releases resources associated with this transform node.
  82297. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82298. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82299. */
  82300. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82301. /**
  82302. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82303. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82304. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82305. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82306. * @returns the current mesh
  82307. */
  82308. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82309. private _syncAbsoluteScalingAndRotation;
  82310. }
  82311. }
  82312. declare module BABYLON {
  82313. /**
  82314. * Defines the types of pose enabled controllers that are supported
  82315. */
  82316. export enum PoseEnabledControllerType {
  82317. /**
  82318. * HTC Vive
  82319. */
  82320. VIVE = 0,
  82321. /**
  82322. * Oculus Rift
  82323. */
  82324. OCULUS = 1,
  82325. /**
  82326. * Windows mixed reality
  82327. */
  82328. WINDOWS = 2,
  82329. /**
  82330. * Samsung gear VR
  82331. */
  82332. GEAR_VR = 3,
  82333. /**
  82334. * Google Daydream
  82335. */
  82336. DAYDREAM = 4,
  82337. /**
  82338. * Generic
  82339. */
  82340. GENERIC = 5
  82341. }
  82342. /**
  82343. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82344. */
  82345. export interface MutableGamepadButton {
  82346. /**
  82347. * Value of the button/trigger
  82348. */
  82349. value: number;
  82350. /**
  82351. * If the button/trigger is currently touched
  82352. */
  82353. touched: boolean;
  82354. /**
  82355. * If the button/trigger is currently pressed
  82356. */
  82357. pressed: boolean;
  82358. }
  82359. /**
  82360. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82361. * @hidden
  82362. */
  82363. export interface ExtendedGamepadButton extends GamepadButton {
  82364. /**
  82365. * If the button/trigger is currently pressed
  82366. */
  82367. readonly pressed: boolean;
  82368. /**
  82369. * If the button/trigger is currently touched
  82370. */
  82371. readonly touched: boolean;
  82372. /**
  82373. * Value of the button/trigger
  82374. */
  82375. readonly value: number;
  82376. }
  82377. /** @hidden */
  82378. export interface _GamePadFactory {
  82379. /**
  82380. * Returns wether or not the current gamepad can be created for this type of controller.
  82381. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82382. * @returns true if it can be created, otherwise false
  82383. */
  82384. canCreate(gamepadInfo: any): boolean;
  82385. /**
  82386. * Creates a new instance of the Gamepad.
  82387. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82388. * @returns the new gamepad instance
  82389. */
  82390. create(gamepadInfo: any): Gamepad;
  82391. }
  82392. /**
  82393. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82394. */
  82395. export class PoseEnabledControllerHelper {
  82396. /** @hidden */
  82397. static _ControllerFactories: _GamePadFactory[];
  82398. /** @hidden */
  82399. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82400. /**
  82401. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82402. * @param vrGamepad the gamepad to initialized
  82403. * @returns a vr controller of the type the gamepad identified as
  82404. */
  82405. static InitiateController(vrGamepad: any): Gamepad;
  82406. }
  82407. /**
  82408. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82409. */
  82410. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82411. /**
  82412. * If the controller is used in a webXR session
  82413. */
  82414. isXR: boolean;
  82415. private _deviceRoomPosition;
  82416. private _deviceRoomRotationQuaternion;
  82417. /**
  82418. * The device position in babylon space
  82419. */
  82420. devicePosition: Vector3;
  82421. /**
  82422. * The device rotation in babylon space
  82423. */
  82424. deviceRotationQuaternion: Quaternion;
  82425. /**
  82426. * The scale factor of the device in babylon space
  82427. */
  82428. deviceScaleFactor: number;
  82429. /**
  82430. * (Likely devicePosition should be used instead) The device position in its room space
  82431. */
  82432. position: Vector3;
  82433. /**
  82434. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82435. */
  82436. rotationQuaternion: Quaternion;
  82437. /**
  82438. * The type of controller (Eg. Windows mixed reality)
  82439. */
  82440. controllerType: PoseEnabledControllerType;
  82441. protected _calculatedPosition: Vector3;
  82442. private _calculatedRotation;
  82443. /**
  82444. * The raw pose from the device
  82445. */
  82446. rawPose: DevicePose;
  82447. private _trackPosition;
  82448. private _maxRotationDistFromHeadset;
  82449. private _draggedRoomRotation;
  82450. /**
  82451. * @hidden
  82452. */
  82453. _disableTrackPosition(fixedPosition: Vector3): void;
  82454. /**
  82455. * Internal, the mesh attached to the controller
  82456. * @hidden
  82457. */
  82458. _mesh: Nullable<AbstractMesh>;
  82459. private _poseControlledCamera;
  82460. private _leftHandSystemQuaternion;
  82461. /**
  82462. * Internal, matrix used to convert room space to babylon space
  82463. * @hidden
  82464. */
  82465. _deviceToWorld: Matrix;
  82466. /**
  82467. * Node to be used when casting a ray from the controller
  82468. * @hidden
  82469. */
  82470. _pointingPoseNode: Nullable<TransformNode>;
  82471. /**
  82472. * Name of the child mesh that can be used to cast a ray from the controller
  82473. */
  82474. static readonly POINTING_POSE: string;
  82475. /**
  82476. * Creates a new PoseEnabledController from a gamepad
  82477. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82478. */
  82479. constructor(browserGamepad: any);
  82480. private _workingMatrix;
  82481. /**
  82482. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82483. */
  82484. update(): void;
  82485. /**
  82486. * Updates only the pose device and mesh without doing any button event checking
  82487. */
  82488. protected _updatePoseAndMesh(): void;
  82489. /**
  82490. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82491. * @param poseData raw pose fromthe device
  82492. */
  82493. updateFromDevice(poseData: DevicePose): void;
  82494. /**
  82495. * @hidden
  82496. */
  82497. _meshAttachedObservable: Observable<AbstractMesh>;
  82498. /**
  82499. * Attaches a mesh to the controller
  82500. * @param mesh the mesh to be attached
  82501. */
  82502. attachToMesh(mesh: AbstractMesh): void;
  82503. /**
  82504. * Attaches the controllers mesh to a camera
  82505. * @param camera the camera the mesh should be attached to
  82506. */
  82507. attachToPoseControlledCamera(camera: TargetCamera): void;
  82508. /**
  82509. * Disposes of the controller
  82510. */
  82511. dispose(): void;
  82512. /**
  82513. * The mesh that is attached to the controller
  82514. */
  82515. readonly mesh: Nullable<AbstractMesh>;
  82516. /**
  82517. * Gets the ray of the controller in the direction the controller is pointing
  82518. * @param length the length the resulting ray should be
  82519. * @returns a ray in the direction the controller is pointing
  82520. */
  82521. getForwardRay(length?: number): Ray;
  82522. }
  82523. }
  82524. declare module BABYLON {
  82525. /**
  82526. * Defines the WebVRController object that represents controllers tracked in 3D space
  82527. */
  82528. export abstract class WebVRController extends PoseEnabledController {
  82529. /**
  82530. * Internal, the default controller model for the controller
  82531. */
  82532. protected _defaultModel: Nullable<AbstractMesh>;
  82533. /**
  82534. * Fired when the trigger state has changed
  82535. */
  82536. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82537. /**
  82538. * Fired when the main button state has changed
  82539. */
  82540. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82541. /**
  82542. * Fired when the secondary button state has changed
  82543. */
  82544. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82545. /**
  82546. * Fired when the pad state has changed
  82547. */
  82548. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82549. /**
  82550. * Fired when controllers stick values have changed
  82551. */
  82552. onPadValuesChangedObservable: Observable<StickValues>;
  82553. /**
  82554. * Array of button availible on the controller
  82555. */
  82556. protected _buttons: Array<MutableGamepadButton>;
  82557. private _onButtonStateChange;
  82558. /**
  82559. * Fired when a controller button's state has changed
  82560. * @param callback the callback containing the button that was modified
  82561. */
  82562. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82563. /**
  82564. * X and Y axis corresponding to the controllers joystick
  82565. */
  82566. pad: StickValues;
  82567. /**
  82568. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82569. */
  82570. hand: string;
  82571. /**
  82572. * The default controller model for the controller
  82573. */
  82574. readonly defaultModel: Nullable<AbstractMesh>;
  82575. /**
  82576. * Creates a new WebVRController from a gamepad
  82577. * @param vrGamepad the gamepad that the WebVRController should be created from
  82578. */
  82579. constructor(vrGamepad: any);
  82580. /**
  82581. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82582. */
  82583. update(): void;
  82584. /**
  82585. * Function to be called when a button is modified
  82586. */
  82587. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82588. /**
  82589. * Loads a mesh and attaches it to the controller
  82590. * @param scene the scene the mesh should be added to
  82591. * @param meshLoaded callback for when the mesh has been loaded
  82592. */
  82593. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82594. private _setButtonValue;
  82595. private _changes;
  82596. private _checkChanges;
  82597. /**
  82598. * Disposes of th webVRCOntroller
  82599. */
  82600. dispose(): void;
  82601. }
  82602. }
  82603. declare module BABYLON {
  82604. /**
  82605. * The HemisphericLight simulates the ambient environment light,
  82606. * so the passed direction is the light reflection direction, not the incoming direction.
  82607. */
  82608. export class HemisphericLight extends Light {
  82609. /**
  82610. * The groundColor is the light in the opposite direction to the one specified during creation.
  82611. * 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.
  82612. */
  82613. groundColor: Color3;
  82614. /**
  82615. * The light reflection direction, not the incoming direction.
  82616. */
  82617. direction: Vector3;
  82618. /**
  82619. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82620. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82621. * The HemisphericLight can't cast shadows.
  82622. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82623. * @param name The friendly name of the light
  82624. * @param direction The direction of the light reflection
  82625. * @param scene The scene the light belongs to
  82626. */
  82627. constructor(name: string, direction: Vector3, scene: Scene);
  82628. protected _buildUniformLayout(): void;
  82629. /**
  82630. * Returns the string "HemisphericLight".
  82631. * @return The class name
  82632. */
  82633. getClassName(): string;
  82634. /**
  82635. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82636. * Returns the updated direction.
  82637. * @param target The target the direction should point to
  82638. * @return The computed direction
  82639. */
  82640. setDirectionToTarget(target: Vector3): Vector3;
  82641. /**
  82642. * Returns the shadow generator associated to the light.
  82643. * @returns Always null for hemispheric lights because it does not support shadows.
  82644. */
  82645. getShadowGenerator(): Nullable<IShadowGenerator>;
  82646. /**
  82647. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82648. * @param effect The effect to update
  82649. * @param lightIndex The index of the light in the effect to update
  82650. * @returns The hemispheric light
  82651. */
  82652. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82653. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82654. /**
  82655. * Computes the world matrix of the node
  82656. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82657. * @param useWasUpdatedFlag defines a reserved property
  82658. * @returns the world matrix
  82659. */
  82660. computeWorldMatrix(): Matrix;
  82661. /**
  82662. * Returns the integer 3.
  82663. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82664. */
  82665. getTypeID(): number;
  82666. /**
  82667. * Prepares the list of defines specific to the light type.
  82668. * @param defines the list of defines
  82669. * @param lightIndex defines the index of the light for the effect
  82670. */
  82671. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82672. }
  82673. }
  82674. declare module BABYLON {
  82675. /** @hidden */
  82676. export var vrMultiviewToSingleviewPixelShader: {
  82677. name: string;
  82678. shader: string;
  82679. };
  82680. }
  82681. declare module BABYLON {
  82682. /**
  82683. * Renders to multiple views with a single draw call
  82684. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82685. */
  82686. export class MultiviewRenderTarget extends RenderTargetTexture {
  82687. /**
  82688. * Creates a multiview render target
  82689. * @param scene scene used with the render target
  82690. * @param size the size of the render target (used for each view)
  82691. */
  82692. constructor(scene: Scene, size?: number | {
  82693. width: number;
  82694. height: number;
  82695. } | {
  82696. ratio: number;
  82697. });
  82698. /**
  82699. * @hidden
  82700. * @param faceIndex the face index, if its a cube texture
  82701. */
  82702. _bindFrameBuffer(faceIndex?: number): void;
  82703. /**
  82704. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82705. * @returns the view count
  82706. */
  82707. getViewCount(): number;
  82708. }
  82709. }
  82710. declare module BABYLON {
  82711. /**
  82712. * Represents a camera frustum
  82713. */
  82714. export class Frustum {
  82715. /**
  82716. * Gets the planes representing the frustum
  82717. * @param transform matrix to be applied to the returned planes
  82718. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82719. */
  82720. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82721. /**
  82722. * Gets the near frustum plane transformed by the transform matrix
  82723. * @param transform transformation matrix to be applied to the resulting frustum plane
  82724. * @param frustumPlane the resuling frustum plane
  82725. */
  82726. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82727. /**
  82728. * Gets the far frustum plane transformed by the transform matrix
  82729. * @param transform transformation matrix to be applied to the resulting frustum plane
  82730. * @param frustumPlane the resuling frustum plane
  82731. */
  82732. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82733. /**
  82734. * Gets the left frustum plane transformed by the transform matrix
  82735. * @param transform transformation matrix to be applied to the resulting frustum plane
  82736. * @param frustumPlane the resuling frustum plane
  82737. */
  82738. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82739. /**
  82740. * Gets the right frustum plane transformed by the transform matrix
  82741. * @param transform transformation matrix to be applied to the resulting frustum plane
  82742. * @param frustumPlane the resuling frustum plane
  82743. */
  82744. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82745. /**
  82746. * Gets the top frustum plane transformed by the transform matrix
  82747. * @param transform transformation matrix to be applied to the resulting frustum plane
  82748. * @param frustumPlane the resuling frustum plane
  82749. */
  82750. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82751. /**
  82752. * Gets the bottom frustum plane transformed by the transform matrix
  82753. * @param transform transformation matrix to be applied to the resulting frustum plane
  82754. * @param frustumPlane the resuling frustum plane
  82755. */
  82756. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82757. /**
  82758. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82759. * @param transform transformation matrix to be applied to the resulting frustum planes
  82760. * @param frustumPlanes the resuling frustum planes
  82761. */
  82762. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82763. }
  82764. }
  82765. declare module BABYLON {
  82766. interface Engine {
  82767. /**
  82768. * Creates a new multiview render target
  82769. * @param width defines the width of the texture
  82770. * @param height defines the height of the texture
  82771. * @returns the created multiview texture
  82772. */
  82773. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82774. /**
  82775. * Binds a multiview framebuffer to be drawn to
  82776. * @param multiviewTexture texture to bind
  82777. */
  82778. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82779. }
  82780. interface Camera {
  82781. /**
  82782. * @hidden
  82783. * 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)
  82784. */
  82785. _useMultiviewToSingleView: boolean;
  82786. /**
  82787. * @hidden
  82788. * 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)
  82789. */
  82790. _multiviewTexture: Nullable<RenderTargetTexture>;
  82791. /**
  82792. * @hidden
  82793. * ensures the multiview texture of the camera exists and has the specified width/height
  82794. * @param width height to set on the multiview texture
  82795. * @param height width to set on the multiview texture
  82796. */
  82797. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82798. }
  82799. interface Scene {
  82800. /** @hidden */
  82801. _transformMatrixR: Matrix;
  82802. /** @hidden */
  82803. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82804. /** @hidden */
  82805. _createMultiviewUbo(): void;
  82806. /** @hidden */
  82807. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82808. /** @hidden */
  82809. _renderMultiviewToSingleView(camera: Camera): void;
  82810. }
  82811. }
  82812. declare module BABYLON {
  82813. /**
  82814. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82815. * This will not be used for webXR as it supports displaying texture arrays directly
  82816. */
  82817. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82818. /**
  82819. * Initializes a VRMultiviewToSingleview
  82820. * @param name name of the post process
  82821. * @param camera camera to be applied to
  82822. * @param scaleFactor scaling factor to the size of the output texture
  82823. */
  82824. constructor(name: string, camera: Camera, scaleFactor: number);
  82825. }
  82826. }
  82827. declare module BABYLON {
  82828. /**
  82829. * Interface used to define additional presentation attributes
  82830. */
  82831. export interface IVRPresentationAttributes {
  82832. /**
  82833. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  82834. */
  82835. highRefreshRate: boolean;
  82836. /**
  82837. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  82838. */
  82839. foveationLevel: number;
  82840. }
  82841. interface Engine {
  82842. /** @hidden */
  82843. _vrDisplay: any;
  82844. /** @hidden */
  82845. _vrSupported: boolean;
  82846. /** @hidden */
  82847. _oldSize: Size;
  82848. /** @hidden */
  82849. _oldHardwareScaleFactor: number;
  82850. /** @hidden */
  82851. _vrExclusivePointerMode: boolean;
  82852. /** @hidden */
  82853. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82854. /** @hidden */
  82855. _onVRDisplayPointerRestricted: () => void;
  82856. /** @hidden */
  82857. _onVRDisplayPointerUnrestricted: () => void;
  82858. /** @hidden */
  82859. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82860. /** @hidden */
  82861. _onVrDisplayDisconnect: Nullable<() => void>;
  82862. /** @hidden */
  82863. _onVrDisplayPresentChange: Nullable<() => void>;
  82864. /**
  82865. * Observable signaled when VR display mode changes
  82866. */
  82867. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82868. /**
  82869. * Observable signaled when VR request present is complete
  82870. */
  82871. onVRRequestPresentComplete: Observable<boolean>;
  82872. /**
  82873. * Observable signaled when VR request present starts
  82874. */
  82875. onVRRequestPresentStart: Observable<Engine>;
  82876. /**
  82877. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82878. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82879. */
  82880. isInVRExclusivePointerMode: boolean;
  82881. /**
  82882. * Gets a boolean indicating if a webVR device was detected
  82883. * @returns true if a webVR device was detected
  82884. */
  82885. isVRDevicePresent(): boolean;
  82886. /**
  82887. * Gets the current webVR device
  82888. * @returns the current webVR device (or null)
  82889. */
  82890. getVRDevice(): any;
  82891. /**
  82892. * Initializes a webVR display and starts listening to display change events
  82893. * The onVRDisplayChangedObservable will be notified upon these changes
  82894. * @returns A promise containing a VRDisplay and if vr is supported
  82895. */
  82896. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82897. /** @hidden */
  82898. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82899. /**
  82900. * Gets or sets the presentation attributes used to configure VR rendering
  82901. */
  82902. vrPresentationAttributes?: IVRPresentationAttributes;
  82903. /**
  82904. * Call this function to switch to webVR mode
  82905. * Will do nothing if webVR is not supported or if there is no webVR device
  82906. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82907. */
  82908. enableVR(): void;
  82909. /** @hidden */
  82910. _onVRFullScreenTriggered(): void;
  82911. }
  82912. }
  82913. declare module BABYLON {
  82914. /**
  82915. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82916. * IMPORTANT!! The data is right-hand data.
  82917. * @export
  82918. * @interface DevicePose
  82919. */
  82920. export interface DevicePose {
  82921. /**
  82922. * The position of the device, values in array are [x,y,z].
  82923. */
  82924. readonly position: Nullable<Float32Array>;
  82925. /**
  82926. * The linearVelocity of the device, values in array are [x,y,z].
  82927. */
  82928. readonly linearVelocity: Nullable<Float32Array>;
  82929. /**
  82930. * The linearAcceleration of the device, values in array are [x,y,z].
  82931. */
  82932. readonly linearAcceleration: Nullable<Float32Array>;
  82933. /**
  82934. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82935. */
  82936. readonly orientation: Nullable<Float32Array>;
  82937. /**
  82938. * The angularVelocity of the device, values in array are [x,y,z].
  82939. */
  82940. readonly angularVelocity: Nullable<Float32Array>;
  82941. /**
  82942. * The angularAcceleration of the device, values in array are [x,y,z].
  82943. */
  82944. readonly angularAcceleration: Nullable<Float32Array>;
  82945. }
  82946. /**
  82947. * Interface representing a pose controlled object in Babylon.
  82948. * A pose controlled object has both regular pose values as well as pose values
  82949. * from an external device such as a VR head mounted display
  82950. */
  82951. export interface PoseControlled {
  82952. /**
  82953. * The position of the object in babylon space.
  82954. */
  82955. position: Vector3;
  82956. /**
  82957. * The rotation quaternion of the object in babylon space.
  82958. */
  82959. rotationQuaternion: Quaternion;
  82960. /**
  82961. * The position of the device in babylon space.
  82962. */
  82963. devicePosition?: Vector3;
  82964. /**
  82965. * The rotation quaternion of the device in babylon space.
  82966. */
  82967. deviceRotationQuaternion: Quaternion;
  82968. /**
  82969. * The raw pose coming from the device.
  82970. */
  82971. rawPose: Nullable<DevicePose>;
  82972. /**
  82973. * The scale of the device to be used when translating from device space to babylon space.
  82974. */
  82975. deviceScaleFactor: number;
  82976. /**
  82977. * Updates the poseControlled values based on the input device pose.
  82978. * @param poseData the pose data to update the object with
  82979. */
  82980. updateFromDevice(poseData: DevicePose): void;
  82981. }
  82982. /**
  82983. * Set of options to customize the webVRCamera
  82984. */
  82985. export interface WebVROptions {
  82986. /**
  82987. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82988. */
  82989. trackPosition?: boolean;
  82990. /**
  82991. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82992. */
  82993. positionScale?: number;
  82994. /**
  82995. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82996. */
  82997. displayName?: string;
  82998. /**
  82999. * Should the native controller meshes be initialized. (default: true)
  83000. */
  83001. controllerMeshes?: boolean;
  83002. /**
  83003. * Creating a default HemiLight only on controllers. (default: true)
  83004. */
  83005. defaultLightingOnControllers?: boolean;
  83006. /**
  83007. * If you don't want to use the default VR button of the helper. (default: false)
  83008. */
  83009. useCustomVRButton?: boolean;
  83010. /**
  83011. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83012. */
  83013. customVRButton?: HTMLButtonElement;
  83014. /**
  83015. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83016. */
  83017. rayLength?: number;
  83018. /**
  83019. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83020. */
  83021. defaultHeight?: number;
  83022. /**
  83023. * If multiview should be used if availible (default: false)
  83024. */
  83025. useMultiview?: boolean;
  83026. }
  83027. /**
  83028. * This represents a WebVR camera.
  83029. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83030. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83031. */
  83032. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83033. private webVROptions;
  83034. /**
  83035. * @hidden
  83036. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83037. */
  83038. _vrDevice: any;
  83039. /**
  83040. * The rawPose of the vrDevice.
  83041. */
  83042. rawPose: Nullable<DevicePose>;
  83043. private _onVREnabled;
  83044. private _specsVersion;
  83045. private _attached;
  83046. private _frameData;
  83047. protected _descendants: Array<Node>;
  83048. private _deviceRoomPosition;
  83049. /** @hidden */
  83050. _deviceRoomRotationQuaternion: Quaternion;
  83051. private _standingMatrix;
  83052. /**
  83053. * Represents device position in babylon space.
  83054. */
  83055. devicePosition: Vector3;
  83056. /**
  83057. * Represents device rotation in babylon space.
  83058. */
  83059. deviceRotationQuaternion: Quaternion;
  83060. /**
  83061. * The scale of the device to be used when translating from device space to babylon space.
  83062. */
  83063. deviceScaleFactor: number;
  83064. private _deviceToWorld;
  83065. private _worldToDevice;
  83066. /**
  83067. * References to the webVR controllers for the vrDevice.
  83068. */
  83069. controllers: Array<WebVRController>;
  83070. /**
  83071. * Emits an event when a controller is attached.
  83072. */
  83073. onControllersAttachedObservable: Observable<WebVRController[]>;
  83074. /**
  83075. * Emits an event when a controller's mesh has been loaded;
  83076. */
  83077. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83078. /**
  83079. * Emits an event when the HMD's pose has been updated.
  83080. */
  83081. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83082. private _poseSet;
  83083. /**
  83084. * If the rig cameras be used as parent instead of this camera.
  83085. */
  83086. rigParenting: boolean;
  83087. private _lightOnControllers;
  83088. private _defaultHeight?;
  83089. /**
  83090. * Instantiates a WebVRFreeCamera.
  83091. * @param name The name of the WebVRFreeCamera
  83092. * @param position The starting anchor position for the camera
  83093. * @param scene The scene the camera belongs to
  83094. * @param webVROptions a set of customizable options for the webVRCamera
  83095. */
  83096. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83097. /**
  83098. * Gets the device distance from the ground in meters.
  83099. * @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.
  83100. */
  83101. deviceDistanceToRoomGround(): number;
  83102. /**
  83103. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83104. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83105. */
  83106. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83107. /**
  83108. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83109. * @returns A promise with a boolean set to if the standing matrix is supported.
  83110. */
  83111. useStandingMatrixAsync(): Promise<boolean>;
  83112. /**
  83113. * Disposes the camera
  83114. */
  83115. dispose(): void;
  83116. /**
  83117. * Gets a vrController by name.
  83118. * @param name The name of the controller to retreive
  83119. * @returns the controller matching the name specified or null if not found
  83120. */
  83121. getControllerByName(name: string): Nullable<WebVRController>;
  83122. private _leftController;
  83123. /**
  83124. * The controller corresponding to the users left hand.
  83125. */
  83126. readonly leftController: Nullable<WebVRController>;
  83127. private _rightController;
  83128. /**
  83129. * The controller corresponding to the users right hand.
  83130. */
  83131. readonly rightController: Nullable<WebVRController>;
  83132. /**
  83133. * Casts a ray forward from the vrCamera's gaze.
  83134. * @param length Length of the ray (default: 100)
  83135. * @returns the ray corresponding to the gaze
  83136. */
  83137. getForwardRay(length?: number): Ray;
  83138. /**
  83139. * @hidden
  83140. * Updates the camera based on device's frame data
  83141. */
  83142. _checkInputs(): void;
  83143. /**
  83144. * Updates the poseControlled values based on the input device pose.
  83145. * @param poseData Pose coming from the device
  83146. */
  83147. updateFromDevice(poseData: DevicePose): void;
  83148. private _htmlElementAttached;
  83149. private _detachIfAttached;
  83150. /**
  83151. * WebVR's attach control will start broadcasting frames to the device.
  83152. * Note that in certain browsers (chrome for example) this function must be called
  83153. * within a user-interaction callback. Example:
  83154. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83155. *
  83156. * @param element html element to attach the vrDevice to
  83157. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83158. */
  83159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83160. /**
  83161. * Detaches the camera from the html element and disables VR
  83162. *
  83163. * @param element html element to detach from
  83164. */
  83165. detachControl(element: HTMLElement): void;
  83166. /**
  83167. * @returns the name of this class
  83168. */
  83169. getClassName(): string;
  83170. /**
  83171. * Calls resetPose on the vrDisplay
  83172. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83173. */
  83174. resetToCurrentRotation(): void;
  83175. /**
  83176. * @hidden
  83177. * Updates the rig cameras (left and right eye)
  83178. */
  83179. _updateRigCameras(): void;
  83180. private _workingVector;
  83181. private _oneVector;
  83182. private _workingMatrix;
  83183. private updateCacheCalled;
  83184. private _correctPositionIfNotTrackPosition;
  83185. /**
  83186. * @hidden
  83187. * Updates the cached values of the camera
  83188. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83189. */
  83190. _updateCache(ignoreParentClass?: boolean): void;
  83191. /**
  83192. * @hidden
  83193. * Get current device position in babylon world
  83194. */
  83195. _computeDevicePosition(): void;
  83196. /**
  83197. * Updates the current device position and rotation in the babylon world
  83198. */
  83199. update(): void;
  83200. /**
  83201. * @hidden
  83202. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83203. * @returns an identity matrix
  83204. */
  83205. _getViewMatrix(): Matrix;
  83206. private _tmpMatrix;
  83207. /**
  83208. * This function is called by the two RIG cameras.
  83209. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83210. * @hidden
  83211. */
  83212. _getWebVRViewMatrix(): Matrix;
  83213. /** @hidden */
  83214. _getWebVRProjectionMatrix(): Matrix;
  83215. private _onGamepadConnectedObserver;
  83216. private _onGamepadDisconnectedObserver;
  83217. private _updateCacheWhenTrackingDisabledObserver;
  83218. /**
  83219. * Initializes the controllers and their meshes
  83220. */
  83221. initControllers(): void;
  83222. }
  83223. }
  83224. declare module BABYLON {
  83225. /**
  83226. * Size options for a post process
  83227. */
  83228. export type PostProcessOptions = {
  83229. width: number;
  83230. height: number;
  83231. };
  83232. /**
  83233. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83234. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83235. */
  83236. export class PostProcess {
  83237. /** Name of the PostProcess. */
  83238. name: string;
  83239. /**
  83240. * Gets or sets the unique id of the post process
  83241. */
  83242. uniqueId: number;
  83243. /**
  83244. * Width of the texture to apply the post process on
  83245. */
  83246. width: number;
  83247. /**
  83248. * Height of the texture to apply the post process on
  83249. */
  83250. height: number;
  83251. /**
  83252. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83253. * @hidden
  83254. */
  83255. _outputTexture: Nullable<InternalTexture>;
  83256. /**
  83257. * Sampling mode used by the shader
  83258. * See https://doc.babylonjs.com/classes/3.1/texture
  83259. */
  83260. renderTargetSamplingMode: number;
  83261. /**
  83262. * Clear color to use when screen clearing
  83263. */
  83264. clearColor: Color4;
  83265. /**
  83266. * If the buffer needs to be cleared before applying the post process. (default: true)
  83267. * Should be set to false if shader will overwrite all previous pixels.
  83268. */
  83269. autoClear: boolean;
  83270. /**
  83271. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83272. */
  83273. alphaMode: number;
  83274. /**
  83275. * Sets the setAlphaBlendConstants of the babylon engine
  83276. */
  83277. alphaConstants: Color4;
  83278. /**
  83279. * Animations to be used for the post processing
  83280. */
  83281. animations: Animation[];
  83282. /**
  83283. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83284. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83285. */
  83286. enablePixelPerfectMode: boolean;
  83287. /**
  83288. * Force the postprocess to be applied without taking in account viewport
  83289. */
  83290. forceFullscreenViewport: boolean;
  83291. /**
  83292. * List of inspectable custom properties (used by the Inspector)
  83293. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83294. */
  83295. inspectableCustomProperties: IInspectable[];
  83296. /**
  83297. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83298. *
  83299. * | Value | Type | Description |
  83300. * | ----- | ----------------------------------- | ----------- |
  83301. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83302. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83303. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83304. *
  83305. */
  83306. scaleMode: number;
  83307. /**
  83308. * Force textures to be a power of two (default: false)
  83309. */
  83310. alwaysForcePOT: boolean;
  83311. private _samples;
  83312. /**
  83313. * Number of sample textures (default: 1)
  83314. */
  83315. samples: number;
  83316. /**
  83317. * Modify the scale of the post process to be the same as the viewport (default: false)
  83318. */
  83319. adaptScaleToCurrentViewport: boolean;
  83320. private _camera;
  83321. private _scene;
  83322. private _engine;
  83323. private _options;
  83324. private _reusable;
  83325. private _textureType;
  83326. /**
  83327. * Smart array of input and output textures for the post process.
  83328. * @hidden
  83329. */
  83330. _textures: SmartArray<InternalTexture>;
  83331. /**
  83332. * The index in _textures that corresponds to the output texture.
  83333. * @hidden
  83334. */
  83335. _currentRenderTextureInd: number;
  83336. private _effect;
  83337. private _samplers;
  83338. private _fragmentUrl;
  83339. private _vertexUrl;
  83340. private _parameters;
  83341. private _scaleRatio;
  83342. protected _indexParameters: any;
  83343. private _shareOutputWithPostProcess;
  83344. private _texelSize;
  83345. private _forcedOutputTexture;
  83346. /**
  83347. * Returns the fragment url or shader name used in the post process.
  83348. * @returns the fragment url or name in the shader store.
  83349. */
  83350. getEffectName(): string;
  83351. /**
  83352. * An event triggered when the postprocess is activated.
  83353. */
  83354. onActivateObservable: Observable<Camera>;
  83355. private _onActivateObserver;
  83356. /**
  83357. * A function that is added to the onActivateObservable
  83358. */
  83359. onActivate: Nullable<(camera: Camera) => void>;
  83360. /**
  83361. * An event triggered when the postprocess changes its size.
  83362. */
  83363. onSizeChangedObservable: Observable<PostProcess>;
  83364. private _onSizeChangedObserver;
  83365. /**
  83366. * A function that is added to the onSizeChangedObservable
  83367. */
  83368. onSizeChanged: (postProcess: PostProcess) => void;
  83369. /**
  83370. * An event triggered when the postprocess applies its effect.
  83371. */
  83372. onApplyObservable: Observable<Effect>;
  83373. private _onApplyObserver;
  83374. /**
  83375. * A function that is added to the onApplyObservable
  83376. */
  83377. onApply: (effect: Effect) => void;
  83378. /**
  83379. * An event triggered before rendering the postprocess
  83380. */
  83381. onBeforeRenderObservable: Observable<Effect>;
  83382. private _onBeforeRenderObserver;
  83383. /**
  83384. * A function that is added to the onBeforeRenderObservable
  83385. */
  83386. onBeforeRender: (effect: Effect) => void;
  83387. /**
  83388. * An event triggered after rendering the postprocess
  83389. */
  83390. onAfterRenderObservable: Observable<Effect>;
  83391. private _onAfterRenderObserver;
  83392. /**
  83393. * A function that is added to the onAfterRenderObservable
  83394. */
  83395. onAfterRender: (efect: Effect) => void;
  83396. /**
  83397. * 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
  83398. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83399. */
  83400. inputTexture: InternalTexture;
  83401. /**
  83402. * Gets the camera which post process is applied to.
  83403. * @returns The camera the post process is applied to.
  83404. */
  83405. getCamera(): Camera;
  83406. /**
  83407. * Gets the texel size of the postprocess.
  83408. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83409. */
  83410. readonly texelSize: Vector2;
  83411. /**
  83412. * Creates a new instance PostProcess
  83413. * @param name The name of the PostProcess.
  83414. * @param fragmentUrl The url of the fragment shader to be used.
  83415. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83416. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83417. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83418. * @param camera The camera to apply the render pass to.
  83419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83420. * @param engine The engine which the post process will be applied. (default: current engine)
  83421. * @param reusable If the post process can be reused on the same frame. (default: false)
  83422. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83423. * @param textureType Type of textures used when performing the post process. (default: 0)
  83424. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83425. * @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
  83426. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83427. */
  83428. constructor(
  83429. /** Name of the PostProcess. */
  83430. 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);
  83431. /**
  83432. * Gets a string idenfifying the name of the class
  83433. * @returns "PostProcess" string
  83434. */
  83435. getClassName(): string;
  83436. /**
  83437. * Gets the engine which this post process belongs to.
  83438. * @returns The engine the post process was enabled with.
  83439. */
  83440. getEngine(): Engine;
  83441. /**
  83442. * The effect that is created when initializing the post process.
  83443. * @returns The created effect corresponding the the postprocess.
  83444. */
  83445. getEffect(): Effect;
  83446. /**
  83447. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83448. * @param postProcess The post process to share the output with.
  83449. * @returns This post process.
  83450. */
  83451. shareOutputWith(postProcess: PostProcess): PostProcess;
  83452. /**
  83453. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83454. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83455. */
  83456. useOwnOutput(): void;
  83457. /**
  83458. * Updates the effect with the current post process compile time values and recompiles the shader.
  83459. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83460. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83461. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83462. * @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
  83463. * @param onCompiled Called when the shader has been compiled.
  83464. * @param onError Called if there is an error when compiling a shader.
  83465. */
  83466. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83467. /**
  83468. * The post process is reusable if it can be used multiple times within one frame.
  83469. * @returns If the post process is reusable
  83470. */
  83471. isReusable(): boolean;
  83472. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83473. markTextureDirty(): void;
  83474. /**
  83475. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83476. * 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.
  83477. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83478. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83479. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83480. * @returns The target texture that was bound to be written to.
  83481. */
  83482. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83483. /**
  83484. * If the post process is supported.
  83485. */
  83486. readonly isSupported: boolean;
  83487. /**
  83488. * The aspect ratio of the output texture.
  83489. */
  83490. readonly aspectRatio: number;
  83491. /**
  83492. * Get a value indicating if the post-process is ready to be used
  83493. * @returns true if the post-process is ready (shader is compiled)
  83494. */
  83495. isReady(): boolean;
  83496. /**
  83497. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83498. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83499. */
  83500. apply(): Nullable<Effect>;
  83501. private _disposeTextures;
  83502. /**
  83503. * Disposes the post process.
  83504. * @param camera The camera to dispose the post process on.
  83505. */
  83506. dispose(camera?: Camera): void;
  83507. }
  83508. }
  83509. declare module BABYLON {
  83510. /** @hidden */
  83511. export var kernelBlurVaryingDeclaration: {
  83512. name: string;
  83513. shader: string;
  83514. };
  83515. }
  83516. declare module BABYLON {
  83517. /** @hidden */
  83518. export var kernelBlurFragment: {
  83519. name: string;
  83520. shader: string;
  83521. };
  83522. }
  83523. declare module BABYLON {
  83524. /** @hidden */
  83525. export var kernelBlurFragment2: {
  83526. name: string;
  83527. shader: string;
  83528. };
  83529. }
  83530. declare module BABYLON {
  83531. /** @hidden */
  83532. export var kernelBlurPixelShader: {
  83533. name: string;
  83534. shader: string;
  83535. };
  83536. }
  83537. declare module BABYLON {
  83538. /** @hidden */
  83539. export var kernelBlurVertex: {
  83540. name: string;
  83541. shader: string;
  83542. };
  83543. }
  83544. declare module BABYLON {
  83545. /** @hidden */
  83546. export var kernelBlurVertexShader: {
  83547. name: string;
  83548. shader: string;
  83549. };
  83550. }
  83551. declare module BABYLON {
  83552. /**
  83553. * The Blur Post Process which blurs an image based on a kernel and direction.
  83554. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83555. */
  83556. export class BlurPostProcess extends PostProcess {
  83557. /** The direction in which to blur the image. */
  83558. direction: Vector2;
  83559. private blockCompilation;
  83560. protected _kernel: number;
  83561. protected _idealKernel: number;
  83562. protected _packedFloat: boolean;
  83563. private _staticDefines;
  83564. /**
  83565. * Sets the length in pixels of the blur sample region
  83566. */
  83567. /**
  83568. * Gets the length in pixels of the blur sample region
  83569. */
  83570. kernel: number;
  83571. /**
  83572. * Sets wether or not the blur needs to unpack/repack floats
  83573. */
  83574. /**
  83575. * Gets wether or not the blur is unpacking/repacking floats
  83576. */
  83577. packedFloat: boolean;
  83578. /**
  83579. * Creates a new instance BlurPostProcess
  83580. * @param name The name of the effect.
  83581. * @param direction The direction in which to blur the image.
  83582. * @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.
  83583. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83584. * @param camera The camera to apply the render pass to.
  83585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83586. * @param engine The engine which the post process will be applied. (default: current engine)
  83587. * @param reusable If the post process can be reused on the same frame. (default: false)
  83588. * @param textureType Type of textures used when performing the post process. (default: 0)
  83589. * @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)
  83590. */
  83591. constructor(name: string,
  83592. /** The direction in which to blur the image. */
  83593. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83594. /**
  83595. * Updates the effect with the current post process compile time values and recompiles the shader.
  83596. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83597. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83598. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83599. * @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
  83600. * @param onCompiled Called when the shader has been compiled.
  83601. * @param onError Called if there is an error when compiling a shader.
  83602. */
  83603. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83604. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83605. /**
  83606. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83607. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83608. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83609. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83610. * The gaps between physical kernels are compensated for in the weighting of the samples
  83611. * @param idealKernel Ideal blur kernel.
  83612. * @return Nearest best kernel.
  83613. */
  83614. protected _nearestBestKernel(idealKernel: number): number;
  83615. /**
  83616. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83617. * @param x The point on the Gaussian distribution to sample.
  83618. * @return the value of the Gaussian function at x.
  83619. */
  83620. protected _gaussianWeight(x: number): number;
  83621. /**
  83622. * Generates a string that can be used as a floating point number in GLSL.
  83623. * @param x Value to print.
  83624. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83625. * @return GLSL float string.
  83626. */
  83627. protected _glslFloat(x: number, decimalFigures?: number): string;
  83628. }
  83629. }
  83630. declare module BABYLON {
  83631. /**
  83632. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83633. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83634. * You can then easily use it as a reflectionTexture on a flat surface.
  83635. * In case the surface is not a plane, please consider relying on reflection probes.
  83636. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83637. */
  83638. export class MirrorTexture extends RenderTargetTexture {
  83639. private scene;
  83640. /**
  83641. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83642. * 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.
  83643. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83644. */
  83645. mirrorPlane: Plane;
  83646. /**
  83647. * Define the blur ratio used to blur the reflection if needed.
  83648. */
  83649. blurRatio: number;
  83650. /**
  83651. * Define the adaptive blur kernel used to blur the reflection if needed.
  83652. * This will autocompute the closest best match for the `blurKernel`
  83653. */
  83654. adaptiveBlurKernel: number;
  83655. /**
  83656. * Define the blur kernel used to blur the reflection if needed.
  83657. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83658. */
  83659. blurKernel: number;
  83660. /**
  83661. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83662. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83663. */
  83664. blurKernelX: number;
  83665. /**
  83666. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83667. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83668. */
  83669. blurKernelY: number;
  83670. private _autoComputeBlurKernel;
  83671. protected _onRatioRescale(): void;
  83672. private _updateGammaSpace;
  83673. private _imageProcessingConfigChangeObserver;
  83674. private _transformMatrix;
  83675. private _mirrorMatrix;
  83676. private _savedViewMatrix;
  83677. private _blurX;
  83678. private _blurY;
  83679. private _adaptiveBlurKernel;
  83680. private _blurKernelX;
  83681. private _blurKernelY;
  83682. private _blurRatio;
  83683. /**
  83684. * Instantiates a Mirror Texture.
  83685. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83686. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83687. * You can then easily use it as a reflectionTexture on a flat surface.
  83688. * In case the surface is not a plane, please consider relying on reflection probes.
  83689. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83690. * @param name
  83691. * @param size
  83692. * @param scene
  83693. * @param generateMipMaps
  83694. * @param type
  83695. * @param samplingMode
  83696. * @param generateDepthBuffer
  83697. */
  83698. constructor(name: string, size: number | {
  83699. width: number;
  83700. height: number;
  83701. } | {
  83702. ratio: number;
  83703. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83704. private _preparePostProcesses;
  83705. /**
  83706. * Clone the mirror texture.
  83707. * @returns the cloned texture
  83708. */
  83709. clone(): MirrorTexture;
  83710. /**
  83711. * Serialize the texture to a JSON representation you could use in Parse later on
  83712. * @returns the serialized JSON representation
  83713. */
  83714. serialize(): any;
  83715. /**
  83716. * Dispose the texture and release its associated resources.
  83717. */
  83718. dispose(): void;
  83719. }
  83720. }
  83721. declare module BABYLON {
  83722. /**
  83723. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83724. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83725. */
  83726. export class Texture extends BaseTexture {
  83727. /**
  83728. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83729. */
  83730. static SerializeBuffers: boolean;
  83731. /** @hidden */
  83732. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83733. /** @hidden */
  83734. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83735. /** @hidden */
  83736. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83737. /** nearest is mag = nearest and min = nearest and mip = linear */
  83738. static readonly NEAREST_SAMPLINGMODE: number;
  83739. /** nearest is mag = nearest and min = nearest and mip = linear */
  83740. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83741. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83742. static readonly BILINEAR_SAMPLINGMODE: number;
  83743. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83744. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83745. /** Trilinear is mag = linear and min = linear and mip = linear */
  83746. static readonly TRILINEAR_SAMPLINGMODE: number;
  83747. /** Trilinear is mag = linear and min = linear and mip = linear */
  83748. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83749. /** mag = nearest and min = nearest and mip = nearest */
  83750. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83751. /** mag = nearest and min = linear and mip = nearest */
  83752. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83753. /** mag = nearest and min = linear and mip = linear */
  83754. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83755. /** mag = nearest and min = linear and mip = none */
  83756. static readonly NEAREST_LINEAR: number;
  83757. /** mag = nearest and min = nearest and mip = none */
  83758. static readonly NEAREST_NEAREST: number;
  83759. /** mag = linear and min = nearest and mip = nearest */
  83760. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83761. /** mag = linear and min = nearest and mip = linear */
  83762. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83763. /** mag = linear and min = linear and mip = none */
  83764. static readonly LINEAR_LINEAR: number;
  83765. /** mag = linear and min = nearest and mip = none */
  83766. static readonly LINEAR_NEAREST: number;
  83767. /** Explicit coordinates mode */
  83768. static readonly EXPLICIT_MODE: number;
  83769. /** Spherical coordinates mode */
  83770. static readonly SPHERICAL_MODE: number;
  83771. /** Planar coordinates mode */
  83772. static readonly PLANAR_MODE: number;
  83773. /** Cubic coordinates mode */
  83774. static readonly CUBIC_MODE: number;
  83775. /** Projection coordinates mode */
  83776. static readonly PROJECTION_MODE: number;
  83777. /** Inverse Cubic coordinates mode */
  83778. static readonly SKYBOX_MODE: number;
  83779. /** Inverse Cubic coordinates mode */
  83780. static readonly INVCUBIC_MODE: number;
  83781. /** Equirectangular coordinates mode */
  83782. static readonly EQUIRECTANGULAR_MODE: number;
  83783. /** Equirectangular Fixed coordinates mode */
  83784. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83785. /** Equirectangular Fixed Mirrored coordinates mode */
  83786. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83787. /** Texture is not repeating outside of 0..1 UVs */
  83788. static readonly CLAMP_ADDRESSMODE: number;
  83789. /** Texture is repeating outside of 0..1 UVs */
  83790. static readonly WRAP_ADDRESSMODE: number;
  83791. /** Texture is repeating and mirrored */
  83792. static readonly MIRROR_ADDRESSMODE: number;
  83793. /**
  83794. * 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
  83795. */
  83796. static UseSerializedUrlIfAny: boolean;
  83797. /**
  83798. * Define the url of the texture.
  83799. */
  83800. url: Nullable<string>;
  83801. /**
  83802. * Define an offset on the texture to offset the u coordinates of the UVs
  83803. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83804. */
  83805. uOffset: number;
  83806. /**
  83807. * Define an offset on the texture to offset the v coordinates of the UVs
  83808. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83809. */
  83810. vOffset: number;
  83811. /**
  83812. * Define an offset on the texture to scale the u coordinates of the UVs
  83813. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83814. */
  83815. uScale: number;
  83816. /**
  83817. * Define an offset on the texture to scale the v coordinates of the UVs
  83818. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83819. */
  83820. vScale: number;
  83821. /**
  83822. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83823. * @see http://doc.babylonjs.com/how_to/more_materials
  83824. */
  83825. uAng: number;
  83826. /**
  83827. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83828. * @see http://doc.babylonjs.com/how_to/more_materials
  83829. */
  83830. vAng: number;
  83831. /**
  83832. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83833. * @see http://doc.babylonjs.com/how_to/more_materials
  83834. */
  83835. wAng: number;
  83836. /**
  83837. * Defines the center of rotation (U)
  83838. */
  83839. uRotationCenter: number;
  83840. /**
  83841. * Defines the center of rotation (V)
  83842. */
  83843. vRotationCenter: number;
  83844. /**
  83845. * Defines the center of rotation (W)
  83846. */
  83847. wRotationCenter: number;
  83848. /**
  83849. * Are mip maps generated for this texture or not.
  83850. */
  83851. readonly noMipmap: boolean;
  83852. /**
  83853. * List of inspectable custom properties (used by the Inspector)
  83854. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83855. */
  83856. inspectableCustomProperties: Nullable<IInspectable[]>;
  83857. private _noMipmap;
  83858. /** @hidden */
  83859. _invertY: boolean;
  83860. private _rowGenerationMatrix;
  83861. private _cachedTextureMatrix;
  83862. private _projectionModeMatrix;
  83863. private _t0;
  83864. private _t1;
  83865. private _t2;
  83866. private _cachedUOffset;
  83867. private _cachedVOffset;
  83868. private _cachedUScale;
  83869. private _cachedVScale;
  83870. private _cachedUAng;
  83871. private _cachedVAng;
  83872. private _cachedWAng;
  83873. private _cachedProjectionMatrixId;
  83874. private _cachedCoordinatesMode;
  83875. /** @hidden */
  83876. protected _initialSamplingMode: number;
  83877. /** @hidden */
  83878. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83879. private _deleteBuffer;
  83880. protected _format: Nullable<number>;
  83881. private _delayedOnLoad;
  83882. private _delayedOnError;
  83883. private _mimeType?;
  83884. /**
  83885. * Observable triggered once the texture has been loaded.
  83886. */
  83887. onLoadObservable: Observable<Texture>;
  83888. protected _isBlocking: boolean;
  83889. /**
  83890. * Is the texture preventing material to render while loading.
  83891. * If false, a default texture will be used instead of the loading one during the preparation step.
  83892. */
  83893. isBlocking: boolean;
  83894. /**
  83895. * Get the current sampling mode associated with the texture.
  83896. */
  83897. readonly samplingMode: number;
  83898. /**
  83899. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83900. */
  83901. readonly invertY: boolean;
  83902. /**
  83903. * Instantiates a new texture.
  83904. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83905. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83906. * @param url defines the url of the picture to load as a texture
  83907. * @param scene defines the scene or engine the texture will belong to
  83908. * @param noMipmap defines if the texture will require mip maps or not
  83909. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83910. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83911. * @param onLoad defines a callback triggered when the texture has been loaded
  83912. * @param onError defines a callback triggered when an error occurred during the loading session
  83913. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83914. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83915. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83916. * @param mimeType defines an optional mime type information
  83917. */
  83918. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83919. /**
  83920. * Update the url (and optional buffer) of this texture if url was null during construction.
  83921. * @param url the url of the texture
  83922. * @param buffer the buffer of the texture (defaults to null)
  83923. * @param onLoad callback called when the texture is loaded (defaults to null)
  83924. */
  83925. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83926. /**
  83927. * Finish the loading sequence of a texture flagged as delayed load.
  83928. * @hidden
  83929. */
  83930. delayLoad(): void;
  83931. private _prepareRowForTextureGeneration;
  83932. /**
  83933. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83934. * @returns the transform matrix of the texture.
  83935. */
  83936. getTextureMatrix(): Matrix;
  83937. /**
  83938. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83939. * @returns The reflection texture transform
  83940. */
  83941. getReflectionTextureMatrix(): Matrix;
  83942. /**
  83943. * Clones the texture.
  83944. * @returns the cloned texture
  83945. */
  83946. clone(): Texture;
  83947. /**
  83948. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83949. * @returns The JSON representation of the texture
  83950. */
  83951. serialize(): any;
  83952. /**
  83953. * Get the current class name of the texture useful for serialization or dynamic coding.
  83954. * @returns "Texture"
  83955. */
  83956. getClassName(): string;
  83957. /**
  83958. * Dispose the texture and release its associated resources.
  83959. */
  83960. dispose(): void;
  83961. /**
  83962. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83963. * @param parsedTexture Define the JSON representation of the texture
  83964. * @param scene Define the scene the parsed texture should be instantiated in
  83965. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83966. * @returns The parsed texture if successful
  83967. */
  83968. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83969. /**
  83970. * Creates a texture from its base 64 representation.
  83971. * @param data Define the base64 payload without the data: prefix
  83972. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83973. * @param scene Define the scene the texture should belong to
  83974. * @param noMipmap Forces the texture to not create mip map information if true
  83975. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83976. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83977. * @param onLoad define a callback triggered when the texture has been loaded
  83978. * @param onError define a callback triggered when an error occurred during the loading session
  83979. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83980. * @returns the created texture
  83981. */
  83982. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83983. /**
  83984. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83985. * @param data Define the base64 payload without the data: prefix
  83986. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83987. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83988. * @param scene Define the scene the texture should belong to
  83989. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83990. * @param noMipmap Forces the texture to not create mip map information if true
  83991. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83992. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83993. * @param onLoad define a callback triggered when the texture has been loaded
  83994. * @param onError define a callback triggered when an error occurred during the loading session
  83995. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83996. * @returns the created texture
  83997. */
  83998. 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;
  83999. }
  84000. }
  84001. declare module BABYLON {
  84002. /**
  84003. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84004. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84005. */
  84006. export class PostProcessManager {
  84007. private _scene;
  84008. private _indexBuffer;
  84009. private _vertexBuffers;
  84010. /**
  84011. * Creates a new instance PostProcess
  84012. * @param scene The scene that the post process is associated with.
  84013. */
  84014. constructor(scene: Scene);
  84015. private _prepareBuffers;
  84016. private _buildIndexBuffer;
  84017. /**
  84018. * Rebuilds the vertex buffers of the manager.
  84019. * @hidden
  84020. */
  84021. _rebuild(): void;
  84022. /**
  84023. * Prepares a frame to be run through a post process.
  84024. * @param sourceTexture The input texture to the post procesess. (default: null)
  84025. * @param postProcesses An array of post processes to be run. (default: null)
  84026. * @returns True if the post processes were able to be run.
  84027. * @hidden
  84028. */
  84029. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84030. /**
  84031. * Manually render a set of post processes to a texture.
  84032. * @param postProcesses An array of post processes to be run.
  84033. * @param targetTexture The target texture to render to.
  84034. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84035. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84036. * @param lodLevel defines which lod of the texture to render to
  84037. */
  84038. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84039. /**
  84040. * Finalize the result of the output of the postprocesses.
  84041. * @param doNotPresent If true the result will not be displayed to the screen.
  84042. * @param targetTexture The target texture to render to.
  84043. * @param faceIndex The index of the face to bind the target texture to.
  84044. * @param postProcesses The array of post processes to render.
  84045. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84046. * @hidden
  84047. */
  84048. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84049. /**
  84050. * Disposes of the post process manager.
  84051. */
  84052. dispose(): void;
  84053. }
  84054. }
  84055. declare module BABYLON {
  84056. /** Interface used by value gradients (color, factor, ...) */
  84057. export interface IValueGradient {
  84058. /**
  84059. * Gets or sets the gradient value (between 0 and 1)
  84060. */
  84061. gradient: number;
  84062. }
  84063. /** Class used to store color4 gradient */
  84064. export class ColorGradient implements IValueGradient {
  84065. /**
  84066. * Gets or sets the gradient value (between 0 and 1)
  84067. */
  84068. gradient: number;
  84069. /**
  84070. * Gets or sets first associated color
  84071. */
  84072. color1: Color4;
  84073. /**
  84074. * Gets or sets second associated color
  84075. */
  84076. color2?: Color4;
  84077. /**
  84078. * Will get a color picked randomly between color1 and color2.
  84079. * If color2 is undefined then color1 will be used
  84080. * @param result defines the target Color4 to store the result in
  84081. */
  84082. getColorToRef(result: Color4): void;
  84083. }
  84084. /** Class used to store color 3 gradient */
  84085. export class Color3Gradient implements IValueGradient {
  84086. /**
  84087. * Gets or sets the gradient value (between 0 and 1)
  84088. */
  84089. gradient: number;
  84090. /**
  84091. * Gets or sets the associated color
  84092. */
  84093. color: Color3;
  84094. }
  84095. /** Class used to store factor gradient */
  84096. export class FactorGradient implements IValueGradient {
  84097. /**
  84098. * Gets or sets the gradient value (between 0 and 1)
  84099. */
  84100. gradient: number;
  84101. /**
  84102. * Gets or sets first associated factor
  84103. */
  84104. factor1: number;
  84105. /**
  84106. * Gets or sets second associated factor
  84107. */
  84108. factor2?: number;
  84109. /**
  84110. * Will get a number picked randomly between factor1 and factor2.
  84111. * If factor2 is undefined then factor1 will be used
  84112. * @returns the picked number
  84113. */
  84114. getFactor(): number;
  84115. }
  84116. /**
  84117. * Helper used to simplify some generic gradient tasks
  84118. */
  84119. export class GradientHelper {
  84120. /**
  84121. * Gets the current gradient from an array of IValueGradient
  84122. * @param ratio defines the current ratio to get
  84123. * @param gradients defines the array of IValueGradient
  84124. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84125. */
  84126. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84127. }
  84128. }
  84129. declare module BABYLON {
  84130. interface ThinEngine {
  84131. /**
  84132. * Creates a dynamic texture
  84133. * @param width defines the width of the texture
  84134. * @param height defines the height of the texture
  84135. * @param generateMipMaps defines if the engine should generate the mip levels
  84136. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84137. * @returns the dynamic texture inside an InternalTexture
  84138. */
  84139. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84140. /**
  84141. * Update the content of a dynamic texture
  84142. * @param texture defines the texture to update
  84143. * @param canvas defines the canvas containing the source
  84144. * @param invertY defines if data must be stored with Y axis inverted
  84145. * @param premulAlpha defines if alpha is stored as premultiplied
  84146. * @param format defines the format of the data
  84147. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84148. */
  84149. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84150. }
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * Helper class used to generate a canvas to manipulate images
  84155. */
  84156. export class CanvasGenerator {
  84157. /**
  84158. * Create a new canvas (or offscreen canvas depending on the context)
  84159. * @param width defines the expected width
  84160. * @param height defines the expected height
  84161. * @return a new canvas or offscreen canvas
  84162. */
  84163. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84164. }
  84165. }
  84166. declare module BABYLON {
  84167. /**
  84168. * A class extending Texture allowing drawing on a texture
  84169. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84170. */
  84171. export class DynamicTexture extends Texture {
  84172. private _generateMipMaps;
  84173. private _canvas;
  84174. private _context;
  84175. private _engine;
  84176. /**
  84177. * Creates a DynamicTexture
  84178. * @param name defines the name of the texture
  84179. * @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
  84180. * @param scene defines the scene where you want the texture
  84181. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84182. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84183. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84184. */
  84185. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84186. /**
  84187. * Get the current class name of the texture useful for serialization or dynamic coding.
  84188. * @returns "DynamicTexture"
  84189. */
  84190. getClassName(): string;
  84191. /**
  84192. * Gets the current state of canRescale
  84193. */
  84194. readonly canRescale: boolean;
  84195. private _recreate;
  84196. /**
  84197. * Scales the texture
  84198. * @param ratio the scale factor to apply to both width and height
  84199. */
  84200. scale(ratio: number): void;
  84201. /**
  84202. * Resizes the texture
  84203. * @param width the new width
  84204. * @param height the new height
  84205. */
  84206. scaleTo(width: number, height: number): void;
  84207. /**
  84208. * Gets the context of the canvas used by the texture
  84209. * @returns the canvas context of the dynamic texture
  84210. */
  84211. getContext(): CanvasRenderingContext2D;
  84212. /**
  84213. * Clears the texture
  84214. */
  84215. clear(): void;
  84216. /**
  84217. * Updates the texture
  84218. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84219. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84220. */
  84221. update(invertY?: boolean, premulAlpha?: boolean): void;
  84222. /**
  84223. * Draws text onto the texture
  84224. * @param text defines the text to be drawn
  84225. * @param x defines the placement of the text from the left
  84226. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84227. * @param font defines the font to be used with font-style, font-size, font-name
  84228. * @param color defines the color used for the text
  84229. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84230. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84231. * @param update defines whether texture is immediately update (default is true)
  84232. */
  84233. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84234. /**
  84235. * Clones the texture
  84236. * @returns the clone of the texture.
  84237. */
  84238. clone(): DynamicTexture;
  84239. /**
  84240. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84241. * @returns a serialized dynamic texture object
  84242. */
  84243. serialize(): any;
  84244. /** @hidden */
  84245. _rebuild(): void;
  84246. }
  84247. }
  84248. declare module BABYLON {
  84249. interface AbstractScene {
  84250. /**
  84251. * The list of procedural textures added to the scene
  84252. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84253. */
  84254. proceduralTextures: Array<ProceduralTexture>;
  84255. }
  84256. /**
  84257. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84258. * in a given scene.
  84259. */
  84260. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84261. /**
  84262. * The component name helpfull to identify the component in the list of scene components.
  84263. */
  84264. readonly name: string;
  84265. /**
  84266. * The scene the component belongs to.
  84267. */
  84268. scene: Scene;
  84269. /**
  84270. * Creates a new instance of the component for the given scene
  84271. * @param scene Defines the scene to register the component in
  84272. */
  84273. constructor(scene: Scene);
  84274. /**
  84275. * Registers the component in a given scene
  84276. */
  84277. register(): void;
  84278. /**
  84279. * Rebuilds the elements related to this component in case of
  84280. * context lost for instance.
  84281. */
  84282. rebuild(): void;
  84283. /**
  84284. * Disposes the component and the associated ressources.
  84285. */
  84286. dispose(): void;
  84287. private _beforeClear;
  84288. }
  84289. }
  84290. declare module BABYLON {
  84291. interface ThinEngine {
  84292. /**
  84293. * Creates a new render target cube texture
  84294. * @param size defines the size of the texture
  84295. * @param options defines the options used to create the texture
  84296. * @returns a new render target cube texture stored in an InternalTexture
  84297. */
  84298. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84299. }
  84300. }
  84301. declare module BABYLON {
  84302. /** @hidden */
  84303. export var proceduralVertexShader: {
  84304. name: string;
  84305. shader: string;
  84306. };
  84307. }
  84308. declare module BABYLON {
  84309. /**
  84310. * 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.
  84311. * This is the base class of any Procedural texture and contains most of the shareable code.
  84312. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84313. */
  84314. export class ProceduralTexture extends Texture {
  84315. isCube: boolean;
  84316. /**
  84317. * Define if the texture is enabled or not (disabled texture will not render)
  84318. */
  84319. isEnabled: boolean;
  84320. /**
  84321. * Define if the texture must be cleared before rendering (default is true)
  84322. */
  84323. autoClear: boolean;
  84324. /**
  84325. * Callback called when the texture is generated
  84326. */
  84327. onGenerated: () => void;
  84328. /**
  84329. * Event raised when the texture is generated
  84330. */
  84331. onGeneratedObservable: Observable<ProceduralTexture>;
  84332. /** @hidden */
  84333. _generateMipMaps: boolean;
  84334. /** @hidden **/
  84335. _effect: Effect;
  84336. /** @hidden */
  84337. _textures: {
  84338. [key: string]: Texture;
  84339. };
  84340. private _size;
  84341. private _currentRefreshId;
  84342. private _refreshRate;
  84343. private _vertexBuffers;
  84344. private _indexBuffer;
  84345. private _uniforms;
  84346. private _samplers;
  84347. private _fragment;
  84348. private _floats;
  84349. private _ints;
  84350. private _floatsArrays;
  84351. private _colors3;
  84352. private _colors4;
  84353. private _vectors2;
  84354. private _vectors3;
  84355. private _matrices;
  84356. private _fallbackTexture;
  84357. private _fallbackTextureUsed;
  84358. private _engine;
  84359. private _cachedDefines;
  84360. private _contentUpdateId;
  84361. private _contentData;
  84362. /**
  84363. * Instantiates a new procedural texture.
  84364. * 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.
  84365. * This is the base class of any Procedural texture and contains most of the shareable code.
  84366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84367. * @param name Define the name of the texture
  84368. * @param size Define the size of the texture to create
  84369. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84370. * @param scene Define the scene the texture belongs to
  84371. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84372. * @param generateMipMaps Define if the texture should creates mip maps or not
  84373. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84374. */
  84375. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84376. /**
  84377. * The effect that is created when initializing the post process.
  84378. * @returns The created effect corresponding the the postprocess.
  84379. */
  84380. getEffect(): Effect;
  84381. /**
  84382. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84383. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84384. */
  84385. getContent(): Nullable<ArrayBufferView>;
  84386. private _createIndexBuffer;
  84387. /** @hidden */
  84388. _rebuild(): void;
  84389. /**
  84390. * Resets the texture in order to recreate its associated resources.
  84391. * This can be called in case of context loss
  84392. */
  84393. reset(): void;
  84394. protected _getDefines(): string;
  84395. /**
  84396. * Is the texture ready to be used ? (rendered at least once)
  84397. * @returns true if ready, otherwise, false.
  84398. */
  84399. isReady(): boolean;
  84400. /**
  84401. * Resets the refresh counter of the texture and start bak from scratch.
  84402. * Could be useful to regenerate the texture if it is setup to render only once.
  84403. */
  84404. resetRefreshCounter(): void;
  84405. /**
  84406. * Set the fragment shader to use in order to render the texture.
  84407. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84408. */
  84409. setFragment(fragment: any): void;
  84410. /**
  84411. * Define the refresh rate of the texture or the rendering frequency.
  84412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84413. */
  84414. refreshRate: number;
  84415. /** @hidden */
  84416. _shouldRender(): boolean;
  84417. /**
  84418. * Get the size the texture is rendering at.
  84419. * @returns the size (texture is always squared)
  84420. */
  84421. getRenderSize(): number;
  84422. /**
  84423. * Resize the texture to new value.
  84424. * @param size Define the new size the texture should have
  84425. * @param generateMipMaps Define whether the new texture should create mip maps
  84426. */
  84427. resize(size: number, generateMipMaps: boolean): void;
  84428. private _checkUniform;
  84429. /**
  84430. * Set a texture in the shader program used to render.
  84431. * @param name Define the name of the uniform samplers as defined in the shader
  84432. * @param texture Define the texture to bind to this sampler
  84433. * @return the texture itself allowing "fluent" like uniform updates
  84434. */
  84435. setTexture(name: string, texture: Texture): ProceduralTexture;
  84436. /**
  84437. * Set a float in the shader.
  84438. * @param name Define the name of the uniform as defined in the shader
  84439. * @param value Define the value to give to the uniform
  84440. * @return the texture itself allowing "fluent" like uniform updates
  84441. */
  84442. setFloat(name: string, value: number): ProceduralTexture;
  84443. /**
  84444. * Set a int in the shader.
  84445. * @param name Define the name of the uniform as defined in the shader
  84446. * @param value Define the value to give to the uniform
  84447. * @return the texture itself allowing "fluent" like uniform updates
  84448. */
  84449. setInt(name: string, value: number): ProceduralTexture;
  84450. /**
  84451. * Set an array of floats in the shader.
  84452. * @param name Define the name of the uniform as defined in the shader
  84453. * @param value Define the value to give to the uniform
  84454. * @return the texture itself allowing "fluent" like uniform updates
  84455. */
  84456. setFloats(name: string, value: number[]): ProceduralTexture;
  84457. /**
  84458. * Set a vec3 in the shader from a Color3.
  84459. * @param name Define the name of the uniform as defined in the shader
  84460. * @param value Define the value to give to the uniform
  84461. * @return the texture itself allowing "fluent" like uniform updates
  84462. */
  84463. setColor3(name: string, value: Color3): ProceduralTexture;
  84464. /**
  84465. * Set a vec4 in the shader from a Color4.
  84466. * @param name Define the name of the uniform as defined in the shader
  84467. * @param value Define the value to give to the uniform
  84468. * @return the texture itself allowing "fluent" like uniform updates
  84469. */
  84470. setColor4(name: string, value: Color4): ProceduralTexture;
  84471. /**
  84472. * Set a vec2 in the shader from a Vector2.
  84473. * @param name Define the name of the uniform as defined in the shader
  84474. * @param value Define the value to give to the uniform
  84475. * @return the texture itself allowing "fluent" like uniform updates
  84476. */
  84477. setVector2(name: string, value: Vector2): ProceduralTexture;
  84478. /**
  84479. * Set a vec3 in the shader from a Vector3.
  84480. * @param name Define the name of the uniform as defined in the shader
  84481. * @param value Define the value to give to the uniform
  84482. * @return the texture itself allowing "fluent" like uniform updates
  84483. */
  84484. setVector3(name: string, value: Vector3): ProceduralTexture;
  84485. /**
  84486. * Set a mat4 in the shader from a MAtrix.
  84487. * @param name Define the name of the uniform as defined in the shader
  84488. * @param value Define the value to give to the uniform
  84489. * @return the texture itself allowing "fluent" like uniform updates
  84490. */
  84491. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84492. /**
  84493. * Render the texture to its associated render target.
  84494. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84495. */
  84496. render(useCameraPostProcess?: boolean): void;
  84497. /**
  84498. * Clone the texture.
  84499. * @returns the cloned texture
  84500. */
  84501. clone(): ProceduralTexture;
  84502. /**
  84503. * Dispose the texture and release its asoociated resources.
  84504. */
  84505. dispose(): void;
  84506. }
  84507. }
  84508. declare module BABYLON {
  84509. /**
  84510. * This represents the base class for particle system in Babylon.
  84511. * 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.
  84512. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84513. * @example https://doc.babylonjs.com/babylon101/particles
  84514. */
  84515. export class BaseParticleSystem {
  84516. /**
  84517. * Source color is added to the destination color without alpha affecting the result
  84518. */
  84519. static BLENDMODE_ONEONE: number;
  84520. /**
  84521. * Blend current color and particle color using particle’s alpha
  84522. */
  84523. static BLENDMODE_STANDARD: number;
  84524. /**
  84525. * Add current color and particle color multiplied by particle’s alpha
  84526. */
  84527. static BLENDMODE_ADD: number;
  84528. /**
  84529. * Multiply current color with particle color
  84530. */
  84531. static BLENDMODE_MULTIPLY: number;
  84532. /**
  84533. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84534. */
  84535. static BLENDMODE_MULTIPLYADD: number;
  84536. /**
  84537. * List of animations used by the particle system.
  84538. */
  84539. animations: Animation[];
  84540. /**
  84541. * The id of the Particle system.
  84542. */
  84543. id: string;
  84544. /**
  84545. * The friendly name of the Particle system.
  84546. */
  84547. name: string;
  84548. /**
  84549. * The rendering group used by the Particle system to chose when to render.
  84550. */
  84551. renderingGroupId: number;
  84552. /**
  84553. * The emitter represents the Mesh or position we are attaching the particle system to.
  84554. */
  84555. emitter: Nullable<AbstractMesh | Vector3>;
  84556. /**
  84557. * The maximum number of particles to emit per frame
  84558. */
  84559. emitRate: number;
  84560. /**
  84561. * If you want to launch only a few particles at once, that can be done, as well.
  84562. */
  84563. manualEmitCount: number;
  84564. /**
  84565. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84566. */
  84567. updateSpeed: number;
  84568. /**
  84569. * The amount of time the particle system is running (depends of the overall update speed).
  84570. */
  84571. targetStopDuration: number;
  84572. /**
  84573. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84574. */
  84575. disposeOnStop: boolean;
  84576. /**
  84577. * Minimum power of emitting particles.
  84578. */
  84579. minEmitPower: number;
  84580. /**
  84581. * Maximum power of emitting particles.
  84582. */
  84583. maxEmitPower: number;
  84584. /**
  84585. * Minimum life time of emitting particles.
  84586. */
  84587. minLifeTime: number;
  84588. /**
  84589. * Maximum life time of emitting particles.
  84590. */
  84591. maxLifeTime: number;
  84592. /**
  84593. * Minimum Size of emitting particles.
  84594. */
  84595. minSize: number;
  84596. /**
  84597. * Maximum Size of emitting particles.
  84598. */
  84599. maxSize: number;
  84600. /**
  84601. * Minimum scale of emitting particles on X axis.
  84602. */
  84603. minScaleX: number;
  84604. /**
  84605. * Maximum scale of emitting particles on X axis.
  84606. */
  84607. maxScaleX: number;
  84608. /**
  84609. * Minimum scale of emitting particles on Y axis.
  84610. */
  84611. minScaleY: number;
  84612. /**
  84613. * Maximum scale of emitting particles on Y axis.
  84614. */
  84615. maxScaleY: number;
  84616. /**
  84617. * Gets or sets the minimal initial rotation in radians.
  84618. */
  84619. minInitialRotation: number;
  84620. /**
  84621. * Gets or sets the maximal initial rotation in radians.
  84622. */
  84623. maxInitialRotation: number;
  84624. /**
  84625. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84626. */
  84627. minAngularSpeed: number;
  84628. /**
  84629. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84630. */
  84631. maxAngularSpeed: number;
  84632. /**
  84633. * The texture used to render each particle. (this can be a spritesheet)
  84634. */
  84635. particleTexture: Nullable<Texture>;
  84636. /**
  84637. * The layer mask we are rendering the particles through.
  84638. */
  84639. layerMask: number;
  84640. /**
  84641. * This can help using your own shader to render the particle system.
  84642. * The according effect will be created
  84643. */
  84644. customShader: any;
  84645. /**
  84646. * By default particle system starts as soon as they are created. This prevents the
  84647. * automatic start to happen and let you decide when to start emitting particles.
  84648. */
  84649. preventAutoStart: boolean;
  84650. private _noiseTexture;
  84651. /**
  84652. * Gets or sets a texture used to add random noise to particle positions
  84653. */
  84654. noiseTexture: Nullable<ProceduralTexture>;
  84655. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84656. noiseStrength: Vector3;
  84657. /**
  84658. * Callback triggered when the particle animation is ending.
  84659. */
  84660. onAnimationEnd: Nullable<() => void>;
  84661. /**
  84662. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84663. */
  84664. blendMode: number;
  84665. /**
  84666. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84667. * to override the particles.
  84668. */
  84669. forceDepthWrite: boolean;
  84670. /** 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 */
  84671. preWarmCycles: number;
  84672. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84673. preWarmStepOffset: number;
  84674. /**
  84675. * 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)
  84676. */
  84677. spriteCellChangeSpeed: number;
  84678. /**
  84679. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84680. */
  84681. startSpriteCellID: number;
  84682. /**
  84683. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84684. */
  84685. endSpriteCellID: number;
  84686. /**
  84687. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84688. */
  84689. spriteCellWidth: number;
  84690. /**
  84691. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84692. */
  84693. spriteCellHeight: number;
  84694. /**
  84695. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84696. */
  84697. spriteRandomStartCell: boolean;
  84698. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84699. translationPivot: Vector2;
  84700. /** @hidden */
  84701. protected _isAnimationSheetEnabled: boolean;
  84702. /**
  84703. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84704. */
  84705. beginAnimationOnStart: boolean;
  84706. /**
  84707. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84708. */
  84709. beginAnimationFrom: number;
  84710. /**
  84711. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84712. */
  84713. beginAnimationTo: number;
  84714. /**
  84715. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84716. */
  84717. beginAnimationLoop: boolean;
  84718. /**
  84719. * Gets or sets a world offset applied to all particles
  84720. */
  84721. worldOffset: Vector3;
  84722. /**
  84723. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84724. */
  84725. isAnimationSheetEnabled: boolean;
  84726. /**
  84727. * Get hosting scene
  84728. * @returns the scene
  84729. */
  84730. getScene(): Scene;
  84731. /**
  84732. * You can use gravity if you want to give an orientation to your particles.
  84733. */
  84734. gravity: Vector3;
  84735. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84736. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84737. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84738. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84739. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84740. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84741. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84742. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84743. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84744. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84745. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84746. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84747. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84748. /**
  84749. * Defines the delay in milliseconds before starting the system (0 by default)
  84750. */
  84751. startDelay: number;
  84752. /**
  84753. * Gets the current list of drag gradients.
  84754. * You must use addDragGradient and removeDragGradient to udpate this list
  84755. * @returns the list of drag gradients
  84756. */
  84757. getDragGradients(): Nullable<Array<FactorGradient>>;
  84758. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84759. limitVelocityDamping: number;
  84760. /**
  84761. * Gets the current list of limit velocity gradients.
  84762. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84763. * @returns the list of limit velocity gradients
  84764. */
  84765. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84766. /**
  84767. * Gets the current list of color gradients.
  84768. * You must use addColorGradient and removeColorGradient to udpate this list
  84769. * @returns the list of color gradients
  84770. */
  84771. getColorGradients(): Nullable<Array<ColorGradient>>;
  84772. /**
  84773. * Gets the current list of size gradients.
  84774. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84775. * @returns the list of size gradients
  84776. */
  84777. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84778. /**
  84779. * Gets the current list of color remap gradients.
  84780. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84781. * @returns the list of color remap gradients
  84782. */
  84783. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84784. /**
  84785. * Gets the current list of alpha remap gradients.
  84786. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84787. * @returns the list of alpha remap gradients
  84788. */
  84789. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84790. /**
  84791. * Gets the current list of life time gradients.
  84792. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84793. * @returns the list of life time gradients
  84794. */
  84795. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84796. /**
  84797. * Gets the current list of angular speed gradients.
  84798. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84799. * @returns the list of angular speed gradients
  84800. */
  84801. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84802. /**
  84803. * Gets the current list of velocity gradients.
  84804. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84805. * @returns the list of velocity gradients
  84806. */
  84807. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84808. /**
  84809. * Gets the current list of start size gradients.
  84810. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84811. * @returns the list of start size gradients
  84812. */
  84813. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84814. /**
  84815. * Gets the current list of emit rate gradients.
  84816. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84817. * @returns the list of emit rate gradients
  84818. */
  84819. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84820. /**
  84821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84822. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84823. */
  84824. direction1: Vector3;
  84825. /**
  84826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84827. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84828. */
  84829. direction2: Vector3;
  84830. /**
  84831. * 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.
  84832. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84833. */
  84834. minEmitBox: Vector3;
  84835. /**
  84836. * 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.
  84837. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84838. */
  84839. maxEmitBox: Vector3;
  84840. /**
  84841. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84842. */
  84843. color1: Color4;
  84844. /**
  84845. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84846. */
  84847. color2: Color4;
  84848. /**
  84849. * Color the particle will have at the end of its lifetime
  84850. */
  84851. colorDead: Color4;
  84852. /**
  84853. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84854. */
  84855. textureMask: Color4;
  84856. /**
  84857. * The particle emitter type defines the emitter used by the particle system.
  84858. * It can be for example box, sphere, or cone...
  84859. */
  84860. particleEmitterType: IParticleEmitterType;
  84861. /** @hidden */
  84862. _isSubEmitter: boolean;
  84863. /**
  84864. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84865. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84866. */
  84867. billboardMode: number;
  84868. protected _isBillboardBased: boolean;
  84869. /**
  84870. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84871. */
  84872. isBillboardBased: boolean;
  84873. /**
  84874. * The scene the particle system belongs to.
  84875. */
  84876. protected _scene: Scene;
  84877. /**
  84878. * Local cache of defines for image processing.
  84879. */
  84880. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84881. /**
  84882. * Default configuration related to image processing available in the standard Material.
  84883. */
  84884. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84885. /**
  84886. * Gets the image processing configuration used either in this material.
  84887. */
  84888. /**
  84889. * Sets the Default image processing configuration used either in the this material.
  84890. *
  84891. * If sets to null, the scene one is in use.
  84892. */
  84893. imageProcessingConfiguration: ImageProcessingConfiguration;
  84894. /**
  84895. * Attaches a new image processing configuration to the Standard Material.
  84896. * @param configuration
  84897. */
  84898. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84899. /** @hidden */
  84900. protected _reset(): void;
  84901. /** @hidden */
  84902. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84903. /**
  84904. * Instantiates a particle system.
  84905. * 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.
  84906. * @param name The name of the particle system
  84907. */
  84908. constructor(name: string);
  84909. /**
  84910. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84911. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84912. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84913. * @returns the emitter
  84914. */
  84915. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84916. /**
  84917. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84918. * @param radius The radius of the hemisphere to emit from
  84919. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84920. * @returns the emitter
  84921. */
  84922. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84923. /**
  84924. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84925. * @param radius The radius of the sphere to emit from
  84926. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84927. * @returns the emitter
  84928. */
  84929. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84930. /**
  84931. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84932. * @param radius The radius of the sphere to emit from
  84933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84935. * @returns the emitter
  84936. */
  84937. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84938. /**
  84939. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84940. * @param radius The radius of the emission cylinder
  84941. * @param height The height of the emission cylinder
  84942. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84943. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84944. * @returns the emitter
  84945. */
  84946. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84947. /**
  84948. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84949. * @param radius The radius of the cylinder to emit from
  84950. * @param height The height of the emission cylinder
  84951. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84954. * @returns the emitter
  84955. */
  84956. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84957. /**
  84958. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84959. * @param radius The radius of the cone to emit from
  84960. * @param angle The base angle of the cone
  84961. * @returns the emitter
  84962. */
  84963. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84964. /**
  84965. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84966. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84967. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84968. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84969. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84970. * @returns the emitter
  84971. */
  84972. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84973. }
  84974. }
  84975. declare module BABYLON {
  84976. /**
  84977. * Type of sub emitter
  84978. */
  84979. export enum SubEmitterType {
  84980. /**
  84981. * Attached to the particle over it's lifetime
  84982. */
  84983. ATTACHED = 0,
  84984. /**
  84985. * Created when the particle dies
  84986. */
  84987. END = 1
  84988. }
  84989. /**
  84990. * Sub emitter class used to emit particles from an existing particle
  84991. */
  84992. export class SubEmitter {
  84993. /**
  84994. * the particle system to be used by the sub emitter
  84995. */
  84996. particleSystem: ParticleSystem;
  84997. /**
  84998. * Type of the submitter (Default: END)
  84999. */
  85000. type: SubEmitterType;
  85001. /**
  85002. * 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)
  85003. * Note: This only is supported when using an emitter of type Mesh
  85004. */
  85005. inheritDirection: boolean;
  85006. /**
  85007. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85008. */
  85009. inheritedVelocityAmount: number;
  85010. /**
  85011. * Creates a sub emitter
  85012. * @param particleSystem the particle system to be used by the sub emitter
  85013. */
  85014. constructor(
  85015. /**
  85016. * the particle system to be used by the sub emitter
  85017. */
  85018. particleSystem: ParticleSystem);
  85019. /**
  85020. * Clones the sub emitter
  85021. * @returns the cloned sub emitter
  85022. */
  85023. clone(): SubEmitter;
  85024. /**
  85025. * Serialize current object to a JSON object
  85026. * @returns the serialized object
  85027. */
  85028. serialize(): any;
  85029. /** @hidden */
  85030. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85031. /**
  85032. * Creates a new SubEmitter from a serialized JSON version
  85033. * @param serializationObject defines the JSON object to read from
  85034. * @param scene defines the hosting scene
  85035. * @param rootUrl defines the rootUrl for data loading
  85036. * @returns a new SubEmitter
  85037. */
  85038. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85039. /** Release associated resources */
  85040. dispose(): void;
  85041. }
  85042. }
  85043. declare module BABYLON {
  85044. /** @hidden */
  85045. export var clipPlaneFragmentDeclaration: {
  85046. name: string;
  85047. shader: string;
  85048. };
  85049. }
  85050. declare module BABYLON {
  85051. /** @hidden */
  85052. export var imageProcessingDeclaration: {
  85053. name: string;
  85054. shader: string;
  85055. };
  85056. }
  85057. declare module BABYLON {
  85058. /** @hidden */
  85059. export var imageProcessingFunctions: {
  85060. name: string;
  85061. shader: string;
  85062. };
  85063. }
  85064. declare module BABYLON {
  85065. /** @hidden */
  85066. export var clipPlaneFragment: {
  85067. name: string;
  85068. shader: string;
  85069. };
  85070. }
  85071. declare module BABYLON {
  85072. /** @hidden */
  85073. export var particlesPixelShader: {
  85074. name: string;
  85075. shader: string;
  85076. };
  85077. }
  85078. declare module BABYLON {
  85079. /** @hidden */
  85080. export var clipPlaneVertexDeclaration: {
  85081. name: string;
  85082. shader: string;
  85083. };
  85084. }
  85085. declare module BABYLON {
  85086. /** @hidden */
  85087. export var clipPlaneVertex: {
  85088. name: string;
  85089. shader: string;
  85090. };
  85091. }
  85092. declare module BABYLON {
  85093. /** @hidden */
  85094. export var particlesVertexShader: {
  85095. name: string;
  85096. shader: string;
  85097. };
  85098. }
  85099. declare module BABYLON {
  85100. /**
  85101. * This represents a particle system in Babylon.
  85102. * 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.
  85103. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85104. * @example https://doc.babylonjs.com/babylon101/particles
  85105. */
  85106. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85107. /**
  85108. * Billboard mode will only apply to Y axis
  85109. */
  85110. static readonly BILLBOARDMODE_Y: number;
  85111. /**
  85112. * Billboard mode will apply to all axes
  85113. */
  85114. static readonly BILLBOARDMODE_ALL: number;
  85115. /**
  85116. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85117. */
  85118. static readonly BILLBOARDMODE_STRETCHED: number;
  85119. /**
  85120. * This function can be defined to provide custom update for active particles.
  85121. * This function will be called instead of regular update (age, position, color, etc.).
  85122. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85123. */
  85124. updateFunction: (particles: Particle[]) => void;
  85125. private _emitterWorldMatrix;
  85126. /**
  85127. * This function can be defined to specify initial direction for every new particle.
  85128. * It by default use the emitterType defined function
  85129. */
  85130. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85131. /**
  85132. * This function can be defined to specify initial position for every new particle.
  85133. * It by default use the emitterType defined function
  85134. */
  85135. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85136. /**
  85137. * @hidden
  85138. */
  85139. _inheritedVelocityOffset: Vector3;
  85140. /**
  85141. * An event triggered when the system is disposed
  85142. */
  85143. onDisposeObservable: Observable<ParticleSystem>;
  85144. private _onDisposeObserver;
  85145. /**
  85146. * Sets a callback that will be triggered when the system is disposed
  85147. */
  85148. onDispose: () => void;
  85149. private _particles;
  85150. private _epsilon;
  85151. private _capacity;
  85152. private _stockParticles;
  85153. private _newPartsExcess;
  85154. private _vertexData;
  85155. private _vertexBuffer;
  85156. private _vertexBuffers;
  85157. private _spriteBuffer;
  85158. private _indexBuffer;
  85159. private _effect;
  85160. private _customEffect;
  85161. private _cachedDefines;
  85162. private _scaledColorStep;
  85163. private _colorDiff;
  85164. private _scaledDirection;
  85165. private _scaledGravity;
  85166. private _currentRenderId;
  85167. private _alive;
  85168. private _useInstancing;
  85169. private _started;
  85170. private _stopped;
  85171. private _actualFrame;
  85172. private _scaledUpdateSpeed;
  85173. private _vertexBufferSize;
  85174. /** @hidden */
  85175. _currentEmitRateGradient: Nullable<FactorGradient>;
  85176. /** @hidden */
  85177. _currentEmitRate1: number;
  85178. /** @hidden */
  85179. _currentEmitRate2: number;
  85180. /** @hidden */
  85181. _currentStartSizeGradient: Nullable<FactorGradient>;
  85182. /** @hidden */
  85183. _currentStartSize1: number;
  85184. /** @hidden */
  85185. _currentStartSize2: number;
  85186. private readonly _rawTextureWidth;
  85187. private _rampGradientsTexture;
  85188. private _useRampGradients;
  85189. /** Gets or sets a boolean indicating that ramp gradients must be used
  85190. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85191. */
  85192. useRampGradients: boolean;
  85193. /**
  85194. * 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.
  85195. * 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: [])
  85196. */
  85197. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85198. private _subEmitters;
  85199. /**
  85200. * @hidden
  85201. * If the particle systems emitter should be disposed when the particle system is disposed
  85202. */
  85203. _disposeEmitterOnDispose: boolean;
  85204. /**
  85205. * The current active Sub-systems, this property is used by the root particle system only.
  85206. */
  85207. activeSubSystems: Array<ParticleSystem>;
  85208. private _rootParticleSystem;
  85209. /**
  85210. * Gets the current list of active particles
  85211. */
  85212. readonly particles: Particle[];
  85213. /**
  85214. * Returns the string "ParticleSystem"
  85215. * @returns a string containing the class name
  85216. */
  85217. getClassName(): string;
  85218. /**
  85219. * Instantiates a particle system.
  85220. * 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.
  85221. * @param name The name of the particle system
  85222. * @param capacity The max number of particles alive at the same time
  85223. * @param scene The scene the particle system belongs to
  85224. * @param customEffect a custom effect used to change the way particles are rendered by default
  85225. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85226. * @param epsilon Offset used to render the particles
  85227. */
  85228. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85229. private _addFactorGradient;
  85230. private _removeFactorGradient;
  85231. /**
  85232. * Adds a new life time gradient
  85233. * @param gradient defines the gradient to use (between 0 and 1)
  85234. * @param factor defines the life time factor to affect to the specified gradient
  85235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85236. * @returns the current particle system
  85237. */
  85238. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85239. /**
  85240. * Remove a specific life time gradient
  85241. * @param gradient defines the gradient to remove
  85242. * @returns the current particle system
  85243. */
  85244. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85245. /**
  85246. * Adds a new size gradient
  85247. * @param gradient defines the gradient to use (between 0 and 1)
  85248. * @param factor defines the size factor to affect to the specified gradient
  85249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85250. * @returns the current particle system
  85251. */
  85252. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85253. /**
  85254. * Remove a specific size gradient
  85255. * @param gradient defines the gradient to remove
  85256. * @returns the current particle system
  85257. */
  85258. removeSizeGradient(gradient: number): IParticleSystem;
  85259. /**
  85260. * Adds a new color remap gradient
  85261. * @param gradient defines the gradient to use (between 0 and 1)
  85262. * @param min defines the color remap minimal range
  85263. * @param max defines the color remap maximal range
  85264. * @returns the current particle system
  85265. */
  85266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85267. /**
  85268. * Remove a specific color remap gradient
  85269. * @param gradient defines the gradient to remove
  85270. * @returns the current particle system
  85271. */
  85272. removeColorRemapGradient(gradient: number): IParticleSystem;
  85273. /**
  85274. * Adds a new alpha remap gradient
  85275. * @param gradient defines the gradient to use (between 0 and 1)
  85276. * @param min defines the alpha remap minimal range
  85277. * @param max defines the alpha remap maximal range
  85278. * @returns the current particle system
  85279. */
  85280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85281. /**
  85282. * Remove a specific alpha remap gradient
  85283. * @param gradient defines the gradient to remove
  85284. * @returns the current particle system
  85285. */
  85286. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85287. /**
  85288. * Adds a new angular speed gradient
  85289. * @param gradient defines the gradient to use (between 0 and 1)
  85290. * @param factor defines the angular speed to affect to the specified gradient
  85291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85292. * @returns the current particle system
  85293. */
  85294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85295. /**
  85296. * Remove a specific angular speed gradient
  85297. * @param gradient defines the gradient to remove
  85298. * @returns the current particle system
  85299. */
  85300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85301. /**
  85302. * Adds a new velocity gradient
  85303. * @param gradient defines the gradient to use (between 0 and 1)
  85304. * @param factor defines the velocity to affect to the specified gradient
  85305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85306. * @returns the current particle system
  85307. */
  85308. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85309. /**
  85310. * Remove a specific velocity gradient
  85311. * @param gradient defines the gradient to remove
  85312. * @returns the current particle system
  85313. */
  85314. removeVelocityGradient(gradient: number): IParticleSystem;
  85315. /**
  85316. * Adds a new limit velocity gradient
  85317. * @param gradient defines the gradient to use (between 0 and 1)
  85318. * @param factor defines the limit velocity value to affect to the specified gradient
  85319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85320. * @returns the current particle system
  85321. */
  85322. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85323. /**
  85324. * Remove a specific limit velocity gradient
  85325. * @param gradient defines the gradient to remove
  85326. * @returns the current particle system
  85327. */
  85328. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85329. /**
  85330. * Adds a new drag gradient
  85331. * @param gradient defines the gradient to use (between 0 and 1)
  85332. * @param factor defines the drag value to affect to the specified gradient
  85333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85334. * @returns the current particle system
  85335. */
  85336. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85337. /**
  85338. * Remove a specific drag gradient
  85339. * @param gradient defines the gradient to remove
  85340. * @returns the current particle system
  85341. */
  85342. removeDragGradient(gradient: number): IParticleSystem;
  85343. /**
  85344. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85345. * @param gradient defines the gradient to use (between 0 and 1)
  85346. * @param factor defines the emit rate value to affect to the specified gradient
  85347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85348. * @returns the current particle system
  85349. */
  85350. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85351. /**
  85352. * Remove a specific emit rate gradient
  85353. * @param gradient defines the gradient to remove
  85354. * @returns the current particle system
  85355. */
  85356. removeEmitRateGradient(gradient: number): IParticleSystem;
  85357. /**
  85358. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85359. * @param gradient defines the gradient to use (between 0 and 1)
  85360. * @param factor defines the start size value to affect to the specified gradient
  85361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85362. * @returns the current particle system
  85363. */
  85364. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85365. /**
  85366. * Remove a specific start size gradient
  85367. * @param gradient defines the gradient to remove
  85368. * @returns the current particle system
  85369. */
  85370. removeStartSizeGradient(gradient: number): IParticleSystem;
  85371. private _createRampGradientTexture;
  85372. /**
  85373. * Gets the current list of ramp gradients.
  85374. * You must use addRampGradient and removeRampGradient to udpate this list
  85375. * @returns the list of ramp gradients
  85376. */
  85377. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85378. /**
  85379. * Adds a new ramp gradient used to remap particle colors
  85380. * @param gradient defines the gradient to use (between 0 and 1)
  85381. * @param color defines the color to affect to the specified gradient
  85382. * @returns the current particle system
  85383. */
  85384. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85385. /**
  85386. * Remove a specific ramp gradient
  85387. * @param gradient defines the gradient to remove
  85388. * @returns the current particle system
  85389. */
  85390. removeRampGradient(gradient: number): ParticleSystem;
  85391. /**
  85392. * Adds a new color gradient
  85393. * @param gradient defines the gradient to use (between 0 and 1)
  85394. * @param color1 defines the color to affect to the specified gradient
  85395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85396. * @returns this particle system
  85397. */
  85398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85399. /**
  85400. * Remove a specific color gradient
  85401. * @param gradient defines the gradient to remove
  85402. * @returns this particle system
  85403. */
  85404. removeColorGradient(gradient: number): IParticleSystem;
  85405. private _fetchR;
  85406. protected _reset(): void;
  85407. private _resetEffect;
  85408. private _createVertexBuffers;
  85409. private _createIndexBuffer;
  85410. /**
  85411. * Gets the maximum number of particles active at the same time.
  85412. * @returns The max number of active particles.
  85413. */
  85414. getCapacity(): number;
  85415. /**
  85416. * Gets whether there are still active particles in the system.
  85417. * @returns True if it is alive, otherwise false.
  85418. */
  85419. isAlive(): boolean;
  85420. /**
  85421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85422. * @returns True if it has been started, otherwise false.
  85423. */
  85424. isStarted(): boolean;
  85425. private _prepareSubEmitterInternalArray;
  85426. /**
  85427. * Starts the particle system and begins to emit
  85428. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85429. */
  85430. start(delay?: number): void;
  85431. /**
  85432. * Stops the particle system.
  85433. * @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.
  85434. */
  85435. stop(stopSubEmitters?: boolean): void;
  85436. /**
  85437. * Remove all active particles
  85438. */
  85439. reset(): void;
  85440. /**
  85441. * @hidden (for internal use only)
  85442. */
  85443. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85444. /**
  85445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85446. * Its lifetime will start back at 0.
  85447. */
  85448. recycleParticle: (particle: Particle) => void;
  85449. private _stopSubEmitters;
  85450. private _createParticle;
  85451. private _removeFromRoot;
  85452. private _emitFromParticle;
  85453. private _update;
  85454. /** @hidden */
  85455. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85456. /** @hidden */
  85457. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85458. /** @hidden */
  85459. private _getEffect;
  85460. /**
  85461. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85462. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85463. */
  85464. animate(preWarmOnly?: boolean): void;
  85465. private _appendParticleVertices;
  85466. /**
  85467. * Rebuilds the particle system.
  85468. */
  85469. rebuild(): void;
  85470. /**
  85471. * Is this system ready to be used/rendered
  85472. * @return true if the system is ready
  85473. */
  85474. isReady(): boolean;
  85475. private _render;
  85476. /**
  85477. * Renders the particle system in its current state.
  85478. * @returns the current number of particles
  85479. */
  85480. render(): number;
  85481. /**
  85482. * Disposes the particle system and free the associated resources
  85483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85484. */
  85485. dispose(disposeTexture?: boolean): void;
  85486. /**
  85487. * Clones the particle system.
  85488. * @param name The name of the cloned object
  85489. * @param newEmitter The new emitter to use
  85490. * @returns the cloned particle system
  85491. */
  85492. clone(name: string, newEmitter: any): ParticleSystem;
  85493. /**
  85494. * Serializes the particle system to a JSON object.
  85495. * @returns the JSON object
  85496. */
  85497. serialize(): any;
  85498. /** @hidden */
  85499. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85500. /** @hidden */
  85501. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85502. /**
  85503. * Parses a JSON object to create a particle system.
  85504. * @param parsedParticleSystem The JSON object to parse
  85505. * @param scene The scene to create the particle system in
  85506. * @param rootUrl The root url to use to load external dependencies like texture
  85507. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85508. * @returns the Parsed particle system
  85509. */
  85510. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85511. }
  85512. }
  85513. declare module BABYLON {
  85514. /**
  85515. * A particle represents one of the element emitted by a particle system.
  85516. * This is mainly define by its coordinates, direction, velocity and age.
  85517. */
  85518. export class Particle {
  85519. /**
  85520. * The particle system the particle belongs to.
  85521. */
  85522. particleSystem: ParticleSystem;
  85523. private static _Count;
  85524. /**
  85525. * Unique ID of the particle
  85526. */
  85527. id: number;
  85528. /**
  85529. * The world position of the particle in the scene.
  85530. */
  85531. position: Vector3;
  85532. /**
  85533. * The world direction of the particle in the scene.
  85534. */
  85535. direction: Vector3;
  85536. /**
  85537. * The color of the particle.
  85538. */
  85539. color: Color4;
  85540. /**
  85541. * The color change of the particle per step.
  85542. */
  85543. colorStep: Color4;
  85544. /**
  85545. * Defines how long will the life of the particle be.
  85546. */
  85547. lifeTime: number;
  85548. /**
  85549. * The current age of the particle.
  85550. */
  85551. age: number;
  85552. /**
  85553. * The current size of the particle.
  85554. */
  85555. size: number;
  85556. /**
  85557. * The current scale of the particle.
  85558. */
  85559. scale: Vector2;
  85560. /**
  85561. * The current angle of the particle.
  85562. */
  85563. angle: number;
  85564. /**
  85565. * Defines how fast is the angle changing.
  85566. */
  85567. angularSpeed: number;
  85568. /**
  85569. * Defines the cell index used by the particle to be rendered from a sprite.
  85570. */
  85571. cellIndex: number;
  85572. /**
  85573. * The information required to support color remapping
  85574. */
  85575. remapData: Vector4;
  85576. /** @hidden */
  85577. _randomCellOffset?: number;
  85578. /** @hidden */
  85579. _initialDirection: Nullable<Vector3>;
  85580. /** @hidden */
  85581. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85582. /** @hidden */
  85583. _initialStartSpriteCellID: number;
  85584. /** @hidden */
  85585. _initialEndSpriteCellID: number;
  85586. /** @hidden */
  85587. _currentColorGradient: Nullable<ColorGradient>;
  85588. /** @hidden */
  85589. _currentColor1: Color4;
  85590. /** @hidden */
  85591. _currentColor2: Color4;
  85592. /** @hidden */
  85593. _currentSizeGradient: Nullable<FactorGradient>;
  85594. /** @hidden */
  85595. _currentSize1: number;
  85596. /** @hidden */
  85597. _currentSize2: number;
  85598. /** @hidden */
  85599. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85600. /** @hidden */
  85601. _currentAngularSpeed1: number;
  85602. /** @hidden */
  85603. _currentAngularSpeed2: number;
  85604. /** @hidden */
  85605. _currentVelocityGradient: Nullable<FactorGradient>;
  85606. /** @hidden */
  85607. _currentVelocity1: number;
  85608. /** @hidden */
  85609. _currentVelocity2: number;
  85610. /** @hidden */
  85611. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85612. /** @hidden */
  85613. _currentLimitVelocity1: number;
  85614. /** @hidden */
  85615. _currentLimitVelocity2: number;
  85616. /** @hidden */
  85617. _currentDragGradient: Nullable<FactorGradient>;
  85618. /** @hidden */
  85619. _currentDrag1: number;
  85620. /** @hidden */
  85621. _currentDrag2: number;
  85622. /** @hidden */
  85623. _randomNoiseCoordinates1: Vector3;
  85624. /** @hidden */
  85625. _randomNoiseCoordinates2: Vector3;
  85626. /**
  85627. * Creates a new instance Particle
  85628. * @param particleSystem the particle system the particle belongs to
  85629. */
  85630. constructor(
  85631. /**
  85632. * The particle system the particle belongs to.
  85633. */
  85634. particleSystem: ParticleSystem);
  85635. private updateCellInfoFromSystem;
  85636. /**
  85637. * Defines how the sprite cell index is updated for the particle
  85638. */
  85639. updateCellIndex(): void;
  85640. /** @hidden */
  85641. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85642. /** @hidden */
  85643. _inheritParticleInfoToSubEmitters(): void;
  85644. /** @hidden */
  85645. _reset(): void;
  85646. /**
  85647. * Copy the properties of particle to another one.
  85648. * @param other the particle to copy the information to.
  85649. */
  85650. copyTo(other: Particle): void;
  85651. }
  85652. }
  85653. declare module BABYLON {
  85654. /**
  85655. * Particle emitter represents a volume emitting particles.
  85656. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85657. */
  85658. export interface IParticleEmitterType {
  85659. /**
  85660. * Called by the particle System when the direction is computed for the created particle.
  85661. * @param worldMatrix is the world matrix of the particle system
  85662. * @param directionToUpdate is the direction vector to update with the result
  85663. * @param particle is the particle we are computed the direction for
  85664. */
  85665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85666. /**
  85667. * Called by the particle System when the position is computed for the created particle.
  85668. * @param worldMatrix is the world matrix of the particle system
  85669. * @param positionToUpdate is the position vector to update with the result
  85670. * @param particle is the particle we are computed the position for
  85671. */
  85672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85673. /**
  85674. * Clones the current emitter and returns a copy of it
  85675. * @returns the new emitter
  85676. */
  85677. clone(): IParticleEmitterType;
  85678. /**
  85679. * Called by the GPUParticleSystem to setup the update shader
  85680. * @param effect defines the update shader
  85681. */
  85682. applyToShader(effect: Effect): void;
  85683. /**
  85684. * Returns a string to use to update the GPU particles update shader
  85685. * @returns the effect defines string
  85686. */
  85687. getEffectDefines(): string;
  85688. /**
  85689. * Returns a string representing the class name
  85690. * @returns a string containing the class name
  85691. */
  85692. getClassName(): string;
  85693. /**
  85694. * Serializes the particle system to a JSON object.
  85695. * @returns the JSON object
  85696. */
  85697. serialize(): any;
  85698. /**
  85699. * Parse properties from a JSON object
  85700. * @param serializationObject defines the JSON object
  85701. */
  85702. parse(serializationObject: any): void;
  85703. }
  85704. }
  85705. declare module BABYLON {
  85706. /**
  85707. * Particle emitter emitting particles from the inside of a box.
  85708. * It emits the particles randomly between 2 given directions.
  85709. */
  85710. export class BoxParticleEmitter implements IParticleEmitterType {
  85711. /**
  85712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85713. */
  85714. direction1: Vector3;
  85715. /**
  85716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85717. */
  85718. direction2: Vector3;
  85719. /**
  85720. * 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.
  85721. */
  85722. minEmitBox: Vector3;
  85723. /**
  85724. * 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.
  85725. */
  85726. maxEmitBox: Vector3;
  85727. /**
  85728. * Creates a new instance BoxParticleEmitter
  85729. */
  85730. constructor();
  85731. /**
  85732. * Called by the particle System when the direction is computed for the created particle.
  85733. * @param worldMatrix is the world matrix of the particle system
  85734. * @param directionToUpdate is the direction vector to update with the result
  85735. * @param particle is the particle we are computed the direction for
  85736. */
  85737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85738. /**
  85739. * Called by the particle System when the position is computed for the created particle.
  85740. * @param worldMatrix is the world matrix of the particle system
  85741. * @param positionToUpdate is the position vector to update with the result
  85742. * @param particle is the particle we are computed the position for
  85743. */
  85744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85745. /**
  85746. * Clones the current emitter and returns a copy of it
  85747. * @returns the new emitter
  85748. */
  85749. clone(): BoxParticleEmitter;
  85750. /**
  85751. * Called by the GPUParticleSystem to setup the update shader
  85752. * @param effect defines the update shader
  85753. */
  85754. applyToShader(effect: Effect): void;
  85755. /**
  85756. * Returns a string to use to update the GPU particles update shader
  85757. * @returns a string containng the defines string
  85758. */
  85759. getEffectDefines(): string;
  85760. /**
  85761. * Returns the string "BoxParticleEmitter"
  85762. * @returns a string containing the class name
  85763. */
  85764. getClassName(): string;
  85765. /**
  85766. * Serializes the particle system to a JSON object.
  85767. * @returns the JSON object
  85768. */
  85769. serialize(): any;
  85770. /**
  85771. * Parse properties from a JSON object
  85772. * @param serializationObject defines the JSON object
  85773. */
  85774. parse(serializationObject: any): void;
  85775. }
  85776. }
  85777. declare module BABYLON {
  85778. /**
  85779. * Particle emitter emitting particles from the inside of a cone.
  85780. * It emits the particles alongside the cone volume from the base to the particle.
  85781. * The emission direction might be randomized.
  85782. */
  85783. export class ConeParticleEmitter implements IParticleEmitterType {
  85784. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85785. directionRandomizer: number;
  85786. private _radius;
  85787. private _angle;
  85788. private _height;
  85789. /**
  85790. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85791. */
  85792. radiusRange: number;
  85793. /**
  85794. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85795. */
  85796. heightRange: number;
  85797. /**
  85798. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85799. */
  85800. emitFromSpawnPointOnly: boolean;
  85801. /**
  85802. * Gets or sets the radius of the emission cone
  85803. */
  85804. radius: number;
  85805. /**
  85806. * Gets or sets the angle of the emission cone
  85807. */
  85808. angle: number;
  85809. private _buildHeight;
  85810. /**
  85811. * Creates a new instance ConeParticleEmitter
  85812. * @param radius the radius of the emission cone (1 by default)
  85813. * @param angle the cone base angle (PI by default)
  85814. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85815. */
  85816. constructor(radius?: number, angle?: number,
  85817. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85818. directionRandomizer?: number);
  85819. /**
  85820. * Called by the particle System when the direction is computed for the created particle.
  85821. * @param worldMatrix is the world matrix of the particle system
  85822. * @param directionToUpdate is the direction vector to update with the result
  85823. * @param particle is the particle we are computed the direction for
  85824. */
  85825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85826. /**
  85827. * Called by the particle System when the position is computed for the created particle.
  85828. * @param worldMatrix is the world matrix of the particle system
  85829. * @param positionToUpdate is the position vector to update with the result
  85830. * @param particle is the particle we are computed the position for
  85831. */
  85832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85833. /**
  85834. * Clones the current emitter and returns a copy of it
  85835. * @returns the new emitter
  85836. */
  85837. clone(): ConeParticleEmitter;
  85838. /**
  85839. * Called by the GPUParticleSystem to setup the update shader
  85840. * @param effect defines the update shader
  85841. */
  85842. applyToShader(effect: Effect): void;
  85843. /**
  85844. * Returns a string to use to update the GPU particles update shader
  85845. * @returns a string containng the defines string
  85846. */
  85847. getEffectDefines(): string;
  85848. /**
  85849. * Returns the string "ConeParticleEmitter"
  85850. * @returns a string containing the class name
  85851. */
  85852. getClassName(): string;
  85853. /**
  85854. * Serializes the particle system to a JSON object.
  85855. * @returns the JSON object
  85856. */
  85857. serialize(): any;
  85858. /**
  85859. * Parse properties from a JSON object
  85860. * @param serializationObject defines the JSON object
  85861. */
  85862. parse(serializationObject: any): void;
  85863. }
  85864. }
  85865. declare module BABYLON {
  85866. /**
  85867. * Particle emitter emitting particles from the inside of a cylinder.
  85868. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85869. */
  85870. export class CylinderParticleEmitter implements IParticleEmitterType {
  85871. /**
  85872. * The radius of the emission cylinder.
  85873. */
  85874. radius: number;
  85875. /**
  85876. * The height of the emission cylinder.
  85877. */
  85878. height: number;
  85879. /**
  85880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85881. */
  85882. radiusRange: number;
  85883. /**
  85884. * How much to randomize the particle direction [0-1].
  85885. */
  85886. directionRandomizer: number;
  85887. /**
  85888. * Creates a new instance CylinderParticleEmitter
  85889. * @param radius the radius of the emission cylinder (1 by default)
  85890. * @param height the height of the emission cylinder (1 by default)
  85891. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85892. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85893. */
  85894. constructor(
  85895. /**
  85896. * The radius of the emission cylinder.
  85897. */
  85898. radius?: number,
  85899. /**
  85900. * The height of the emission cylinder.
  85901. */
  85902. height?: number,
  85903. /**
  85904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85905. */
  85906. radiusRange?: number,
  85907. /**
  85908. * How much to randomize the particle direction [0-1].
  85909. */
  85910. directionRandomizer?: number);
  85911. /**
  85912. * Called by the particle System when the direction is computed for the created particle.
  85913. * @param worldMatrix is the world matrix of the particle system
  85914. * @param directionToUpdate is the direction vector to update with the result
  85915. * @param particle is the particle we are computed the direction for
  85916. */
  85917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85918. /**
  85919. * Called by the particle System when the position is computed for the created particle.
  85920. * @param worldMatrix is the world matrix of the particle system
  85921. * @param positionToUpdate is the position vector to update with the result
  85922. * @param particle is the particle we are computed the position for
  85923. */
  85924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85925. /**
  85926. * Clones the current emitter and returns a copy of it
  85927. * @returns the new emitter
  85928. */
  85929. clone(): CylinderParticleEmitter;
  85930. /**
  85931. * Called by the GPUParticleSystem to setup the update shader
  85932. * @param effect defines the update shader
  85933. */
  85934. applyToShader(effect: Effect): void;
  85935. /**
  85936. * Returns a string to use to update the GPU particles update shader
  85937. * @returns a string containng the defines string
  85938. */
  85939. getEffectDefines(): string;
  85940. /**
  85941. * Returns the string "CylinderParticleEmitter"
  85942. * @returns a string containing the class name
  85943. */
  85944. getClassName(): string;
  85945. /**
  85946. * Serializes the particle system to a JSON object.
  85947. * @returns the JSON object
  85948. */
  85949. serialize(): any;
  85950. /**
  85951. * Parse properties from a JSON object
  85952. * @param serializationObject defines the JSON object
  85953. */
  85954. parse(serializationObject: any): void;
  85955. }
  85956. /**
  85957. * Particle emitter emitting particles from the inside of a cylinder.
  85958. * It emits the particles randomly between two vectors.
  85959. */
  85960. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85961. /**
  85962. * The min limit of the emission direction.
  85963. */
  85964. direction1: Vector3;
  85965. /**
  85966. * The max limit of the emission direction.
  85967. */
  85968. direction2: Vector3;
  85969. /**
  85970. * Creates a new instance CylinderDirectedParticleEmitter
  85971. * @param radius the radius of the emission cylinder (1 by default)
  85972. * @param height the height of the emission cylinder (1 by default)
  85973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85974. * @param direction1 the min limit of the emission direction (up vector by default)
  85975. * @param direction2 the max limit of the emission direction (up vector by default)
  85976. */
  85977. constructor(radius?: number, height?: number, radiusRange?: number,
  85978. /**
  85979. * The min limit of the emission direction.
  85980. */
  85981. direction1?: Vector3,
  85982. /**
  85983. * The max limit of the emission direction.
  85984. */
  85985. direction2?: Vector3);
  85986. /**
  85987. * Called by the particle System when the direction is computed for the created particle.
  85988. * @param worldMatrix is the world matrix of the particle system
  85989. * @param directionToUpdate is the direction vector to update with the result
  85990. * @param particle is the particle we are computed the direction for
  85991. */
  85992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85993. /**
  85994. * Clones the current emitter and returns a copy of it
  85995. * @returns the new emitter
  85996. */
  85997. clone(): CylinderDirectedParticleEmitter;
  85998. /**
  85999. * Called by the GPUParticleSystem to setup the update shader
  86000. * @param effect defines the update shader
  86001. */
  86002. applyToShader(effect: Effect): void;
  86003. /**
  86004. * Returns a string to use to update the GPU particles update shader
  86005. * @returns a string containng the defines string
  86006. */
  86007. getEffectDefines(): string;
  86008. /**
  86009. * Returns the string "CylinderDirectedParticleEmitter"
  86010. * @returns a string containing the class name
  86011. */
  86012. getClassName(): string;
  86013. /**
  86014. * Serializes the particle system to a JSON object.
  86015. * @returns the JSON object
  86016. */
  86017. serialize(): any;
  86018. /**
  86019. * Parse properties from a JSON object
  86020. * @param serializationObject defines the JSON object
  86021. */
  86022. parse(serializationObject: any): void;
  86023. }
  86024. }
  86025. declare module BABYLON {
  86026. /**
  86027. * Particle emitter emitting particles from the inside of a hemisphere.
  86028. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86029. */
  86030. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86031. /**
  86032. * The radius of the emission hemisphere.
  86033. */
  86034. radius: number;
  86035. /**
  86036. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86037. */
  86038. radiusRange: number;
  86039. /**
  86040. * How much to randomize the particle direction [0-1].
  86041. */
  86042. directionRandomizer: number;
  86043. /**
  86044. * Creates a new instance HemisphericParticleEmitter
  86045. * @param radius the radius of the emission hemisphere (1 by default)
  86046. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86047. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86048. */
  86049. constructor(
  86050. /**
  86051. * The radius of the emission hemisphere.
  86052. */
  86053. radius?: number,
  86054. /**
  86055. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86056. */
  86057. radiusRange?: number,
  86058. /**
  86059. * How much to randomize the particle direction [0-1].
  86060. */
  86061. directionRandomizer?: number);
  86062. /**
  86063. * Called by the particle System when the direction is computed for the created particle.
  86064. * @param worldMatrix is the world matrix of the particle system
  86065. * @param directionToUpdate is the direction vector to update with the result
  86066. * @param particle is the particle we are computed the direction for
  86067. */
  86068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86069. /**
  86070. * Called by the particle System when the position is computed for the created particle.
  86071. * @param worldMatrix is the world matrix of the particle system
  86072. * @param positionToUpdate is the position vector to update with the result
  86073. * @param particle is the particle we are computed the position for
  86074. */
  86075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86076. /**
  86077. * Clones the current emitter and returns a copy of it
  86078. * @returns the new emitter
  86079. */
  86080. clone(): HemisphericParticleEmitter;
  86081. /**
  86082. * Called by the GPUParticleSystem to setup the update shader
  86083. * @param effect defines the update shader
  86084. */
  86085. applyToShader(effect: Effect): void;
  86086. /**
  86087. * Returns a string to use to update the GPU particles update shader
  86088. * @returns a string containng the defines string
  86089. */
  86090. getEffectDefines(): string;
  86091. /**
  86092. * Returns the string "HemisphericParticleEmitter"
  86093. * @returns a string containing the class name
  86094. */
  86095. getClassName(): string;
  86096. /**
  86097. * Serializes the particle system to a JSON object.
  86098. * @returns the JSON object
  86099. */
  86100. serialize(): any;
  86101. /**
  86102. * Parse properties from a JSON object
  86103. * @param serializationObject defines the JSON object
  86104. */
  86105. parse(serializationObject: any): void;
  86106. }
  86107. }
  86108. declare module BABYLON {
  86109. /**
  86110. * Particle emitter emitting particles from a point.
  86111. * It emits the particles randomly between 2 given directions.
  86112. */
  86113. export class PointParticleEmitter implements IParticleEmitterType {
  86114. /**
  86115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86116. */
  86117. direction1: Vector3;
  86118. /**
  86119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86120. */
  86121. direction2: Vector3;
  86122. /**
  86123. * Creates a new instance PointParticleEmitter
  86124. */
  86125. constructor();
  86126. /**
  86127. * Called by the particle System when the direction is computed for the created particle.
  86128. * @param worldMatrix is the world matrix of the particle system
  86129. * @param directionToUpdate is the direction vector to update with the result
  86130. * @param particle is the particle we are computed the direction for
  86131. */
  86132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86133. /**
  86134. * Called by the particle System when the position is computed for the created particle.
  86135. * @param worldMatrix is the world matrix of the particle system
  86136. * @param positionToUpdate is the position vector to update with the result
  86137. * @param particle is the particle we are computed the position for
  86138. */
  86139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86140. /**
  86141. * Clones the current emitter and returns a copy of it
  86142. * @returns the new emitter
  86143. */
  86144. clone(): PointParticleEmitter;
  86145. /**
  86146. * Called by the GPUParticleSystem to setup the update shader
  86147. * @param effect defines the update shader
  86148. */
  86149. applyToShader(effect: Effect): void;
  86150. /**
  86151. * Returns a string to use to update the GPU particles update shader
  86152. * @returns a string containng the defines string
  86153. */
  86154. getEffectDefines(): string;
  86155. /**
  86156. * Returns the string "PointParticleEmitter"
  86157. * @returns a string containing the class name
  86158. */
  86159. getClassName(): string;
  86160. /**
  86161. * Serializes the particle system to a JSON object.
  86162. * @returns the JSON object
  86163. */
  86164. serialize(): any;
  86165. /**
  86166. * Parse properties from a JSON object
  86167. * @param serializationObject defines the JSON object
  86168. */
  86169. parse(serializationObject: any): void;
  86170. }
  86171. }
  86172. declare module BABYLON {
  86173. /**
  86174. * Particle emitter emitting particles from the inside of a sphere.
  86175. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86176. */
  86177. export class SphereParticleEmitter implements IParticleEmitterType {
  86178. /**
  86179. * The radius of the emission sphere.
  86180. */
  86181. radius: number;
  86182. /**
  86183. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86184. */
  86185. radiusRange: number;
  86186. /**
  86187. * How much to randomize the particle direction [0-1].
  86188. */
  86189. directionRandomizer: number;
  86190. /**
  86191. * Creates a new instance SphereParticleEmitter
  86192. * @param radius the radius of the emission sphere (1 by default)
  86193. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86194. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86195. */
  86196. constructor(
  86197. /**
  86198. * The radius of the emission sphere.
  86199. */
  86200. radius?: number,
  86201. /**
  86202. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86203. */
  86204. radiusRange?: number,
  86205. /**
  86206. * How much to randomize the particle direction [0-1].
  86207. */
  86208. directionRandomizer?: number);
  86209. /**
  86210. * Called by the particle System when the direction is computed for the created particle.
  86211. * @param worldMatrix is the world matrix of the particle system
  86212. * @param directionToUpdate is the direction vector to update with the result
  86213. * @param particle is the particle we are computed the direction for
  86214. */
  86215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86216. /**
  86217. * Called by the particle System when the position is computed for the created particle.
  86218. * @param worldMatrix is the world matrix of the particle system
  86219. * @param positionToUpdate is the position vector to update with the result
  86220. * @param particle is the particle we are computed the position for
  86221. */
  86222. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86223. /**
  86224. * Clones the current emitter and returns a copy of it
  86225. * @returns the new emitter
  86226. */
  86227. clone(): SphereParticleEmitter;
  86228. /**
  86229. * Called by the GPUParticleSystem to setup the update shader
  86230. * @param effect defines the update shader
  86231. */
  86232. applyToShader(effect: Effect): void;
  86233. /**
  86234. * Returns a string to use to update the GPU particles update shader
  86235. * @returns a string containng the defines string
  86236. */
  86237. getEffectDefines(): string;
  86238. /**
  86239. * Returns the string "SphereParticleEmitter"
  86240. * @returns a string containing the class name
  86241. */
  86242. getClassName(): string;
  86243. /**
  86244. * Serializes the particle system to a JSON object.
  86245. * @returns the JSON object
  86246. */
  86247. serialize(): any;
  86248. /**
  86249. * Parse properties from a JSON object
  86250. * @param serializationObject defines the JSON object
  86251. */
  86252. parse(serializationObject: any): void;
  86253. }
  86254. /**
  86255. * Particle emitter emitting particles from the inside of a sphere.
  86256. * It emits the particles randomly between two vectors.
  86257. */
  86258. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86259. /**
  86260. * The min limit of the emission direction.
  86261. */
  86262. direction1: Vector3;
  86263. /**
  86264. * The max limit of the emission direction.
  86265. */
  86266. direction2: Vector3;
  86267. /**
  86268. * Creates a new instance SphereDirectedParticleEmitter
  86269. * @param radius the radius of the emission sphere (1 by default)
  86270. * @param direction1 the min limit of the emission direction (up vector by default)
  86271. * @param direction2 the max limit of the emission direction (up vector by default)
  86272. */
  86273. constructor(radius?: number,
  86274. /**
  86275. * The min limit of the emission direction.
  86276. */
  86277. direction1?: Vector3,
  86278. /**
  86279. * The max limit of the emission direction.
  86280. */
  86281. direction2?: Vector3);
  86282. /**
  86283. * Called by the particle System when the direction is computed for the created particle.
  86284. * @param worldMatrix is the world matrix of the particle system
  86285. * @param directionToUpdate is the direction vector to update with the result
  86286. * @param particle is the particle we are computed the direction for
  86287. */
  86288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86289. /**
  86290. * Clones the current emitter and returns a copy of it
  86291. * @returns the new emitter
  86292. */
  86293. clone(): SphereDirectedParticleEmitter;
  86294. /**
  86295. * Called by the GPUParticleSystem to setup the update shader
  86296. * @param effect defines the update shader
  86297. */
  86298. applyToShader(effect: Effect): void;
  86299. /**
  86300. * Returns a string to use to update the GPU particles update shader
  86301. * @returns a string containng the defines string
  86302. */
  86303. getEffectDefines(): string;
  86304. /**
  86305. * Returns the string "SphereDirectedParticleEmitter"
  86306. * @returns a string containing the class name
  86307. */
  86308. getClassName(): string;
  86309. /**
  86310. * Serializes the particle system to a JSON object.
  86311. * @returns the JSON object
  86312. */
  86313. serialize(): any;
  86314. /**
  86315. * Parse properties from a JSON object
  86316. * @param serializationObject defines the JSON object
  86317. */
  86318. parse(serializationObject: any): void;
  86319. }
  86320. }
  86321. declare module BABYLON {
  86322. /**
  86323. * Interface representing a particle system in Babylon.js.
  86324. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86325. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86326. */
  86327. export interface IParticleSystem {
  86328. /**
  86329. * List of animations used by the particle system.
  86330. */
  86331. animations: Animation[];
  86332. /**
  86333. * The id of the Particle system.
  86334. */
  86335. id: string;
  86336. /**
  86337. * The name of the Particle system.
  86338. */
  86339. name: string;
  86340. /**
  86341. * The emitter represents the Mesh or position we are attaching the particle system to.
  86342. */
  86343. emitter: Nullable<AbstractMesh | Vector3>;
  86344. /**
  86345. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86346. */
  86347. isBillboardBased: boolean;
  86348. /**
  86349. * The rendering group used by the Particle system to chose when to render.
  86350. */
  86351. renderingGroupId: number;
  86352. /**
  86353. * The layer mask we are rendering the particles through.
  86354. */
  86355. layerMask: number;
  86356. /**
  86357. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86358. */
  86359. updateSpeed: number;
  86360. /**
  86361. * The amount of time the particle system is running (depends of the overall update speed).
  86362. */
  86363. targetStopDuration: number;
  86364. /**
  86365. * The texture used to render each particle. (this can be a spritesheet)
  86366. */
  86367. particleTexture: Nullable<Texture>;
  86368. /**
  86369. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86370. */
  86371. blendMode: number;
  86372. /**
  86373. * Minimum life time of emitting particles.
  86374. */
  86375. minLifeTime: number;
  86376. /**
  86377. * Maximum life time of emitting particles.
  86378. */
  86379. maxLifeTime: number;
  86380. /**
  86381. * Minimum Size of emitting particles.
  86382. */
  86383. minSize: number;
  86384. /**
  86385. * Maximum Size of emitting particles.
  86386. */
  86387. maxSize: number;
  86388. /**
  86389. * Minimum scale of emitting particles on X axis.
  86390. */
  86391. minScaleX: number;
  86392. /**
  86393. * Maximum scale of emitting particles on X axis.
  86394. */
  86395. maxScaleX: number;
  86396. /**
  86397. * Minimum scale of emitting particles on Y axis.
  86398. */
  86399. minScaleY: number;
  86400. /**
  86401. * Maximum scale of emitting particles on Y axis.
  86402. */
  86403. maxScaleY: number;
  86404. /**
  86405. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86406. */
  86407. color1: Color4;
  86408. /**
  86409. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86410. */
  86411. color2: Color4;
  86412. /**
  86413. * Color the particle will have at the end of its lifetime.
  86414. */
  86415. colorDead: Color4;
  86416. /**
  86417. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86418. */
  86419. emitRate: number;
  86420. /**
  86421. * You can use gravity if you want to give an orientation to your particles.
  86422. */
  86423. gravity: Vector3;
  86424. /**
  86425. * Minimum power of emitting particles.
  86426. */
  86427. minEmitPower: number;
  86428. /**
  86429. * Maximum power of emitting particles.
  86430. */
  86431. maxEmitPower: number;
  86432. /**
  86433. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86434. */
  86435. minAngularSpeed: number;
  86436. /**
  86437. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86438. */
  86439. maxAngularSpeed: number;
  86440. /**
  86441. * Gets or sets the minimal initial rotation in radians.
  86442. */
  86443. minInitialRotation: number;
  86444. /**
  86445. * Gets or sets the maximal initial rotation in radians.
  86446. */
  86447. maxInitialRotation: number;
  86448. /**
  86449. * The particle emitter type defines the emitter used by the particle system.
  86450. * It can be for example box, sphere, or cone...
  86451. */
  86452. particleEmitterType: Nullable<IParticleEmitterType>;
  86453. /**
  86454. * Defines the delay in milliseconds before starting the system (0 by default)
  86455. */
  86456. startDelay: number;
  86457. /**
  86458. * 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
  86459. */
  86460. preWarmCycles: number;
  86461. /**
  86462. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86463. */
  86464. preWarmStepOffset: number;
  86465. /**
  86466. * 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)
  86467. */
  86468. spriteCellChangeSpeed: number;
  86469. /**
  86470. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86471. */
  86472. startSpriteCellID: number;
  86473. /**
  86474. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86475. */
  86476. endSpriteCellID: number;
  86477. /**
  86478. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86479. */
  86480. spriteCellWidth: number;
  86481. /**
  86482. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86483. */
  86484. spriteCellHeight: number;
  86485. /**
  86486. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86487. */
  86488. spriteRandomStartCell: boolean;
  86489. /**
  86490. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86491. */
  86492. isAnimationSheetEnabled: boolean;
  86493. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86494. translationPivot: Vector2;
  86495. /**
  86496. * Gets or sets a texture used to add random noise to particle positions
  86497. */
  86498. noiseTexture: Nullable<BaseTexture>;
  86499. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86500. noiseStrength: Vector3;
  86501. /**
  86502. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86503. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86504. */
  86505. billboardMode: number;
  86506. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86507. limitVelocityDamping: number;
  86508. /**
  86509. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86510. */
  86511. beginAnimationOnStart: boolean;
  86512. /**
  86513. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86514. */
  86515. beginAnimationFrom: number;
  86516. /**
  86517. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86518. */
  86519. beginAnimationTo: number;
  86520. /**
  86521. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86522. */
  86523. beginAnimationLoop: boolean;
  86524. /**
  86525. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86526. */
  86527. disposeOnStop: boolean;
  86528. /**
  86529. * Gets the maximum number of particles active at the same time.
  86530. * @returns The max number of active particles.
  86531. */
  86532. getCapacity(): number;
  86533. /**
  86534. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86535. * @returns True if it has been started, otherwise false.
  86536. */
  86537. isStarted(): boolean;
  86538. /**
  86539. * Animates the particle system for this frame.
  86540. */
  86541. animate(): void;
  86542. /**
  86543. * Renders the particle system in its current state.
  86544. * @returns the current number of particles
  86545. */
  86546. render(): number;
  86547. /**
  86548. * Dispose the particle system and frees its associated resources.
  86549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86550. */
  86551. dispose(disposeTexture?: boolean): void;
  86552. /**
  86553. * Clones the particle system.
  86554. * @param name The name of the cloned object
  86555. * @param newEmitter The new emitter to use
  86556. * @returns the cloned particle system
  86557. */
  86558. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86559. /**
  86560. * Serializes the particle system to a JSON object.
  86561. * @returns the JSON object
  86562. */
  86563. serialize(): any;
  86564. /**
  86565. * Rebuild the particle system
  86566. */
  86567. rebuild(): void;
  86568. /**
  86569. * Starts the particle system and begins to emit
  86570. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86571. */
  86572. start(delay?: number): void;
  86573. /**
  86574. * Stops the particle system.
  86575. */
  86576. stop(): void;
  86577. /**
  86578. * Remove all active particles
  86579. */
  86580. reset(): void;
  86581. /**
  86582. * Is this system ready to be used/rendered
  86583. * @return true if the system is ready
  86584. */
  86585. isReady(): boolean;
  86586. /**
  86587. * Adds a new color gradient
  86588. * @param gradient defines the gradient to use (between 0 and 1)
  86589. * @param color1 defines the color to affect to the specified gradient
  86590. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86591. * @returns the current particle system
  86592. */
  86593. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86594. /**
  86595. * Remove a specific color gradient
  86596. * @param gradient defines the gradient to remove
  86597. * @returns the current particle system
  86598. */
  86599. removeColorGradient(gradient: number): IParticleSystem;
  86600. /**
  86601. * Adds a new size gradient
  86602. * @param gradient defines the gradient to use (between 0 and 1)
  86603. * @param factor defines the size factor to affect to the specified gradient
  86604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86605. * @returns the current particle system
  86606. */
  86607. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86608. /**
  86609. * Remove a specific size gradient
  86610. * @param gradient defines the gradient to remove
  86611. * @returns the current particle system
  86612. */
  86613. removeSizeGradient(gradient: number): IParticleSystem;
  86614. /**
  86615. * Gets the current list of color gradients.
  86616. * You must use addColorGradient and removeColorGradient to udpate this list
  86617. * @returns the list of color gradients
  86618. */
  86619. getColorGradients(): Nullable<Array<ColorGradient>>;
  86620. /**
  86621. * Gets the current list of size gradients.
  86622. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86623. * @returns the list of size gradients
  86624. */
  86625. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86626. /**
  86627. * Gets the current list of angular speed gradients.
  86628. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86629. * @returns the list of angular speed gradients
  86630. */
  86631. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86632. /**
  86633. * Adds a new angular speed gradient
  86634. * @param gradient defines the gradient to use (between 0 and 1)
  86635. * @param factor defines the angular speed to affect to the specified gradient
  86636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86637. * @returns the current particle system
  86638. */
  86639. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86640. /**
  86641. * Remove a specific angular speed gradient
  86642. * @param gradient defines the gradient to remove
  86643. * @returns the current particle system
  86644. */
  86645. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86646. /**
  86647. * Gets the current list of velocity gradients.
  86648. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86649. * @returns the list of velocity gradients
  86650. */
  86651. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86652. /**
  86653. * Adds a new velocity gradient
  86654. * @param gradient defines the gradient to use (between 0 and 1)
  86655. * @param factor defines the velocity to affect to the specified gradient
  86656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86657. * @returns the current particle system
  86658. */
  86659. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86660. /**
  86661. * Remove a specific velocity gradient
  86662. * @param gradient defines the gradient to remove
  86663. * @returns the current particle system
  86664. */
  86665. removeVelocityGradient(gradient: number): IParticleSystem;
  86666. /**
  86667. * Gets the current list of limit velocity gradients.
  86668. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86669. * @returns the list of limit velocity gradients
  86670. */
  86671. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86672. /**
  86673. * Adds a new limit velocity gradient
  86674. * @param gradient defines the gradient to use (between 0 and 1)
  86675. * @param factor defines the limit velocity to affect to the specified gradient
  86676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86677. * @returns the current particle system
  86678. */
  86679. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86680. /**
  86681. * Remove a specific limit velocity gradient
  86682. * @param gradient defines the gradient to remove
  86683. * @returns the current particle system
  86684. */
  86685. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86686. /**
  86687. * Adds a new drag gradient
  86688. * @param gradient defines the gradient to use (between 0 and 1)
  86689. * @param factor defines the drag to affect to the specified gradient
  86690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86691. * @returns the current particle system
  86692. */
  86693. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86694. /**
  86695. * Remove a specific drag gradient
  86696. * @param gradient defines the gradient to remove
  86697. * @returns the current particle system
  86698. */
  86699. removeDragGradient(gradient: number): IParticleSystem;
  86700. /**
  86701. * Gets the current list of drag gradients.
  86702. * You must use addDragGradient and removeDragGradient to udpate this list
  86703. * @returns the list of drag gradients
  86704. */
  86705. getDragGradients(): Nullable<Array<FactorGradient>>;
  86706. /**
  86707. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86708. * @param gradient defines the gradient to use (between 0 and 1)
  86709. * @param factor defines the emit rate to affect to the specified gradient
  86710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86711. * @returns the current particle system
  86712. */
  86713. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86714. /**
  86715. * Remove a specific emit rate gradient
  86716. * @param gradient defines the gradient to remove
  86717. * @returns the current particle system
  86718. */
  86719. removeEmitRateGradient(gradient: number): IParticleSystem;
  86720. /**
  86721. * Gets the current list of emit rate gradients.
  86722. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86723. * @returns the list of emit rate gradients
  86724. */
  86725. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86726. /**
  86727. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86728. * @param gradient defines the gradient to use (between 0 and 1)
  86729. * @param factor defines the start size to affect to the specified gradient
  86730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86731. * @returns the current particle system
  86732. */
  86733. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86734. /**
  86735. * Remove a specific start size gradient
  86736. * @param gradient defines the gradient to remove
  86737. * @returns the current particle system
  86738. */
  86739. removeStartSizeGradient(gradient: number): IParticleSystem;
  86740. /**
  86741. * Gets the current list of start size gradients.
  86742. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86743. * @returns the list of start size gradients
  86744. */
  86745. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86746. /**
  86747. * Adds a new life time gradient
  86748. * @param gradient defines the gradient to use (between 0 and 1)
  86749. * @param factor defines the life time factor to affect to the specified gradient
  86750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86751. * @returns the current particle system
  86752. */
  86753. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86754. /**
  86755. * Remove a specific life time gradient
  86756. * @param gradient defines the gradient to remove
  86757. * @returns the current particle system
  86758. */
  86759. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86760. /**
  86761. * Gets the current list of life time gradients.
  86762. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86763. * @returns the list of life time gradients
  86764. */
  86765. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86766. /**
  86767. * Gets the current list of color gradients.
  86768. * You must use addColorGradient and removeColorGradient to udpate this list
  86769. * @returns the list of color gradients
  86770. */
  86771. getColorGradients(): Nullable<Array<ColorGradient>>;
  86772. /**
  86773. * Adds a new ramp gradient used to remap particle colors
  86774. * @param gradient defines the gradient to use (between 0 and 1)
  86775. * @param color defines the color to affect to the specified gradient
  86776. * @returns the current particle system
  86777. */
  86778. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86779. /**
  86780. * Gets the current list of ramp gradients.
  86781. * You must use addRampGradient and removeRampGradient to udpate this list
  86782. * @returns the list of ramp gradients
  86783. */
  86784. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86785. /** Gets or sets a boolean indicating that ramp gradients must be used
  86786. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86787. */
  86788. useRampGradients: boolean;
  86789. /**
  86790. * Adds a new color remap gradient
  86791. * @param gradient defines the gradient to use (between 0 and 1)
  86792. * @param min defines the color remap minimal range
  86793. * @param max defines the color remap maximal range
  86794. * @returns the current particle system
  86795. */
  86796. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86797. /**
  86798. * Gets the current list of color remap gradients.
  86799. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86800. * @returns the list of color remap gradients
  86801. */
  86802. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86803. /**
  86804. * Adds a new alpha remap gradient
  86805. * @param gradient defines the gradient to use (between 0 and 1)
  86806. * @param min defines the alpha remap minimal range
  86807. * @param max defines the alpha remap maximal range
  86808. * @returns the current particle system
  86809. */
  86810. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86811. /**
  86812. * Gets the current list of alpha remap gradients.
  86813. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86814. * @returns the list of alpha remap gradients
  86815. */
  86816. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86817. /**
  86818. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86819. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86820. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86821. * @returns the emitter
  86822. */
  86823. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86824. /**
  86825. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86826. * @param radius The radius of the hemisphere to emit from
  86827. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86828. * @returns the emitter
  86829. */
  86830. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86831. /**
  86832. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86833. * @param radius The radius of the sphere to emit from
  86834. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86835. * @returns the emitter
  86836. */
  86837. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86838. /**
  86839. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86840. * @param radius The radius of the sphere to emit from
  86841. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86842. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86843. * @returns the emitter
  86844. */
  86845. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86846. /**
  86847. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86848. * @param radius The radius of the emission cylinder
  86849. * @param height The height of the emission cylinder
  86850. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86851. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86852. * @returns the emitter
  86853. */
  86854. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86855. /**
  86856. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86857. * @param radius The radius of the cylinder to emit from
  86858. * @param height The height of the emission cylinder
  86859. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86862. * @returns the emitter
  86863. */
  86864. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86865. /**
  86866. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86867. * @param radius The radius of the cone to emit from
  86868. * @param angle The base angle of the cone
  86869. * @returns the emitter
  86870. */
  86871. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86872. /**
  86873. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86876. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86877. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86878. * @returns the emitter
  86879. */
  86880. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86881. /**
  86882. * Get hosting scene
  86883. * @returns the scene
  86884. */
  86885. getScene(): Scene;
  86886. }
  86887. }
  86888. declare module BABYLON {
  86889. /**
  86890. * Creates an instance based on a source mesh.
  86891. */
  86892. export class InstancedMesh extends AbstractMesh {
  86893. private _sourceMesh;
  86894. private _currentLOD;
  86895. /** @hidden */
  86896. _indexInSourceMeshInstanceArray: number;
  86897. constructor(name: string, source: Mesh);
  86898. /**
  86899. * Returns the string "InstancedMesh".
  86900. */
  86901. getClassName(): string;
  86902. /** Gets the list of lights affecting that mesh */
  86903. readonly lightSources: Light[];
  86904. _resyncLightSources(): void;
  86905. _resyncLighSource(light: Light): void;
  86906. _removeLightSource(light: Light, dispose: boolean): void;
  86907. /**
  86908. * If the source mesh receives shadows
  86909. */
  86910. readonly receiveShadows: boolean;
  86911. /**
  86912. * The material of the source mesh
  86913. */
  86914. readonly material: Nullable<Material>;
  86915. /**
  86916. * Visibility of the source mesh
  86917. */
  86918. readonly visibility: number;
  86919. /**
  86920. * Skeleton of the source mesh
  86921. */
  86922. readonly skeleton: Nullable<Skeleton>;
  86923. /**
  86924. * Rendering ground id of the source mesh
  86925. */
  86926. renderingGroupId: number;
  86927. /**
  86928. * Returns the total number of vertices (integer).
  86929. */
  86930. getTotalVertices(): number;
  86931. /**
  86932. * Returns a positive integer : the total number of indices in this mesh geometry.
  86933. * @returns the numner of indices or zero if the mesh has no geometry.
  86934. */
  86935. getTotalIndices(): number;
  86936. /**
  86937. * The source mesh of the instance
  86938. */
  86939. readonly sourceMesh: Mesh;
  86940. /**
  86941. * Is this node ready to be used/rendered
  86942. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86943. * @return {boolean} is it ready
  86944. */
  86945. isReady(completeCheck?: boolean): boolean;
  86946. /**
  86947. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86948. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86949. * @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.
  86950. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86951. */
  86952. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86953. /**
  86954. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86955. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86956. * The `data` are either a numeric array either a Float32Array.
  86957. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86958. * 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).
  86959. * Note that a new underlying VertexBuffer object is created each call.
  86960. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86961. *
  86962. * Possible `kind` values :
  86963. * - VertexBuffer.PositionKind
  86964. * - VertexBuffer.UVKind
  86965. * - VertexBuffer.UV2Kind
  86966. * - VertexBuffer.UV3Kind
  86967. * - VertexBuffer.UV4Kind
  86968. * - VertexBuffer.UV5Kind
  86969. * - VertexBuffer.UV6Kind
  86970. * - VertexBuffer.ColorKind
  86971. * - VertexBuffer.MatricesIndicesKind
  86972. * - VertexBuffer.MatricesIndicesExtraKind
  86973. * - VertexBuffer.MatricesWeightsKind
  86974. * - VertexBuffer.MatricesWeightsExtraKind
  86975. *
  86976. * Returns the Mesh.
  86977. */
  86978. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86979. /**
  86980. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86981. * If the mesh has no geometry, it is simply returned as it is.
  86982. * The `data` are either a numeric array either a Float32Array.
  86983. * No new underlying VertexBuffer object is created.
  86984. * 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.
  86985. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86986. *
  86987. * Possible `kind` values :
  86988. * - VertexBuffer.PositionKind
  86989. * - VertexBuffer.UVKind
  86990. * - VertexBuffer.UV2Kind
  86991. * - VertexBuffer.UV3Kind
  86992. * - VertexBuffer.UV4Kind
  86993. * - VertexBuffer.UV5Kind
  86994. * - VertexBuffer.UV6Kind
  86995. * - VertexBuffer.ColorKind
  86996. * - VertexBuffer.MatricesIndicesKind
  86997. * - VertexBuffer.MatricesIndicesExtraKind
  86998. * - VertexBuffer.MatricesWeightsKind
  86999. * - VertexBuffer.MatricesWeightsExtraKind
  87000. *
  87001. * Returns the Mesh.
  87002. */
  87003. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87004. /**
  87005. * Sets the mesh indices.
  87006. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87007. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87008. * This method creates a new index buffer each call.
  87009. * Returns the Mesh.
  87010. */
  87011. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87012. /**
  87013. * Boolean : True if the mesh owns the requested kind of data.
  87014. */
  87015. isVerticesDataPresent(kind: string): boolean;
  87016. /**
  87017. * Returns an array of indices (IndicesArray).
  87018. */
  87019. getIndices(): Nullable<IndicesArray>;
  87020. readonly _positions: Nullable<Vector3[]>;
  87021. /**
  87022. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87023. * This means the mesh underlying bounding box and sphere are recomputed.
  87024. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87025. * @returns the current mesh
  87026. */
  87027. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87028. /** @hidden */
  87029. _preActivate(): InstancedMesh;
  87030. /** @hidden */
  87031. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87032. /** @hidden */
  87033. _postActivate(): void;
  87034. getWorldMatrix(): Matrix;
  87035. readonly isAnInstance: boolean;
  87036. /**
  87037. * Returns the current associated LOD AbstractMesh.
  87038. */
  87039. getLOD(camera: Camera): AbstractMesh;
  87040. /** @hidden */
  87041. _syncSubMeshes(): InstancedMesh;
  87042. /** @hidden */
  87043. _generatePointsArray(): boolean;
  87044. /**
  87045. * Creates a new InstancedMesh from the current mesh.
  87046. * - name (string) : the cloned mesh name
  87047. * - newParent (optional Node) : the optional Node to parent the clone to.
  87048. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87049. *
  87050. * Returns the clone.
  87051. */
  87052. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87053. /**
  87054. * Disposes the InstancedMesh.
  87055. * Returns nothing.
  87056. */
  87057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87058. }
  87059. interface Mesh {
  87060. /**
  87061. * Register a custom buffer that will be instanced
  87062. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87063. * @param kind defines the buffer kind
  87064. * @param stride defines the stride in floats
  87065. */
  87066. registerInstancedBuffer(kind: string, stride: number): void;
  87067. /** @hidden */
  87068. _userInstancedBuffersStorage: {
  87069. data: {
  87070. [key: string]: Float32Array;
  87071. };
  87072. sizes: {
  87073. [key: string]: number;
  87074. };
  87075. vertexBuffers: {
  87076. [key: string]: Nullable<VertexBuffer>;
  87077. };
  87078. strides: {
  87079. [key: string]: number;
  87080. };
  87081. };
  87082. }
  87083. interface AbstractMesh {
  87084. /**
  87085. * Object used to store instanced buffers defined by user
  87086. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87087. */
  87088. instancedBuffers: {
  87089. [key: string]: any;
  87090. };
  87091. }
  87092. }
  87093. declare module BABYLON {
  87094. /**
  87095. * Defines the options associated with the creation of a shader material.
  87096. */
  87097. export interface IShaderMaterialOptions {
  87098. /**
  87099. * Does the material work in alpha blend mode
  87100. */
  87101. needAlphaBlending: boolean;
  87102. /**
  87103. * Does the material work in alpha test mode
  87104. */
  87105. needAlphaTesting: boolean;
  87106. /**
  87107. * The list of attribute names used in the shader
  87108. */
  87109. attributes: string[];
  87110. /**
  87111. * The list of unifrom names used in the shader
  87112. */
  87113. uniforms: string[];
  87114. /**
  87115. * The list of UBO names used in the shader
  87116. */
  87117. uniformBuffers: string[];
  87118. /**
  87119. * The list of sampler names used in the shader
  87120. */
  87121. samplers: string[];
  87122. /**
  87123. * The list of defines used in the shader
  87124. */
  87125. defines: string[];
  87126. }
  87127. /**
  87128. * 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.
  87129. *
  87130. * This returned material effects how the mesh will look based on the code in the shaders.
  87131. *
  87132. * @see http://doc.babylonjs.com/how_to/shader_material
  87133. */
  87134. export class ShaderMaterial extends Material {
  87135. private _shaderPath;
  87136. private _options;
  87137. private _textures;
  87138. private _textureArrays;
  87139. private _floats;
  87140. private _ints;
  87141. private _floatsArrays;
  87142. private _colors3;
  87143. private _colors3Arrays;
  87144. private _colors4;
  87145. private _colors4Arrays;
  87146. private _vectors2;
  87147. private _vectors3;
  87148. private _vectors4;
  87149. private _matrices;
  87150. private _matrixArrays;
  87151. private _matrices3x3;
  87152. private _matrices2x2;
  87153. private _vectors2Arrays;
  87154. private _vectors3Arrays;
  87155. private _vectors4Arrays;
  87156. private _cachedWorldViewMatrix;
  87157. private _cachedWorldViewProjectionMatrix;
  87158. private _renderId;
  87159. /**
  87160. * Instantiate a new shader material.
  87161. * 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.
  87162. * This returned material effects how the mesh will look based on the code in the shaders.
  87163. * @see http://doc.babylonjs.com/how_to/shader_material
  87164. * @param name Define the name of the material in the scene
  87165. * @param scene Define the scene the material belongs to
  87166. * @param shaderPath Defines the route to the shader code in one of three ways:
  87167. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87168. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87169. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87170. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87171. * @param options Define the options used to create the shader
  87172. */
  87173. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87174. /**
  87175. * Gets the options used to compile the shader.
  87176. * They can be modified to trigger a new compilation
  87177. */
  87178. readonly options: IShaderMaterialOptions;
  87179. /**
  87180. * Gets the current class name of the material e.g. "ShaderMaterial"
  87181. * Mainly use in serialization.
  87182. * @returns the class name
  87183. */
  87184. getClassName(): string;
  87185. /**
  87186. * Specifies if the material will require alpha blending
  87187. * @returns a boolean specifying if alpha blending is needed
  87188. */
  87189. needAlphaBlending(): boolean;
  87190. /**
  87191. * Specifies if this material should be rendered in alpha test mode
  87192. * @returns a boolean specifying if an alpha test is needed.
  87193. */
  87194. needAlphaTesting(): boolean;
  87195. private _checkUniform;
  87196. /**
  87197. * Set a texture in the shader.
  87198. * @param name Define the name of the uniform samplers as defined in the shader
  87199. * @param texture Define the texture to bind to this sampler
  87200. * @return the material itself allowing "fluent" like uniform updates
  87201. */
  87202. setTexture(name: string, texture: Texture): ShaderMaterial;
  87203. /**
  87204. * Set a texture array in the shader.
  87205. * @param name Define the name of the uniform sampler array as defined in the shader
  87206. * @param textures Define the list of textures to bind to this sampler
  87207. * @return the material itself allowing "fluent" like uniform updates
  87208. */
  87209. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87210. /**
  87211. * Set a float in the shader.
  87212. * @param name Define the name of the uniform as defined in the shader
  87213. * @param value Define the value to give to the uniform
  87214. * @return the material itself allowing "fluent" like uniform updates
  87215. */
  87216. setFloat(name: string, value: number): ShaderMaterial;
  87217. /**
  87218. * Set a int in the shader.
  87219. * @param name Define the name of the uniform as defined in the shader
  87220. * @param value Define the value to give to the uniform
  87221. * @return the material itself allowing "fluent" like uniform updates
  87222. */
  87223. setInt(name: string, value: number): ShaderMaterial;
  87224. /**
  87225. * Set an array of floats in the shader.
  87226. * @param name Define the name of the uniform as defined in the shader
  87227. * @param value Define the value to give to the uniform
  87228. * @return the material itself allowing "fluent" like uniform updates
  87229. */
  87230. setFloats(name: string, value: number[]): ShaderMaterial;
  87231. /**
  87232. * Set a vec3 in the shader from a Color3.
  87233. * @param name Define the name of the uniform as defined in the shader
  87234. * @param value Define the value to give to the uniform
  87235. * @return the material itself allowing "fluent" like uniform updates
  87236. */
  87237. setColor3(name: string, value: Color3): ShaderMaterial;
  87238. /**
  87239. * Set a vec3 array in the shader from a Color3 array.
  87240. * @param name Define the name of the uniform as defined in the shader
  87241. * @param value Define the value to give to the uniform
  87242. * @return the material itself allowing "fluent" like uniform updates
  87243. */
  87244. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87245. /**
  87246. * Set a vec4 in the shader from a Color4.
  87247. * @param name Define the name of the uniform as defined in the shader
  87248. * @param value Define the value to give to the uniform
  87249. * @return the material itself allowing "fluent" like uniform updates
  87250. */
  87251. setColor4(name: string, value: Color4): ShaderMaterial;
  87252. /**
  87253. * Set a vec4 array in the shader from a Color4 array.
  87254. * @param name Define the name of the uniform as defined in the shader
  87255. * @param value Define the value to give to the uniform
  87256. * @return the material itself allowing "fluent" like uniform updates
  87257. */
  87258. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87259. /**
  87260. * Set a vec2 in the shader from a Vector2.
  87261. * @param name Define the name of the uniform as defined in the shader
  87262. * @param value Define the value to give to the uniform
  87263. * @return the material itself allowing "fluent" like uniform updates
  87264. */
  87265. setVector2(name: string, value: Vector2): ShaderMaterial;
  87266. /**
  87267. * Set a vec3 in the shader from a Vector3.
  87268. * @param name Define the name of the uniform as defined in the shader
  87269. * @param value Define the value to give to the uniform
  87270. * @return the material itself allowing "fluent" like uniform updates
  87271. */
  87272. setVector3(name: string, value: Vector3): ShaderMaterial;
  87273. /**
  87274. * Set a vec4 in the shader from a Vector4.
  87275. * @param name Define the name of the uniform as defined in the shader
  87276. * @param value Define the value to give to the uniform
  87277. * @return the material itself allowing "fluent" like uniform updates
  87278. */
  87279. setVector4(name: string, value: Vector4): ShaderMaterial;
  87280. /**
  87281. * Set a mat4 in the shader from a Matrix.
  87282. * @param name Define the name of the uniform as defined in the shader
  87283. * @param value Define the value to give to the uniform
  87284. * @return the material itself allowing "fluent" like uniform updates
  87285. */
  87286. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87287. /**
  87288. * Set a float32Array in the shader from a matrix array.
  87289. * @param name Define the name of the uniform as defined in the shader
  87290. * @param value Define the value to give to the uniform
  87291. * @return the material itself allowing "fluent" like uniform updates
  87292. */
  87293. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87294. /**
  87295. * Set a mat3 in the shader from a Float32Array.
  87296. * @param name Define the name of the uniform as defined in the shader
  87297. * @param value Define the value to give to the uniform
  87298. * @return the material itself allowing "fluent" like uniform updates
  87299. */
  87300. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87301. /**
  87302. * Set a mat2 in the shader from a Float32Array.
  87303. * @param name Define the name of the uniform as defined in the shader
  87304. * @param value Define the value to give to the uniform
  87305. * @return the material itself allowing "fluent" like uniform updates
  87306. */
  87307. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87308. /**
  87309. * Set a vec2 array in the shader from a number array.
  87310. * @param name Define the name of the uniform as defined in the shader
  87311. * @param value Define the value to give to the uniform
  87312. * @return the material itself allowing "fluent" like uniform updates
  87313. */
  87314. setArray2(name: string, value: number[]): ShaderMaterial;
  87315. /**
  87316. * Set a vec3 array in the shader from a number array.
  87317. * @param name Define the name of the uniform as defined in the shader
  87318. * @param value Define the value to give to the uniform
  87319. * @return the material itself allowing "fluent" like uniform updates
  87320. */
  87321. setArray3(name: string, value: number[]): ShaderMaterial;
  87322. /**
  87323. * Set a vec4 array in the shader from a number array.
  87324. * @param name Define the name of the uniform as defined in the shader
  87325. * @param value Define the value to give to the uniform
  87326. * @return the material itself allowing "fluent" like uniform updates
  87327. */
  87328. setArray4(name: string, value: number[]): ShaderMaterial;
  87329. private _checkCache;
  87330. /**
  87331. * Specifies that the submesh is ready to be used
  87332. * @param mesh defines the mesh to check
  87333. * @param subMesh defines which submesh to check
  87334. * @param useInstances specifies that instances should be used
  87335. * @returns a boolean indicating that the submesh is ready or not
  87336. */
  87337. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87338. /**
  87339. * Checks if the material is ready to render the requested mesh
  87340. * @param mesh Define the mesh to render
  87341. * @param useInstances Define whether or not the material is used with instances
  87342. * @returns true if ready, otherwise false
  87343. */
  87344. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87345. /**
  87346. * Binds the world matrix to the material
  87347. * @param world defines the world transformation matrix
  87348. */
  87349. bindOnlyWorldMatrix(world: Matrix): void;
  87350. /**
  87351. * Binds the material to the mesh
  87352. * @param world defines the world transformation matrix
  87353. * @param mesh defines the mesh to bind the material to
  87354. */
  87355. bind(world: Matrix, mesh?: Mesh): void;
  87356. /**
  87357. * Gets the active textures from the material
  87358. * @returns an array of textures
  87359. */
  87360. getActiveTextures(): BaseTexture[];
  87361. /**
  87362. * Specifies if the material uses a texture
  87363. * @param texture defines the texture to check against the material
  87364. * @returns a boolean specifying if the material uses the texture
  87365. */
  87366. hasTexture(texture: BaseTexture): boolean;
  87367. /**
  87368. * Makes a duplicate of the material, and gives it a new name
  87369. * @param name defines the new name for the duplicated material
  87370. * @returns the cloned material
  87371. */
  87372. clone(name: string): ShaderMaterial;
  87373. /**
  87374. * Disposes the material
  87375. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87376. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87377. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87378. */
  87379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87380. /**
  87381. * Serializes this material in a JSON representation
  87382. * @returns the serialized material object
  87383. */
  87384. serialize(): any;
  87385. /**
  87386. * Creates a shader material from parsed shader material data
  87387. * @param source defines the JSON represnetation of the material
  87388. * @param scene defines the hosting scene
  87389. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87390. * @returns a new material
  87391. */
  87392. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87393. }
  87394. }
  87395. declare module BABYLON {
  87396. /** @hidden */
  87397. export var colorPixelShader: {
  87398. name: string;
  87399. shader: string;
  87400. };
  87401. }
  87402. declare module BABYLON {
  87403. /** @hidden */
  87404. export var colorVertexShader: {
  87405. name: string;
  87406. shader: string;
  87407. };
  87408. }
  87409. declare module BABYLON {
  87410. /**
  87411. * Line mesh
  87412. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87413. */
  87414. export class LinesMesh extends Mesh {
  87415. /**
  87416. * If vertex color should be applied to the mesh
  87417. */
  87418. readonly useVertexColor?: boolean | undefined;
  87419. /**
  87420. * If vertex alpha should be applied to the mesh
  87421. */
  87422. readonly useVertexAlpha?: boolean | undefined;
  87423. /**
  87424. * Color of the line (Default: White)
  87425. */
  87426. color: Color3;
  87427. /**
  87428. * Alpha of the line (Default: 1)
  87429. */
  87430. alpha: number;
  87431. /**
  87432. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87433. * This margin is expressed in world space coordinates, so its value may vary.
  87434. * Default value is 0.1
  87435. */
  87436. intersectionThreshold: number;
  87437. private _colorShader;
  87438. private color4;
  87439. /**
  87440. * Creates a new LinesMesh
  87441. * @param name defines the name
  87442. * @param scene defines the hosting scene
  87443. * @param parent defines the parent mesh if any
  87444. * @param source defines the optional source LinesMesh used to clone data from
  87445. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87446. * When false, achieved by calling a clone(), also passing False.
  87447. * This will make creation of children, recursive.
  87448. * @param useVertexColor defines if this LinesMesh supports vertex color
  87449. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87450. */
  87451. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87452. /**
  87453. * If vertex color should be applied to the mesh
  87454. */
  87455. useVertexColor?: boolean | undefined,
  87456. /**
  87457. * If vertex alpha should be applied to the mesh
  87458. */
  87459. useVertexAlpha?: boolean | undefined);
  87460. private _addClipPlaneDefine;
  87461. private _removeClipPlaneDefine;
  87462. isReady(): boolean;
  87463. /**
  87464. * Returns the string "LineMesh"
  87465. */
  87466. getClassName(): string;
  87467. /**
  87468. * @hidden
  87469. */
  87470. /**
  87471. * @hidden
  87472. */
  87473. material: Material;
  87474. /**
  87475. * @hidden
  87476. */
  87477. readonly checkCollisions: boolean;
  87478. /** @hidden */
  87479. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87480. /** @hidden */
  87481. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87482. /**
  87483. * Disposes of the line mesh
  87484. * @param doNotRecurse If children should be disposed
  87485. */
  87486. dispose(doNotRecurse?: boolean): void;
  87487. /**
  87488. * Returns a new LineMesh object cloned from the current one.
  87489. */
  87490. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87491. /**
  87492. * Creates a new InstancedLinesMesh object from the mesh model.
  87493. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87494. * @param name defines the name of the new instance
  87495. * @returns a new InstancedLinesMesh
  87496. */
  87497. createInstance(name: string): InstancedLinesMesh;
  87498. }
  87499. /**
  87500. * Creates an instance based on a source LinesMesh
  87501. */
  87502. export class InstancedLinesMesh extends InstancedMesh {
  87503. /**
  87504. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87505. * This margin is expressed in world space coordinates, so its value may vary.
  87506. * Initilized with the intersectionThreshold value of the source LinesMesh
  87507. */
  87508. intersectionThreshold: number;
  87509. constructor(name: string, source: LinesMesh);
  87510. /**
  87511. * Returns the string "InstancedLinesMesh".
  87512. */
  87513. getClassName(): string;
  87514. }
  87515. }
  87516. declare module BABYLON {
  87517. /** @hidden */
  87518. export var linePixelShader: {
  87519. name: string;
  87520. shader: string;
  87521. };
  87522. }
  87523. declare module BABYLON {
  87524. /** @hidden */
  87525. export var lineVertexShader: {
  87526. name: string;
  87527. shader: string;
  87528. };
  87529. }
  87530. declare module BABYLON {
  87531. interface AbstractMesh {
  87532. /**
  87533. * Gets the edgesRenderer associated with the mesh
  87534. */
  87535. edgesRenderer: Nullable<EdgesRenderer>;
  87536. }
  87537. interface LinesMesh {
  87538. /**
  87539. * Enables the edge rendering mode on the mesh.
  87540. * This mode makes the mesh edges visible
  87541. * @param epsilon defines the maximal distance between two angles to detect a face
  87542. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87543. * @returns the currentAbstractMesh
  87544. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87545. */
  87546. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87547. }
  87548. interface InstancedLinesMesh {
  87549. /**
  87550. * Enables the edge rendering mode on the mesh.
  87551. * This mode makes the mesh edges visible
  87552. * @param epsilon defines the maximal distance between two angles to detect a face
  87553. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87554. * @returns the current InstancedLinesMesh
  87555. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87556. */
  87557. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87558. }
  87559. /**
  87560. * Defines the minimum contract an Edges renderer should follow.
  87561. */
  87562. export interface IEdgesRenderer extends IDisposable {
  87563. /**
  87564. * Gets or sets a boolean indicating if the edgesRenderer is active
  87565. */
  87566. isEnabled: boolean;
  87567. /**
  87568. * Renders the edges of the attached mesh,
  87569. */
  87570. render(): void;
  87571. /**
  87572. * Checks wether or not the edges renderer is ready to render.
  87573. * @return true if ready, otherwise false.
  87574. */
  87575. isReady(): boolean;
  87576. }
  87577. /**
  87578. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87579. */
  87580. export class EdgesRenderer implements IEdgesRenderer {
  87581. /**
  87582. * Define the size of the edges with an orthographic camera
  87583. */
  87584. edgesWidthScalerForOrthographic: number;
  87585. /**
  87586. * Define the size of the edges with a perspective camera
  87587. */
  87588. edgesWidthScalerForPerspective: number;
  87589. protected _source: AbstractMesh;
  87590. protected _linesPositions: number[];
  87591. protected _linesNormals: number[];
  87592. protected _linesIndices: number[];
  87593. protected _epsilon: number;
  87594. protected _indicesCount: number;
  87595. protected _lineShader: ShaderMaterial;
  87596. protected _ib: DataBuffer;
  87597. protected _buffers: {
  87598. [key: string]: Nullable<VertexBuffer>;
  87599. };
  87600. protected _checkVerticesInsteadOfIndices: boolean;
  87601. private _meshRebuildObserver;
  87602. private _meshDisposeObserver;
  87603. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87604. isEnabled: boolean;
  87605. /**
  87606. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87607. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87608. * @param source Mesh used to create edges
  87609. * @param epsilon sum of angles in adjacency to check for edge
  87610. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87611. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87612. */
  87613. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87614. protected _prepareRessources(): void;
  87615. /** @hidden */
  87616. _rebuild(): void;
  87617. /**
  87618. * Releases the required resources for the edges renderer
  87619. */
  87620. dispose(): void;
  87621. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87622. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87623. /**
  87624. * Checks if the pair of p0 and p1 is en edge
  87625. * @param faceIndex
  87626. * @param edge
  87627. * @param faceNormals
  87628. * @param p0
  87629. * @param p1
  87630. * @private
  87631. */
  87632. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87633. /**
  87634. * push line into the position, normal and index buffer
  87635. * @protected
  87636. */
  87637. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87638. /**
  87639. * Generates lines edges from adjacencjes
  87640. * @private
  87641. */
  87642. _generateEdgesLines(): void;
  87643. /**
  87644. * Checks wether or not the edges renderer is ready to render.
  87645. * @return true if ready, otherwise false.
  87646. */
  87647. isReady(): boolean;
  87648. /**
  87649. * Renders the edges of the attached mesh,
  87650. */
  87651. render(): void;
  87652. }
  87653. /**
  87654. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87655. */
  87656. export class LineEdgesRenderer extends EdgesRenderer {
  87657. /**
  87658. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87659. * @param source LineMesh used to generate edges
  87660. * @param epsilon not important (specified angle for edge detection)
  87661. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87662. */
  87663. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87664. /**
  87665. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87666. */
  87667. _generateEdgesLines(): void;
  87668. }
  87669. }
  87670. declare module BABYLON {
  87671. /**
  87672. * This represents the object necessary to create a rendering group.
  87673. * This is exclusively used and created by the rendering manager.
  87674. * To modify the behavior, you use the available helpers in your scene or meshes.
  87675. * @hidden
  87676. */
  87677. export class RenderingGroup {
  87678. index: number;
  87679. private static _zeroVector;
  87680. private _scene;
  87681. private _opaqueSubMeshes;
  87682. private _transparentSubMeshes;
  87683. private _alphaTestSubMeshes;
  87684. private _depthOnlySubMeshes;
  87685. private _particleSystems;
  87686. private _spriteManagers;
  87687. private _opaqueSortCompareFn;
  87688. private _alphaTestSortCompareFn;
  87689. private _transparentSortCompareFn;
  87690. private _renderOpaque;
  87691. private _renderAlphaTest;
  87692. private _renderTransparent;
  87693. /** @hidden */
  87694. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87695. onBeforeTransparentRendering: () => void;
  87696. /**
  87697. * Set the opaque sort comparison function.
  87698. * If null the sub meshes will be render in the order they were created
  87699. */
  87700. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87701. /**
  87702. * Set the alpha test sort comparison function.
  87703. * If null the sub meshes will be render in the order they were created
  87704. */
  87705. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87706. /**
  87707. * Set the transparent sort comparison function.
  87708. * If null the sub meshes will be render in the order they were created
  87709. */
  87710. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87711. /**
  87712. * Creates a new rendering group.
  87713. * @param index The rendering group index
  87714. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87715. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87716. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87717. */
  87718. 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>);
  87719. /**
  87720. * Render all the sub meshes contained in the group.
  87721. * @param customRenderFunction Used to override the default render behaviour of the group.
  87722. * @returns true if rendered some submeshes.
  87723. */
  87724. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87725. /**
  87726. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87727. * @param subMeshes The submeshes to render
  87728. */
  87729. private renderOpaqueSorted;
  87730. /**
  87731. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87732. * @param subMeshes The submeshes to render
  87733. */
  87734. private renderAlphaTestSorted;
  87735. /**
  87736. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87737. * @param subMeshes The submeshes to render
  87738. */
  87739. private renderTransparentSorted;
  87740. /**
  87741. * Renders the submeshes in a specified order.
  87742. * @param subMeshes The submeshes to sort before render
  87743. * @param sortCompareFn The comparison function use to sort
  87744. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87745. * @param transparent Specifies to activate blending if true
  87746. */
  87747. private static renderSorted;
  87748. /**
  87749. * Renders the submeshes in the order they were dispatched (no sort applied).
  87750. * @param subMeshes The submeshes to render
  87751. */
  87752. private static renderUnsorted;
  87753. /**
  87754. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87755. * are rendered back to front if in the same alpha index.
  87756. *
  87757. * @param a The first submesh
  87758. * @param b The second submesh
  87759. * @returns The result of the comparison
  87760. */
  87761. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87762. /**
  87763. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87764. * are rendered back to front.
  87765. *
  87766. * @param a The first submesh
  87767. * @param b The second submesh
  87768. * @returns The result of the comparison
  87769. */
  87770. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87771. /**
  87772. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87773. * are rendered front to back (prevent overdraw).
  87774. *
  87775. * @param a The first submesh
  87776. * @param b The second submesh
  87777. * @returns The result of the comparison
  87778. */
  87779. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87780. /**
  87781. * Resets the different lists of submeshes to prepare a new frame.
  87782. */
  87783. prepare(): void;
  87784. dispose(): void;
  87785. /**
  87786. * Inserts the submesh in its correct queue depending on its material.
  87787. * @param subMesh The submesh to dispatch
  87788. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87789. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87790. */
  87791. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87792. dispatchSprites(spriteManager: ISpriteManager): void;
  87793. dispatchParticles(particleSystem: IParticleSystem): void;
  87794. private _renderParticles;
  87795. private _renderSprites;
  87796. }
  87797. }
  87798. declare module BABYLON {
  87799. /**
  87800. * Interface describing the different options available in the rendering manager
  87801. * regarding Auto Clear between groups.
  87802. */
  87803. export interface IRenderingManagerAutoClearSetup {
  87804. /**
  87805. * Defines whether or not autoclear is enable.
  87806. */
  87807. autoClear: boolean;
  87808. /**
  87809. * Defines whether or not to autoclear the depth buffer.
  87810. */
  87811. depth: boolean;
  87812. /**
  87813. * Defines whether or not to autoclear the stencil buffer.
  87814. */
  87815. stencil: boolean;
  87816. }
  87817. /**
  87818. * This class is used by the onRenderingGroupObservable
  87819. */
  87820. export class RenderingGroupInfo {
  87821. /**
  87822. * The Scene that being rendered
  87823. */
  87824. scene: Scene;
  87825. /**
  87826. * The camera currently used for the rendering pass
  87827. */
  87828. camera: Nullable<Camera>;
  87829. /**
  87830. * The ID of the renderingGroup being processed
  87831. */
  87832. renderingGroupId: number;
  87833. }
  87834. /**
  87835. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87836. * It is enable to manage the different groups as well as the different necessary sort functions.
  87837. * This should not be used directly aside of the few static configurations
  87838. */
  87839. export class RenderingManager {
  87840. /**
  87841. * The max id used for rendering groups (not included)
  87842. */
  87843. static MAX_RENDERINGGROUPS: number;
  87844. /**
  87845. * The min id used for rendering groups (included)
  87846. */
  87847. static MIN_RENDERINGGROUPS: number;
  87848. /**
  87849. * Used to globally prevent autoclearing scenes.
  87850. */
  87851. static AUTOCLEAR: boolean;
  87852. /**
  87853. * @hidden
  87854. */
  87855. _useSceneAutoClearSetup: boolean;
  87856. private _scene;
  87857. private _renderingGroups;
  87858. private _depthStencilBufferAlreadyCleaned;
  87859. private _autoClearDepthStencil;
  87860. private _customOpaqueSortCompareFn;
  87861. private _customAlphaTestSortCompareFn;
  87862. private _customTransparentSortCompareFn;
  87863. private _renderingGroupInfo;
  87864. /**
  87865. * Instantiates a new rendering group for a particular scene
  87866. * @param scene Defines the scene the groups belongs to
  87867. */
  87868. constructor(scene: Scene);
  87869. private _clearDepthStencilBuffer;
  87870. /**
  87871. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87872. * @hidden
  87873. */
  87874. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87875. /**
  87876. * Resets the different information of the group to prepare a new frame
  87877. * @hidden
  87878. */
  87879. reset(): void;
  87880. /**
  87881. * Dispose and release the group and its associated resources.
  87882. * @hidden
  87883. */
  87884. dispose(): void;
  87885. /**
  87886. * Clear the info related to rendering groups preventing retention points during dispose.
  87887. */
  87888. freeRenderingGroups(): void;
  87889. private _prepareRenderingGroup;
  87890. /**
  87891. * Add a sprite manager to the rendering manager in order to render it this frame.
  87892. * @param spriteManager Define the sprite manager to render
  87893. */
  87894. dispatchSprites(spriteManager: ISpriteManager): void;
  87895. /**
  87896. * Add a particle system to the rendering manager in order to render it this frame.
  87897. * @param particleSystem Define the particle system to render
  87898. */
  87899. dispatchParticles(particleSystem: IParticleSystem): void;
  87900. /**
  87901. * Add a submesh to the manager in order to render it this frame
  87902. * @param subMesh The submesh to dispatch
  87903. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87904. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87905. */
  87906. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87907. /**
  87908. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87909. * This allowed control for front to back rendering or reversly depending of the special needs.
  87910. *
  87911. * @param renderingGroupId The rendering group id corresponding to its index
  87912. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87913. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87914. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87915. */
  87916. 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;
  87917. /**
  87918. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87919. *
  87920. * @param renderingGroupId The rendering group id corresponding to its index
  87921. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87922. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87923. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87924. */
  87925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87926. /**
  87927. * Gets the current auto clear configuration for one rendering group of the rendering
  87928. * manager.
  87929. * @param index the rendering group index to get the information for
  87930. * @returns The auto clear setup for the requested rendering group
  87931. */
  87932. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87933. }
  87934. }
  87935. declare module BABYLON {
  87936. /**
  87937. * This Helps creating a texture that will be created from a camera in your scene.
  87938. * It is basically a dynamic texture that could be used to create special effects for instance.
  87939. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87940. */
  87941. export class RenderTargetTexture extends Texture {
  87942. isCube: boolean;
  87943. /**
  87944. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87945. */
  87946. static readonly REFRESHRATE_RENDER_ONCE: number;
  87947. /**
  87948. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87949. */
  87950. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87951. /**
  87952. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87953. * the central point of your effect and can save a lot of performances.
  87954. */
  87955. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87956. /**
  87957. * Use this predicate to dynamically define the list of mesh you want to render.
  87958. * If set, the renderList property will be overwritten.
  87959. */
  87960. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87961. private _renderList;
  87962. /**
  87963. * Use this list to define the list of mesh you want to render.
  87964. */
  87965. renderList: Nullable<Array<AbstractMesh>>;
  87966. private _hookArray;
  87967. /**
  87968. * Define if particles should be rendered in your texture.
  87969. */
  87970. renderParticles: boolean;
  87971. /**
  87972. * Define if sprites should be rendered in your texture.
  87973. */
  87974. renderSprites: boolean;
  87975. /**
  87976. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87977. */
  87978. coordinatesMode: number;
  87979. /**
  87980. * Define the camera used to render the texture.
  87981. */
  87982. activeCamera: Nullable<Camera>;
  87983. /**
  87984. * Override the render function of the texture with your own one.
  87985. */
  87986. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87987. /**
  87988. * Define if camera post processes should be use while rendering the texture.
  87989. */
  87990. useCameraPostProcesses: boolean;
  87991. /**
  87992. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87993. */
  87994. ignoreCameraViewport: boolean;
  87995. private _postProcessManager;
  87996. private _postProcesses;
  87997. private _resizeObserver;
  87998. /**
  87999. * An event triggered when the texture is unbind.
  88000. */
  88001. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88002. /**
  88003. * An event triggered when the texture is unbind.
  88004. */
  88005. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88006. private _onAfterUnbindObserver;
  88007. /**
  88008. * Set a after unbind callback in the texture.
  88009. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88010. */
  88011. onAfterUnbind: () => void;
  88012. /**
  88013. * An event triggered before rendering the texture
  88014. */
  88015. onBeforeRenderObservable: Observable<number>;
  88016. private _onBeforeRenderObserver;
  88017. /**
  88018. * Set a before render callback in the texture.
  88019. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88020. */
  88021. onBeforeRender: (faceIndex: number) => void;
  88022. /**
  88023. * An event triggered after rendering the texture
  88024. */
  88025. onAfterRenderObservable: Observable<number>;
  88026. private _onAfterRenderObserver;
  88027. /**
  88028. * Set a after render callback in the texture.
  88029. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88030. */
  88031. onAfterRender: (faceIndex: number) => void;
  88032. /**
  88033. * An event triggered after the texture clear
  88034. */
  88035. onClearObservable: Observable<Engine>;
  88036. private _onClearObserver;
  88037. /**
  88038. * Set a clear callback in the texture.
  88039. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88040. */
  88041. onClear: (Engine: Engine) => void;
  88042. /**
  88043. * An event triggered when the texture is resized.
  88044. */
  88045. onResizeObservable: Observable<RenderTargetTexture>;
  88046. /**
  88047. * Define the clear color of the Render Target if it should be different from the scene.
  88048. */
  88049. clearColor: Color4;
  88050. protected _size: number | {
  88051. width: number;
  88052. height: number;
  88053. };
  88054. protected _initialSizeParameter: number | {
  88055. width: number;
  88056. height: number;
  88057. } | {
  88058. ratio: number;
  88059. };
  88060. protected _sizeRatio: Nullable<number>;
  88061. /** @hidden */
  88062. _generateMipMaps: boolean;
  88063. protected _renderingManager: RenderingManager;
  88064. /** @hidden */
  88065. _waitingRenderList: string[];
  88066. protected _doNotChangeAspectRatio: boolean;
  88067. protected _currentRefreshId: number;
  88068. protected _refreshRate: number;
  88069. protected _textureMatrix: Matrix;
  88070. protected _samples: number;
  88071. protected _renderTargetOptions: RenderTargetCreationOptions;
  88072. /**
  88073. * Gets render target creation options that were used.
  88074. */
  88075. readonly renderTargetOptions: RenderTargetCreationOptions;
  88076. protected _engine: Engine;
  88077. protected _onRatioRescale(): void;
  88078. /**
  88079. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88080. * It must define where the camera used to render the texture is set
  88081. */
  88082. boundingBoxPosition: Vector3;
  88083. private _boundingBoxSize;
  88084. /**
  88085. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88086. * When defined, the cubemap will switch to local mode
  88087. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88088. * @example https://www.babylonjs-playground.com/#RNASML
  88089. */
  88090. boundingBoxSize: Vector3;
  88091. /**
  88092. * In case the RTT has been created with a depth texture, get the associated
  88093. * depth texture.
  88094. * Otherwise, return null.
  88095. */
  88096. depthStencilTexture: Nullable<InternalTexture>;
  88097. /**
  88098. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88099. * or used a shadow, depth texture...
  88100. * @param name The friendly name of the texture
  88101. * @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)
  88102. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88103. * @param generateMipMaps True if mip maps need to be generated after render.
  88104. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88105. * @param type The type of the buffer in the RTT (int, half float, float...)
  88106. * @param isCube True if a cube texture needs to be created
  88107. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88108. * @param generateDepthBuffer True to generate a depth buffer
  88109. * @param generateStencilBuffer True to generate a stencil buffer
  88110. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88111. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88112. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88113. */
  88114. constructor(name: string, size: number | {
  88115. width: number;
  88116. height: number;
  88117. } | {
  88118. ratio: number;
  88119. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88120. /**
  88121. * Creates a depth stencil texture.
  88122. * This is only available in WebGL 2 or with the depth texture extension available.
  88123. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88124. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88125. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88126. */
  88127. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88128. private _processSizeParameter;
  88129. /**
  88130. * Define the number of samples to use in case of MSAA.
  88131. * It defaults to one meaning no MSAA has been enabled.
  88132. */
  88133. samples: number;
  88134. /**
  88135. * Resets the refresh counter of the texture and start bak from scratch.
  88136. * Could be useful to regenerate the texture if it is setup to render only once.
  88137. */
  88138. resetRefreshCounter(): void;
  88139. /**
  88140. * Define the refresh rate of the texture or the rendering frequency.
  88141. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88142. */
  88143. refreshRate: number;
  88144. /**
  88145. * Adds a post process to the render target rendering passes.
  88146. * @param postProcess define the post process to add
  88147. */
  88148. addPostProcess(postProcess: PostProcess): void;
  88149. /**
  88150. * Clear all the post processes attached to the render target
  88151. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88152. */
  88153. clearPostProcesses(dispose?: boolean): void;
  88154. /**
  88155. * Remove one of the post process from the list of attached post processes to the texture
  88156. * @param postProcess define the post process to remove from the list
  88157. */
  88158. removePostProcess(postProcess: PostProcess): void;
  88159. /** @hidden */
  88160. _shouldRender(): boolean;
  88161. /**
  88162. * Gets the actual render size of the texture.
  88163. * @returns the width of the render size
  88164. */
  88165. getRenderSize(): number;
  88166. /**
  88167. * Gets the actual render width of the texture.
  88168. * @returns the width of the render size
  88169. */
  88170. getRenderWidth(): number;
  88171. /**
  88172. * Gets the actual render height of the texture.
  88173. * @returns the height of the render size
  88174. */
  88175. getRenderHeight(): number;
  88176. /**
  88177. * Get if the texture can be rescaled or not.
  88178. */
  88179. readonly canRescale: boolean;
  88180. /**
  88181. * Resize the texture using a ratio.
  88182. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88183. */
  88184. scale(ratio: number): void;
  88185. /**
  88186. * Get the texture reflection matrix used to rotate/transform the reflection.
  88187. * @returns the reflection matrix
  88188. */
  88189. getReflectionTextureMatrix(): Matrix;
  88190. /**
  88191. * Resize the texture to a new desired size.
  88192. * Be carrefull as it will recreate all the data in the new texture.
  88193. * @param size Define the new size. It can be:
  88194. * - a number for squared texture,
  88195. * - an object containing { width: number, height: number }
  88196. * - or an object containing a ratio { ratio: number }
  88197. */
  88198. resize(size: number | {
  88199. width: number;
  88200. height: number;
  88201. } | {
  88202. ratio: number;
  88203. }): void;
  88204. /**
  88205. * Renders all the objects from the render list into the texture.
  88206. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88207. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88208. */
  88209. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88210. private _bestReflectionRenderTargetDimension;
  88211. /**
  88212. * @hidden
  88213. * @param faceIndex face index to bind to if this is a cubetexture
  88214. */
  88215. _bindFrameBuffer(faceIndex?: number): void;
  88216. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88217. private renderToTarget;
  88218. /**
  88219. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88220. * This allowed control for front to back rendering or reversly depending of the special needs.
  88221. *
  88222. * @param renderingGroupId The rendering group id corresponding to its index
  88223. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88224. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88225. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88226. */
  88227. 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;
  88228. /**
  88229. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88230. *
  88231. * @param renderingGroupId The rendering group id corresponding to its index
  88232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88233. */
  88234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88235. /**
  88236. * Clones the texture.
  88237. * @returns the cloned texture
  88238. */
  88239. clone(): RenderTargetTexture;
  88240. /**
  88241. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88242. * @returns The JSON representation of the texture
  88243. */
  88244. serialize(): any;
  88245. /**
  88246. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88247. */
  88248. disposeFramebufferObjects(): void;
  88249. /**
  88250. * Dispose the texture and release its associated resources.
  88251. */
  88252. dispose(): void;
  88253. /** @hidden */
  88254. _rebuild(): void;
  88255. /**
  88256. * Clear the info related to rendering groups preventing retention point in material dispose.
  88257. */
  88258. freeRenderingGroups(): void;
  88259. /**
  88260. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88261. * @returns the view count
  88262. */
  88263. getViewCount(): number;
  88264. }
  88265. }
  88266. declare module BABYLON {
  88267. /**
  88268. * Options for compiling materials.
  88269. */
  88270. export interface IMaterialCompilationOptions {
  88271. /**
  88272. * Defines whether clip planes are enabled.
  88273. */
  88274. clipPlane: boolean;
  88275. /**
  88276. * Defines whether instances are enabled.
  88277. */
  88278. useInstances: boolean;
  88279. }
  88280. /**
  88281. * Base class for the main features of a material in Babylon.js
  88282. */
  88283. export class Material implements IAnimatable {
  88284. /**
  88285. * Returns the triangle fill mode
  88286. */
  88287. static readonly TriangleFillMode: number;
  88288. /**
  88289. * Returns the wireframe mode
  88290. */
  88291. static readonly WireFrameFillMode: number;
  88292. /**
  88293. * Returns the point fill mode
  88294. */
  88295. static readonly PointFillMode: number;
  88296. /**
  88297. * Returns the point list draw mode
  88298. */
  88299. static readonly PointListDrawMode: number;
  88300. /**
  88301. * Returns the line list draw mode
  88302. */
  88303. static readonly LineListDrawMode: number;
  88304. /**
  88305. * Returns the line loop draw mode
  88306. */
  88307. static readonly LineLoopDrawMode: number;
  88308. /**
  88309. * Returns the line strip draw mode
  88310. */
  88311. static readonly LineStripDrawMode: number;
  88312. /**
  88313. * Returns the triangle strip draw mode
  88314. */
  88315. static readonly TriangleStripDrawMode: number;
  88316. /**
  88317. * Returns the triangle fan draw mode
  88318. */
  88319. static readonly TriangleFanDrawMode: number;
  88320. /**
  88321. * Stores the clock-wise side orientation
  88322. */
  88323. static readonly ClockWiseSideOrientation: number;
  88324. /**
  88325. * Stores the counter clock-wise side orientation
  88326. */
  88327. static readonly CounterClockWiseSideOrientation: number;
  88328. /**
  88329. * The dirty texture flag value
  88330. */
  88331. static readonly TextureDirtyFlag: number;
  88332. /**
  88333. * The dirty light flag value
  88334. */
  88335. static readonly LightDirtyFlag: number;
  88336. /**
  88337. * The dirty fresnel flag value
  88338. */
  88339. static readonly FresnelDirtyFlag: number;
  88340. /**
  88341. * The dirty attribute flag value
  88342. */
  88343. static readonly AttributesDirtyFlag: number;
  88344. /**
  88345. * The dirty misc flag value
  88346. */
  88347. static readonly MiscDirtyFlag: number;
  88348. /**
  88349. * The all dirty flag value
  88350. */
  88351. static readonly AllDirtyFlag: number;
  88352. /**
  88353. * The ID of the material
  88354. */
  88355. id: string;
  88356. /**
  88357. * Gets or sets the unique id of the material
  88358. */
  88359. uniqueId: number;
  88360. /**
  88361. * The name of the material
  88362. */
  88363. name: string;
  88364. /**
  88365. * Gets or sets user defined metadata
  88366. */
  88367. metadata: any;
  88368. /**
  88369. * For internal use only. Please do not use.
  88370. */
  88371. reservedDataStore: any;
  88372. /**
  88373. * Specifies if the ready state should be checked on each call
  88374. */
  88375. checkReadyOnEveryCall: boolean;
  88376. /**
  88377. * Specifies if the ready state should be checked once
  88378. */
  88379. checkReadyOnlyOnce: boolean;
  88380. /**
  88381. * The state of the material
  88382. */
  88383. state: string;
  88384. /**
  88385. * The alpha value of the material
  88386. */
  88387. protected _alpha: number;
  88388. /**
  88389. * List of inspectable custom properties (used by the Inspector)
  88390. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88391. */
  88392. inspectableCustomProperties: IInspectable[];
  88393. /**
  88394. * Sets the alpha value of the material
  88395. */
  88396. /**
  88397. * Gets the alpha value of the material
  88398. */
  88399. alpha: number;
  88400. /**
  88401. * Specifies if back face culling is enabled
  88402. */
  88403. protected _backFaceCulling: boolean;
  88404. /**
  88405. * Sets the back-face culling state
  88406. */
  88407. /**
  88408. * Gets the back-face culling state
  88409. */
  88410. backFaceCulling: boolean;
  88411. /**
  88412. * Stores the value for side orientation
  88413. */
  88414. sideOrientation: number;
  88415. /**
  88416. * Callback triggered when the material is compiled
  88417. */
  88418. onCompiled: Nullable<(effect: Effect) => void>;
  88419. /**
  88420. * Callback triggered when an error occurs
  88421. */
  88422. onError: Nullable<(effect: Effect, errors: string) => void>;
  88423. /**
  88424. * Callback triggered to get the render target textures
  88425. */
  88426. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88427. /**
  88428. * Gets a boolean indicating that current material needs to register RTT
  88429. */
  88430. readonly hasRenderTargetTextures: boolean;
  88431. /**
  88432. * Specifies if the material should be serialized
  88433. */
  88434. doNotSerialize: boolean;
  88435. /**
  88436. * @hidden
  88437. */
  88438. _storeEffectOnSubMeshes: boolean;
  88439. /**
  88440. * Stores the animations for the material
  88441. */
  88442. animations: Nullable<Array<Animation>>;
  88443. /**
  88444. * An event triggered when the material is disposed
  88445. */
  88446. onDisposeObservable: Observable<Material>;
  88447. /**
  88448. * An observer which watches for dispose events
  88449. */
  88450. private _onDisposeObserver;
  88451. private _onUnBindObservable;
  88452. /**
  88453. * Called during a dispose event
  88454. */
  88455. onDispose: () => void;
  88456. private _onBindObservable;
  88457. /**
  88458. * An event triggered when the material is bound
  88459. */
  88460. readonly onBindObservable: Observable<AbstractMesh>;
  88461. /**
  88462. * An observer which watches for bind events
  88463. */
  88464. private _onBindObserver;
  88465. /**
  88466. * Called during a bind event
  88467. */
  88468. onBind: (Mesh: AbstractMesh) => void;
  88469. /**
  88470. * An event triggered when the material is unbound
  88471. */
  88472. readonly onUnBindObservable: Observable<Material>;
  88473. /**
  88474. * Stores the value of the alpha mode
  88475. */
  88476. private _alphaMode;
  88477. /**
  88478. * Sets the value of the alpha mode.
  88479. *
  88480. * | Value | Type | Description |
  88481. * | --- | --- | --- |
  88482. * | 0 | ALPHA_DISABLE | |
  88483. * | 1 | ALPHA_ADD | |
  88484. * | 2 | ALPHA_COMBINE | |
  88485. * | 3 | ALPHA_SUBTRACT | |
  88486. * | 4 | ALPHA_MULTIPLY | |
  88487. * | 5 | ALPHA_MAXIMIZED | |
  88488. * | 6 | ALPHA_ONEONE | |
  88489. * | 7 | ALPHA_PREMULTIPLIED | |
  88490. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88491. * | 9 | ALPHA_INTERPOLATE | |
  88492. * | 10 | ALPHA_SCREENMODE | |
  88493. *
  88494. */
  88495. /**
  88496. * Gets the value of the alpha mode
  88497. */
  88498. alphaMode: number;
  88499. /**
  88500. * Stores the state of the need depth pre-pass value
  88501. */
  88502. private _needDepthPrePass;
  88503. /**
  88504. * Sets the need depth pre-pass value
  88505. */
  88506. /**
  88507. * Gets the depth pre-pass value
  88508. */
  88509. needDepthPrePass: boolean;
  88510. /**
  88511. * Specifies if depth writing should be disabled
  88512. */
  88513. disableDepthWrite: boolean;
  88514. /**
  88515. * Specifies if depth writing should be forced
  88516. */
  88517. forceDepthWrite: boolean;
  88518. /**
  88519. * Specifies if there should be a separate pass for culling
  88520. */
  88521. separateCullingPass: boolean;
  88522. /**
  88523. * Stores the state specifing if fog should be enabled
  88524. */
  88525. private _fogEnabled;
  88526. /**
  88527. * Sets the state for enabling fog
  88528. */
  88529. /**
  88530. * Gets the value of the fog enabled state
  88531. */
  88532. fogEnabled: boolean;
  88533. /**
  88534. * Stores the size of points
  88535. */
  88536. pointSize: number;
  88537. /**
  88538. * Stores the z offset value
  88539. */
  88540. zOffset: number;
  88541. /**
  88542. * Gets a value specifying if wireframe mode is enabled
  88543. */
  88544. /**
  88545. * Sets the state of wireframe mode
  88546. */
  88547. wireframe: boolean;
  88548. /**
  88549. * Gets the value specifying if point clouds are enabled
  88550. */
  88551. /**
  88552. * Sets the state of point cloud mode
  88553. */
  88554. pointsCloud: boolean;
  88555. /**
  88556. * Gets the material fill mode
  88557. */
  88558. /**
  88559. * Sets the material fill mode
  88560. */
  88561. fillMode: number;
  88562. /**
  88563. * @hidden
  88564. * Stores the effects for the material
  88565. */
  88566. _effect: Nullable<Effect>;
  88567. /**
  88568. * @hidden
  88569. * Specifies if the material was previously ready
  88570. */
  88571. _wasPreviouslyReady: boolean;
  88572. /**
  88573. * Specifies if uniform buffers should be used
  88574. */
  88575. private _useUBO;
  88576. /**
  88577. * Stores a reference to the scene
  88578. */
  88579. private _scene;
  88580. /**
  88581. * Stores the fill mode state
  88582. */
  88583. private _fillMode;
  88584. /**
  88585. * Specifies if the depth write state should be cached
  88586. */
  88587. private _cachedDepthWriteState;
  88588. /**
  88589. * Stores the uniform buffer
  88590. */
  88591. protected _uniformBuffer: UniformBuffer;
  88592. /** @hidden */
  88593. _indexInSceneMaterialArray: number;
  88594. /** @hidden */
  88595. meshMap: Nullable<{
  88596. [id: string]: AbstractMesh | undefined;
  88597. }>;
  88598. /**
  88599. * Creates a material instance
  88600. * @param name defines the name of the material
  88601. * @param scene defines the scene to reference
  88602. * @param doNotAdd specifies if the material should be added to the scene
  88603. */
  88604. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88605. /**
  88606. * Returns a string representation of the current material
  88607. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88608. * @returns a string with material information
  88609. */
  88610. toString(fullDetails?: boolean): string;
  88611. /**
  88612. * Gets the class name of the material
  88613. * @returns a string with the class name of the material
  88614. */
  88615. getClassName(): string;
  88616. /**
  88617. * Specifies if updates for the material been locked
  88618. */
  88619. readonly isFrozen: boolean;
  88620. /**
  88621. * Locks updates for the material
  88622. */
  88623. freeze(): void;
  88624. /**
  88625. * Unlocks updates for the material
  88626. */
  88627. unfreeze(): void;
  88628. /**
  88629. * Specifies if the material is ready to be used
  88630. * @param mesh defines the mesh to check
  88631. * @param useInstances specifies if instances should be used
  88632. * @returns a boolean indicating if the material is ready to be used
  88633. */
  88634. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88635. /**
  88636. * Specifies that the submesh is ready to be used
  88637. * @param mesh defines the mesh to check
  88638. * @param subMesh defines which submesh to check
  88639. * @param useInstances specifies that instances should be used
  88640. * @returns a boolean indicating that the submesh is ready or not
  88641. */
  88642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88643. /**
  88644. * Returns the material effect
  88645. * @returns the effect associated with the material
  88646. */
  88647. getEffect(): Nullable<Effect>;
  88648. /**
  88649. * Returns the current scene
  88650. * @returns a Scene
  88651. */
  88652. getScene(): Scene;
  88653. /**
  88654. * Specifies if the material will require alpha blending
  88655. * @returns a boolean specifying if alpha blending is needed
  88656. */
  88657. needAlphaBlending(): boolean;
  88658. /**
  88659. * Specifies if the mesh will require alpha blending
  88660. * @param mesh defines the mesh to check
  88661. * @returns a boolean specifying if alpha blending is needed for the mesh
  88662. */
  88663. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88664. /**
  88665. * Specifies if this material should be rendered in alpha test mode
  88666. * @returns a boolean specifying if an alpha test is needed.
  88667. */
  88668. needAlphaTesting(): boolean;
  88669. /**
  88670. * Gets the texture used for the alpha test
  88671. * @returns the texture to use for alpha testing
  88672. */
  88673. getAlphaTestTexture(): Nullable<BaseTexture>;
  88674. /**
  88675. * Marks the material to indicate that it needs to be re-calculated
  88676. */
  88677. markDirty(): void;
  88678. /** @hidden */
  88679. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88680. /**
  88681. * Binds the material to the mesh
  88682. * @param world defines the world transformation matrix
  88683. * @param mesh defines the mesh to bind the material to
  88684. */
  88685. bind(world: Matrix, mesh?: Mesh): void;
  88686. /**
  88687. * Binds the submesh to the material
  88688. * @param world defines the world transformation matrix
  88689. * @param mesh defines the mesh containing the submesh
  88690. * @param subMesh defines the submesh to bind the material to
  88691. */
  88692. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88693. /**
  88694. * Binds the world matrix to the material
  88695. * @param world defines the world transformation matrix
  88696. */
  88697. bindOnlyWorldMatrix(world: Matrix): void;
  88698. /**
  88699. * Binds the scene's uniform buffer to the effect.
  88700. * @param effect defines the effect to bind to the scene uniform buffer
  88701. * @param sceneUbo defines the uniform buffer storing scene data
  88702. */
  88703. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88704. /**
  88705. * Binds the view matrix to the effect
  88706. * @param effect defines the effect to bind the view matrix to
  88707. */
  88708. bindView(effect: Effect): void;
  88709. /**
  88710. * Binds the view projection matrix to the effect
  88711. * @param effect defines the effect to bind the view projection matrix to
  88712. */
  88713. bindViewProjection(effect: Effect): void;
  88714. /**
  88715. * Specifies if material alpha testing should be turned on for the mesh
  88716. * @param mesh defines the mesh to check
  88717. */
  88718. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88719. /**
  88720. * Processes to execute after binding the material to a mesh
  88721. * @param mesh defines the rendered mesh
  88722. */
  88723. protected _afterBind(mesh?: Mesh): void;
  88724. /**
  88725. * Unbinds the material from the mesh
  88726. */
  88727. unbind(): void;
  88728. /**
  88729. * Gets the active textures from the material
  88730. * @returns an array of textures
  88731. */
  88732. getActiveTextures(): BaseTexture[];
  88733. /**
  88734. * Specifies if the material uses a texture
  88735. * @param texture defines the texture to check against the material
  88736. * @returns a boolean specifying if the material uses the texture
  88737. */
  88738. hasTexture(texture: BaseTexture): boolean;
  88739. /**
  88740. * Makes a duplicate of the material, and gives it a new name
  88741. * @param name defines the new name for the duplicated material
  88742. * @returns the cloned material
  88743. */
  88744. clone(name: string): Nullable<Material>;
  88745. /**
  88746. * Gets the meshes bound to the material
  88747. * @returns an array of meshes bound to the material
  88748. */
  88749. getBindedMeshes(): AbstractMesh[];
  88750. /**
  88751. * Force shader compilation
  88752. * @param mesh defines the mesh associated with this material
  88753. * @param onCompiled defines a function to execute once the material is compiled
  88754. * @param options defines the options to configure the compilation
  88755. * @param onError defines a function to execute if the material fails compiling
  88756. */
  88757. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88758. /**
  88759. * Force shader compilation
  88760. * @param mesh defines the mesh that will use this material
  88761. * @param options defines additional options for compiling the shaders
  88762. * @returns a promise that resolves when the compilation completes
  88763. */
  88764. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88765. private static readonly _AllDirtyCallBack;
  88766. private static readonly _ImageProcessingDirtyCallBack;
  88767. private static readonly _TextureDirtyCallBack;
  88768. private static readonly _FresnelDirtyCallBack;
  88769. private static readonly _MiscDirtyCallBack;
  88770. private static readonly _LightsDirtyCallBack;
  88771. private static readonly _AttributeDirtyCallBack;
  88772. private static _FresnelAndMiscDirtyCallBack;
  88773. private static _TextureAndMiscDirtyCallBack;
  88774. private static readonly _DirtyCallbackArray;
  88775. private static readonly _RunDirtyCallBacks;
  88776. /**
  88777. * Marks a define in the material to indicate that it needs to be re-computed
  88778. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88779. */
  88780. markAsDirty(flag: number): void;
  88781. /**
  88782. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88783. * @param func defines a function which checks material defines against the submeshes
  88784. */
  88785. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88786. /**
  88787. * Indicates that we need to re-calculated for all submeshes
  88788. */
  88789. protected _markAllSubMeshesAsAllDirty(): void;
  88790. /**
  88791. * Indicates that image processing needs to be re-calculated for all submeshes
  88792. */
  88793. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88794. /**
  88795. * Indicates that textures need to be re-calculated for all submeshes
  88796. */
  88797. protected _markAllSubMeshesAsTexturesDirty(): void;
  88798. /**
  88799. * Indicates that fresnel needs to be re-calculated for all submeshes
  88800. */
  88801. protected _markAllSubMeshesAsFresnelDirty(): void;
  88802. /**
  88803. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88804. */
  88805. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88806. /**
  88807. * Indicates that lights need to be re-calculated for all submeshes
  88808. */
  88809. protected _markAllSubMeshesAsLightsDirty(): void;
  88810. /**
  88811. * Indicates that attributes need to be re-calculated for all submeshes
  88812. */
  88813. protected _markAllSubMeshesAsAttributesDirty(): void;
  88814. /**
  88815. * Indicates that misc needs to be re-calculated for all submeshes
  88816. */
  88817. protected _markAllSubMeshesAsMiscDirty(): void;
  88818. /**
  88819. * Indicates that textures and misc need to be re-calculated for all submeshes
  88820. */
  88821. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88822. /**
  88823. * Disposes the material
  88824. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88825. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88826. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88827. */
  88828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88829. /** @hidden */
  88830. private releaseVertexArrayObject;
  88831. /**
  88832. * Serializes this material
  88833. * @returns the serialized material object
  88834. */
  88835. serialize(): any;
  88836. /**
  88837. * Creates a material from parsed material data
  88838. * @param parsedMaterial defines parsed material data
  88839. * @param scene defines the hosting scene
  88840. * @param rootUrl defines the root URL to use to load textures
  88841. * @returns a new material
  88842. */
  88843. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88844. }
  88845. }
  88846. declare module BABYLON {
  88847. /**
  88848. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88849. * separate meshes. This can be use to improve performances.
  88850. * @see http://doc.babylonjs.com/how_to/multi_materials
  88851. */
  88852. export class MultiMaterial extends Material {
  88853. private _subMaterials;
  88854. /**
  88855. * Gets or Sets the list of Materials used within the multi material.
  88856. * They need to be ordered according to the submeshes order in the associated mesh
  88857. */
  88858. subMaterials: Nullable<Material>[];
  88859. /**
  88860. * Function used to align with Node.getChildren()
  88861. * @returns the list of Materials used within the multi material
  88862. */
  88863. getChildren(): Nullable<Material>[];
  88864. /**
  88865. * Instantiates a new Multi Material
  88866. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88867. * separate meshes. This can be use to improve performances.
  88868. * @see http://doc.babylonjs.com/how_to/multi_materials
  88869. * @param name Define the name in the scene
  88870. * @param scene Define the scene the material belongs to
  88871. */
  88872. constructor(name: string, scene: Scene);
  88873. private _hookArray;
  88874. /**
  88875. * Get one of the submaterial by its index in the submaterials array
  88876. * @param index The index to look the sub material at
  88877. * @returns The Material if the index has been defined
  88878. */
  88879. getSubMaterial(index: number): Nullable<Material>;
  88880. /**
  88881. * Get the list of active textures for the whole sub materials list.
  88882. * @returns All the textures that will be used during the rendering
  88883. */
  88884. getActiveTextures(): BaseTexture[];
  88885. /**
  88886. * Gets the current class name of the material e.g. "MultiMaterial"
  88887. * Mainly use in serialization.
  88888. * @returns the class name
  88889. */
  88890. getClassName(): string;
  88891. /**
  88892. * Checks if the material is ready to render the requested sub mesh
  88893. * @param mesh Define the mesh the submesh belongs to
  88894. * @param subMesh Define the sub mesh to look readyness for
  88895. * @param useInstances Define whether or not the material is used with instances
  88896. * @returns true if ready, otherwise false
  88897. */
  88898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88899. /**
  88900. * Clones the current material and its related sub materials
  88901. * @param name Define the name of the newly cloned material
  88902. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88903. * @returns the cloned material
  88904. */
  88905. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88906. /**
  88907. * Serializes the materials into a JSON representation.
  88908. * @returns the JSON representation
  88909. */
  88910. serialize(): any;
  88911. /**
  88912. * Dispose the material and release its associated resources
  88913. * @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)
  88914. * @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)
  88915. * @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)
  88916. */
  88917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88918. /**
  88919. * Creates a MultiMaterial from parsed MultiMaterial data.
  88920. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88921. * @param scene defines the hosting scene
  88922. * @returns a new MultiMaterial
  88923. */
  88924. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88925. }
  88926. }
  88927. declare module BABYLON {
  88928. /**
  88929. * Base class for submeshes
  88930. */
  88931. export class BaseSubMesh {
  88932. /** @hidden */
  88933. _materialDefines: Nullable<MaterialDefines>;
  88934. /** @hidden */
  88935. _materialEffect: Nullable<Effect>;
  88936. /**
  88937. * Gets associated effect
  88938. */
  88939. readonly effect: Nullable<Effect>;
  88940. /**
  88941. * Sets associated effect (effect used to render this submesh)
  88942. * @param effect defines the effect to associate with
  88943. * @param defines defines the set of defines used to compile this effect
  88944. */
  88945. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88946. }
  88947. /**
  88948. * Defines a subdivision inside a mesh
  88949. */
  88950. export class SubMesh extends BaseSubMesh implements ICullable {
  88951. /** the material index to use */
  88952. materialIndex: number;
  88953. /** vertex index start */
  88954. verticesStart: number;
  88955. /** vertices count */
  88956. verticesCount: number;
  88957. /** index start */
  88958. indexStart: number;
  88959. /** indices count */
  88960. indexCount: number;
  88961. /** @hidden */
  88962. _linesIndexCount: number;
  88963. private _mesh;
  88964. private _renderingMesh;
  88965. private _boundingInfo;
  88966. private _linesIndexBuffer;
  88967. /** @hidden */
  88968. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88969. /** @hidden */
  88970. _trianglePlanes: Plane[];
  88971. /** @hidden */
  88972. _lastColliderTransformMatrix: Nullable<Matrix>;
  88973. /** @hidden */
  88974. _renderId: number;
  88975. /** @hidden */
  88976. _alphaIndex: number;
  88977. /** @hidden */
  88978. _distanceToCamera: number;
  88979. /** @hidden */
  88980. _id: number;
  88981. private _currentMaterial;
  88982. /**
  88983. * Add a new submesh to a mesh
  88984. * @param materialIndex defines the material index to use
  88985. * @param verticesStart defines vertex index start
  88986. * @param verticesCount defines vertices count
  88987. * @param indexStart defines index start
  88988. * @param indexCount defines indices count
  88989. * @param mesh defines the parent mesh
  88990. * @param renderingMesh defines an optional rendering mesh
  88991. * @param createBoundingBox defines if bounding box should be created for this submesh
  88992. * @returns the new submesh
  88993. */
  88994. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88995. /**
  88996. * Creates a new submesh
  88997. * @param materialIndex defines the material index to use
  88998. * @param verticesStart defines vertex index start
  88999. * @param verticesCount defines vertices count
  89000. * @param indexStart defines index start
  89001. * @param indexCount defines indices count
  89002. * @param mesh defines the parent mesh
  89003. * @param renderingMesh defines an optional rendering mesh
  89004. * @param createBoundingBox defines if bounding box should be created for this submesh
  89005. */
  89006. constructor(
  89007. /** the material index to use */
  89008. materialIndex: number,
  89009. /** vertex index start */
  89010. verticesStart: number,
  89011. /** vertices count */
  89012. verticesCount: number,
  89013. /** index start */
  89014. indexStart: number,
  89015. /** indices count */
  89016. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89017. /**
  89018. * Returns true if this submesh covers the entire parent mesh
  89019. * @ignorenaming
  89020. */
  89021. readonly IsGlobal: boolean;
  89022. /**
  89023. * Returns the submesh BoudingInfo object
  89024. * @returns current bounding info (or mesh's one if the submesh is global)
  89025. */
  89026. getBoundingInfo(): BoundingInfo;
  89027. /**
  89028. * Sets the submesh BoundingInfo
  89029. * @param boundingInfo defines the new bounding info to use
  89030. * @returns the SubMesh
  89031. */
  89032. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89033. /**
  89034. * Returns the mesh of the current submesh
  89035. * @return the parent mesh
  89036. */
  89037. getMesh(): AbstractMesh;
  89038. /**
  89039. * Returns the rendering mesh of the submesh
  89040. * @returns the rendering mesh (could be different from parent mesh)
  89041. */
  89042. getRenderingMesh(): Mesh;
  89043. /**
  89044. * Returns the submesh material
  89045. * @returns null or the current material
  89046. */
  89047. getMaterial(): Nullable<Material>;
  89048. /**
  89049. * Sets a new updated BoundingInfo object to the submesh
  89050. * @param data defines an optional position array to use to determine the bounding info
  89051. * @returns the SubMesh
  89052. */
  89053. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89054. /** @hidden */
  89055. _checkCollision(collider: Collider): boolean;
  89056. /**
  89057. * Updates the submesh BoundingInfo
  89058. * @param world defines the world matrix to use to update the bounding info
  89059. * @returns the submesh
  89060. */
  89061. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89062. /**
  89063. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89064. * @param frustumPlanes defines the frustum planes
  89065. * @returns true if the submesh is intersecting with the frustum
  89066. */
  89067. isInFrustum(frustumPlanes: Plane[]): boolean;
  89068. /**
  89069. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89070. * @param frustumPlanes defines the frustum planes
  89071. * @returns true if the submesh is inside the frustum
  89072. */
  89073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89074. /**
  89075. * Renders the submesh
  89076. * @param enableAlphaMode defines if alpha needs to be used
  89077. * @returns the submesh
  89078. */
  89079. render(enableAlphaMode: boolean): SubMesh;
  89080. /**
  89081. * @hidden
  89082. */
  89083. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89084. /**
  89085. * Checks if the submesh intersects with a ray
  89086. * @param ray defines the ray to test
  89087. * @returns true is the passed ray intersects the submesh bounding box
  89088. */
  89089. canIntersects(ray: Ray): boolean;
  89090. /**
  89091. * Intersects current submesh with a ray
  89092. * @param ray defines the ray to test
  89093. * @param positions defines mesh's positions array
  89094. * @param indices defines mesh's indices array
  89095. * @param fastCheck defines if only bounding info should be used
  89096. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89097. * @returns intersection info or null if no intersection
  89098. */
  89099. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89100. /** @hidden */
  89101. private _intersectLines;
  89102. /** @hidden */
  89103. private _intersectUnIndexedLines;
  89104. /** @hidden */
  89105. private _intersectTriangles;
  89106. /** @hidden */
  89107. private _intersectUnIndexedTriangles;
  89108. /** @hidden */
  89109. _rebuild(): void;
  89110. /**
  89111. * Creates a new submesh from the passed mesh
  89112. * @param newMesh defines the new hosting mesh
  89113. * @param newRenderingMesh defines an optional rendering mesh
  89114. * @returns the new submesh
  89115. */
  89116. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89117. /**
  89118. * Release associated resources
  89119. */
  89120. dispose(): void;
  89121. /**
  89122. * Gets the class name
  89123. * @returns the string "SubMesh".
  89124. */
  89125. getClassName(): string;
  89126. /**
  89127. * Creates a new submesh from indices data
  89128. * @param materialIndex the index of the main mesh material
  89129. * @param startIndex the index where to start the copy in the mesh indices array
  89130. * @param indexCount the number of indices to copy then from the startIndex
  89131. * @param mesh the main mesh to create the submesh from
  89132. * @param renderingMesh the optional rendering mesh
  89133. * @returns a new submesh
  89134. */
  89135. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89136. }
  89137. }
  89138. declare module BABYLON {
  89139. /**
  89140. * Class used to represent data loading progression
  89141. */
  89142. export class SceneLoaderFlags {
  89143. private static _ForceFullSceneLoadingForIncremental;
  89144. private static _ShowLoadingScreen;
  89145. private static _CleanBoneMatrixWeights;
  89146. private static _loggingLevel;
  89147. /**
  89148. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89149. */
  89150. static ForceFullSceneLoadingForIncremental: boolean;
  89151. /**
  89152. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89153. */
  89154. static ShowLoadingScreen: boolean;
  89155. /**
  89156. * Defines the current logging level (while loading the scene)
  89157. * @ignorenaming
  89158. */
  89159. static loggingLevel: number;
  89160. /**
  89161. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89162. */
  89163. static CleanBoneMatrixWeights: boolean;
  89164. }
  89165. }
  89166. declare module BABYLON {
  89167. /**
  89168. * Class used to store geometry data (vertex buffers + index buffer)
  89169. */
  89170. export class Geometry implements IGetSetVerticesData {
  89171. /**
  89172. * Gets or sets the ID of the geometry
  89173. */
  89174. id: string;
  89175. /**
  89176. * Gets or sets the unique ID of the geometry
  89177. */
  89178. uniqueId: number;
  89179. /**
  89180. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89181. */
  89182. delayLoadState: number;
  89183. /**
  89184. * Gets the file containing the data to load when running in delay load state
  89185. */
  89186. delayLoadingFile: Nullable<string>;
  89187. /**
  89188. * Callback called when the geometry is updated
  89189. */
  89190. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89191. private _scene;
  89192. private _engine;
  89193. private _meshes;
  89194. private _totalVertices;
  89195. /** @hidden */
  89196. _indices: IndicesArray;
  89197. /** @hidden */
  89198. _vertexBuffers: {
  89199. [key: string]: VertexBuffer;
  89200. };
  89201. private _isDisposed;
  89202. private _extend;
  89203. private _boundingBias;
  89204. /** @hidden */
  89205. _delayInfo: Array<string>;
  89206. private _indexBuffer;
  89207. private _indexBufferIsUpdatable;
  89208. /** @hidden */
  89209. _boundingInfo: Nullable<BoundingInfo>;
  89210. /** @hidden */
  89211. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89212. /** @hidden */
  89213. _softwareSkinningFrameId: number;
  89214. private _vertexArrayObjects;
  89215. private _updatable;
  89216. /** @hidden */
  89217. _positions: Nullable<Vector3[]>;
  89218. /**
  89219. * 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
  89220. */
  89221. /**
  89222. * 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
  89223. */
  89224. boundingBias: Vector2;
  89225. /**
  89226. * Static function used to attach a new empty geometry to a mesh
  89227. * @param mesh defines the mesh to attach the geometry to
  89228. * @returns the new Geometry
  89229. */
  89230. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89231. /**
  89232. * Creates a new geometry
  89233. * @param id defines the unique ID
  89234. * @param scene defines the hosting scene
  89235. * @param vertexData defines the VertexData used to get geometry data
  89236. * @param updatable defines if geometry must be updatable (false by default)
  89237. * @param mesh defines the mesh that will be associated with the geometry
  89238. */
  89239. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89240. /**
  89241. * Gets the current extend of the geometry
  89242. */
  89243. readonly extend: {
  89244. minimum: Vector3;
  89245. maximum: Vector3;
  89246. };
  89247. /**
  89248. * Gets the hosting scene
  89249. * @returns the hosting Scene
  89250. */
  89251. getScene(): Scene;
  89252. /**
  89253. * Gets the hosting engine
  89254. * @returns the hosting Engine
  89255. */
  89256. getEngine(): Engine;
  89257. /**
  89258. * Defines if the geometry is ready to use
  89259. * @returns true if the geometry is ready to be used
  89260. */
  89261. isReady(): boolean;
  89262. /**
  89263. * Gets a value indicating that the geometry should not be serialized
  89264. */
  89265. readonly doNotSerialize: boolean;
  89266. /** @hidden */
  89267. _rebuild(): void;
  89268. /**
  89269. * Affects all geometry data in one call
  89270. * @param vertexData defines the geometry data
  89271. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89272. */
  89273. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89274. /**
  89275. * Set specific vertex data
  89276. * @param kind defines the data kind (Position, normal, etc...)
  89277. * @param data defines the vertex data to use
  89278. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89279. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89280. */
  89281. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89282. /**
  89283. * Removes a specific vertex data
  89284. * @param kind defines the data kind (Position, normal, etc...)
  89285. */
  89286. removeVerticesData(kind: string): void;
  89287. /**
  89288. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89289. * @param buffer defines the vertex buffer to use
  89290. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89291. */
  89292. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89293. /**
  89294. * Update a specific vertex buffer
  89295. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89296. * It will do nothing if the buffer is not updatable
  89297. * @param kind defines the data kind (Position, normal, etc...)
  89298. * @param data defines the data to use
  89299. * @param offset defines the offset in the target buffer where to store the data
  89300. * @param useBytes set to true if the offset is in bytes
  89301. */
  89302. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89303. /**
  89304. * Update a specific vertex buffer
  89305. * This function will create a new buffer if the current one is not updatable
  89306. * @param kind defines the data kind (Position, normal, etc...)
  89307. * @param data defines the data to use
  89308. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89309. */
  89310. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89311. private _updateBoundingInfo;
  89312. /** @hidden */
  89313. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89314. /**
  89315. * Gets total number of vertices
  89316. * @returns the total number of vertices
  89317. */
  89318. getTotalVertices(): number;
  89319. /**
  89320. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89321. * @param kind defines the data kind (Position, normal, etc...)
  89322. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89323. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89324. * @returns a float array containing vertex data
  89325. */
  89326. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89327. /**
  89328. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89329. * @param kind defines the data kind (Position, normal, etc...)
  89330. * @returns true if the vertex buffer with the specified kind is updatable
  89331. */
  89332. isVertexBufferUpdatable(kind: string): boolean;
  89333. /**
  89334. * Gets a specific vertex buffer
  89335. * @param kind defines the data kind (Position, normal, etc...)
  89336. * @returns a VertexBuffer
  89337. */
  89338. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89339. /**
  89340. * Returns all vertex buffers
  89341. * @return an object holding all vertex buffers indexed by kind
  89342. */
  89343. getVertexBuffers(): Nullable<{
  89344. [key: string]: VertexBuffer;
  89345. }>;
  89346. /**
  89347. * Gets a boolean indicating if specific vertex buffer is present
  89348. * @param kind defines the data kind (Position, normal, etc...)
  89349. * @returns true if data is present
  89350. */
  89351. isVerticesDataPresent(kind: string): boolean;
  89352. /**
  89353. * Gets a list of all attached data kinds (Position, normal, etc...)
  89354. * @returns a list of string containing all kinds
  89355. */
  89356. getVerticesDataKinds(): string[];
  89357. /**
  89358. * Update index buffer
  89359. * @param indices defines the indices to store in the index buffer
  89360. * @param offset defines the offset in the target buffer where to store the data
  89361. * @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)
  89362. */
  89363. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89364. /**
  89365. * Creates a new index buffer
  89366. * @param indices defines the indices to store in the index buffer
  89367. * @param totalVertices defines the total number of vertices (could be null)
  89368. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89369. */
  89370. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89371. /**
  89372. * Return the total number of indices
  89373. * @returns the total number of indices
  89374. */
  89375. getTotalIndices(): number;
  89376. /**
  89377. * Gets the index buffer array
  89378. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89379. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89380. * @returns the index buffer array
  89381. */
  89382. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89383. /**
  89384. * Gets the index buffer
  89385. * @return the index buffer
  89386. */
  89387. getIndexBuffer(): Nullable<DataBuffer>;
  89388. /** @hidden */
  89389. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89390. /**
  89391. * Release the associated resources for a specific mesh
  89392. * @param mesh defines the source mesh
  89393. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89394. */
  89395. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89396. /**
  89397. * Apply current geometry to a given mesh
  89398. * @param mesh defines the mesh to apply geometry to
  89399. */
  89400. applyToMesh(mesh: Mesh): void;
  89401. private _updateExtend;
  89402. private _applyToMesh;
  89403. private notifyUpdate;
  89404. /**
  89405. * Load the geometry if it was flagged as delay loaded
  89406. * @param scene defines the hosting scene
  89407. * @param onLoaded defines a callback called when the geometry is loaded
  89408. */
  89409. load(scene: Scene, onLoaded?: () => void): void;
  89410. private _queueLoad;
  89411. /**
  89412. * Invert the geometry to move from a right handed system to a left handed one.
  89413. */
  89414. toLeftHanded(): void;
  89415. /** @hidden */
  89416. _resetPointsArrayCache(): void;
  89417. /** @hidden */
  89418. _generatePointsArray(): boolean;
  89419. /**
  89420. * Gets a value indicating if the geometry is disposed
  89421. * @returns true if the geometry was disposed
  89422. */
  89423. isDisposed(): boolean;
  89424. private _disposeVertexArrayObjects;
  89425. /**
  89426. * Free all associated resources
  89427. */
  89428. dispose(): void;
  89429. /**
  89430. * Clone the current geometry into a new geometry
  89431. * @param id defines the unique ID of the new geometry
  89432. * @returns a new geometry object
  89433. */
  89434. copy(id: string): Geometry;
  89435. /**
  89436. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89437. * @return a JSON representation of the current geometry data (without the vertices data)
  89438. */
  89439. serialize(): any;
  89440. private toNumberArray;
  89441. /**
  89442. * Serialize all vertices data into a JSON oject
  89443. * @returns a JSON representation of the current geometry data
  89444. */
  89445. serializeVerticeData(): any;
  89446. /**
  89447. * Extracts a clone of a mesh geometry
  89448. * @param mesh defines the source mesh
  89449. * @param id defines the unique ID of the new geometry object
  89450. * @returns the new geometry object
  89451. */
  89452. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89453. /**
  89454. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89455. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89456. * Be aware Math.random() could cause collisions, but:
  89457. * "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"
  89458. * @returns a string containing a new GUID
  89459. */
  89460. static RandomId(): string;
  89461. /** @hidden */
  89462. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89463. private static _CleanMatricesWeights;
  89464. /**
  89465. * Create a new geometry from persisted data (Using .babylon file format)
  89466. * @param parsedVertexData defines the persisted data
  89467. * @param scene defines the hosting scene
  89468. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89469. * @returns the new geometry object
  89470. */
  89471. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89472. }
  89473. }
  89474. declare module BABYLON {
  89475. /**
  89476. * Define an interface for all classes that will get and set the data on vertices
  89477. */
  89478. export interface IGetSetVerticesData {
  89479. /**
  89480. * Gets a boolean indicating if specific vertex data is present
  89481. * @param kind defines the vertex data kind to use
  89482. * @returns true is data kind is present
  89483. */
  89484. isVerticesDataPresent(kind: string): boolean;
  89485. /**
  89486. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89487. * @param kind defines the data kind (Position, normal, etc...)
  89488. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89489. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89490. * @returns a float array containing vertex data
  89491. */
  89492. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89493. /**
  89494. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89495. * @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.
  89496. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89497. * @returns the indices array or an empty array if the mesh has no geometry
  89498. */
  89499. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89500. /**
  89501. * Set specific vertex data
  89502. * @param kind defines the data kind (Position, normal, etc...)
  89503. * @param data defines the vertex data to use
  89504. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89505. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89506. */
  89507. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89508. /**
  89509. * Update a specific associated vertex buffer
  89510. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89511. * - VertexBuffer.PositionKind
  89512. * - VertexBuffer.UVKind
  89513. * - VertexBuffer.UV2Kind
  89514. * - VertexBuffer.UV3Kind
  89515. * - VertexBuffer.UV4Kind
  89516. * - VertexBuffer.UV5Kind
  89517. * - VertexBuffer.UV6Kind
  89518. * - VertexBuffer.ColorKind
  89519. * - VertexBuffer.MatricesIndicesKind
  89520. * - VertexBuffer.MatricesIndicesExtraKind
  89521. * - VertexBuffer.MatricesWeightsKind
  89522. * - VertexBuffer.MatricesWeightsExtraKind
  89523. * @param data defines the data source
  89524. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89525. * @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)
  89526. */
  89527. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89528. /**
  89529. * Creates a new index buffer
  89530. * @param indices defines the indices to store in the index buffer
  89531. * @param totalVertices defines the total number of vertices (could be null)
  89532. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89533. */
  89534. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89535. }
  89536. /**
  89537. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89538. */
  89539. export class VertexData {
  89540. /**
  89541. * Mesh side orientation : usually the external or front surface
  89542. */
  89543. static readonly FRONTSIDE: number;
  89544. /**
  89545. * Mesh side orientation : usually the internal or back surface
  89546. */
  89547. static readonly BACKSIDE: number;
  89548. /**
  89549. * Mesh side orientation : both internal and external or front and back surfaces
  89550. */
  89551. static readonly DOUBLESIDE: number;
  89552. /**
  89553. * Mesh side orientation : by default, `FRONTSIDE`
  89554. */
  89555. static readonly DEFAULTSIDE: number;
  89556. /**
  89557. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89558. */
  89559. positions: Nullable<FloatArray>;
  89560. /**
  89561. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89562. */
  89563. normals: Nullable<FloatArray>;
  89564. /**
  89565. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89566. */
  89567. tangents: Nullable<FloatArray>;
  89568. /**
  89569. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89570. */
  89571. uvs: Nullable<FloatArray>;
  89572. /**
  89573. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89574. */
  89575. uvs2: Nullable<FloatArray>;
  89576. /**
  89577. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89578. */
  89579. uvs3: Nullable<FloatArray>;
  89580. /**
  89581. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89582. */
  89583. uvs4: Nullable<FloatArray>;
  89584. /**
  89585. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89586. */
  89587. uvs5: Nullable<FloatArray>;
  89588. /**
  89589. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89590. */
  89591. uvs6: Nullable<FloatArray>;
  89592. /**
  89593. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89594. */
  89595. colors: Nullable<FloatArray>;
  89596. /**
  89597. * 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).
  89598. */
  89599. matricesIndices: Nullable<FloatArray>;
  89600. /**
  89601. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89602. */
  89603. matricesWeights: Nullable<FloatArray>;
  89604. /**
  89605. * An array extending the number of possible indices
  89606. */
  89607. matricesIndicesExtra: Nullable<FloatArray>;
  89608. /**
  89609. * An array extending the number of possible weights when the number of indices is extended
  89610. */
  89611. matricesWeightsExtra: Nullable<FloatArray>;
  89612. /**
  89613. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89614. */
  89615. indices: Nullable<IndicesArray>;
  89616. /**
  89617. * Uses the passed data array to set the set the values for the specified kind of data
  89618. * @param data a linear array of floating numbers
  89619. * @param kind the type of data that is being set, eg positions, colors etc
  89620. */
  89621. set(data: FloatArray, kind: string): void;
  89622. /**
  89623. * Associates the vertexData to the passed Mesh.
  89624. * Sets it as updatable or not (default `false`)
  89625. * @param mesh the mesh the vertexData is applied to
  89626. * @param updatable when used and having the value true allows new data to update the vertexData
  89627. * @returns the VertexData
  89628. */
  89629. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89630. /**
  89631. * Associates the vertexData to the passed Geometry.
  89632. * Sets it as updatable or not (default `false`)
  89633. * @param geometry the geometry the vertexData is applied to
  89634. * @param updatable when used and having the value true allows new data to update the vertexData
  89635. * @returns VertexData
  89636. */
  89637. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89638. /**
  89639. * Updates the associated mesh
  89640. * @param mesh the mesh to be updated
  89641. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89642. * @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
  89643. * @returns VertexData
  89644. */
  89645. updateMesh(mesh: Mesh): VertexData;
  89646. /**
  89647. * Updates the associated geometry
  89648. * @param geometry the geometry to be updated
  89649. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89650. * @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
  89651. * @returns VertexData.
  89652. */
  89653. updateGeometry(geometry: Geometry): VertexData;
  89654. private _applyTo;
  89655. private _update;
  89656. /**
  89657. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89658. * @param matrix the transforming matrix
  89659. * @returns the VertexData
  89660. */
  89661. transform(matrix: Matrix): VertexData;
  89662. /**
  89663. * Merges the passed VertexData into the current one
  89664. * @param other the VertexData to be merged into the current one
  89665. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89666. * @returns the modified VertexData
  89667. */
  89668. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89669. private _mergeElement;
  89670. private _validate;
  89671. /**
  89672. * Serializes the VertexData
  89673. * @returns a serialized object
  89674. */
  89675. serialize(): any;
  89676. /**
  89677. * Extracts the vertexData from a mesh
  89678. * @param mesh the mesh from which to extract the VertexData
  89679. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89680. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89681. * @returns the object VertexData associated to the passed mesh
  89682. */
  89683. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89684. /**
  89685. * Extracts the vertexData from the geometry
  89686. * @param geometry the geometry from which to extract the VertexData
  89687. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89688. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89689. * @returns the object VertexData associated to the passed mesh
  89690. */
  89691. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89692. private static _ExtractFrom;
  89693. /**
  89694. * Creates the VertexData for a Ribbon
  89695. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89696. * * pathArray array of paths, each of which an array of successive Vector3
  89697. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89698. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89699. * * 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
  89700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89701. * * 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)
  89702. * * 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)
  89703. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89704. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89705. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89706. * @returns the VertexData of the ribbon
  89707. */
  89708. static CreateRibbon(options: {
  89709. pathArray: Vector3[][];
  89710. closeArray?: boolean;
  89711. closePath?: boolean;
  89712. offset?: number;
  89713. sideOrientation?: number;
  89714. frontUVs?: Vector4;
  89715. backUVs?: Vector4;
  89716. invertUV?: boolean;
  89717. uvs?: Vector2[];
  89718. colors?: Color4[];
  89719. }): VertexData;
  89720. /**
  89721. * Creates the VertexData for a box
  89722. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89723. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89724. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89725. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89726. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89727. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89728. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89730. * * 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)
  89731. * * 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)
  89732. * @returns the VertexData of the box
  89733. */
  89734. static CreateBox(options: {
  89735. size?: number;
  89736. width?: number;
  89737. height?: number;
  89738. depth?: number;
  89739. faceUV?: Vector4[];
  89740. faceColors?: Color4[];
  89741. sideOrientation?: number;
  89742. frontUVs?: Vector4;
  89743. backUVs?: Vector4;
  89744. }): VertexData;
  89745. /**
  89746. * Creates the VertexData for a tiled box
  89747. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89748. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89749. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89750. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89751. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89752. * @returns the VertexData of the box
  89753. */
  89754. static CreateTiledBox(options: {
  89755. pattern?: number;
  89756. width?: number;
  89757. height?: number;
  89758. depth?: number;
  89759. tileSize?: number;
  89760. tileWidth?: number;
  89761. tileHeight?: number;
  89762. alignHorizontal?: number;
  89763. alignVertical?: number;
  89764. faceUV?: Vector4[];
  89765. faceColors?: Color4[];
  89766. sideOrientation?: number;
  89767. }): VertexData;
  89768. /**
  89769. * Creates the VertexData for a tiled plane
  89770. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89771. * * pattern a limited pattern arrangement depending on the number
  89772. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89773. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89774. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89776. * * 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)
  89777. * * 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)
  89778. * @returns the VertexData of the tiled plane
  89779. */
  89780. static CreateTiledPlane(options: {
  89781. pattern?: number;
  89782. tileSize?: number;
  89783. tileWidth?: number;
  89784. tileHeight?: number;
  89785. size?: number;
  89786. width?: number;
  89787. height?: number;
  89788. alignHorizontal?: number;
  89789. alignVertical?: number;
  89790. sideOrientation?: number;
  89791. frontUVs?: Vector4;
  89792. backUVs?: Vector4;
  89793. }): VertexData;
  89794. /**
  89795. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89796. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89797. * * segments sets the number of horizontal strips optional, default 32
  89798. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89799. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89800. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89801. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89802. * * 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
  89803. * * 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
  89804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89805. * * 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)
  89806. * * 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)
  89807. * @returns the VertexData of the ellipsoid
  89808. */
  89809. static CreateSphere(options: {
  89810. segments?: number;
  89811. diameter?: number;
  89812. diameterX?: number;
  89813. diameterY?: number;
  89814. diameterZ?: number;
  89815. arc?: number;
  89816. slice?: number;
  89817. sideOrientation?: number;
  89818. frontUVs?: Vector4;
  89819. backUVs?: Vector4;
  89820. }): VertexData;
  89821. /**
  89822. * Creates the VertexData for a cylinder, cone or prism
  89823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89824. * * height sets the height (y direction) of the cylinder, optional, default 2
  89825. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89826. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89827. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89828. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89829. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89830. * * 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
  89831. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89832. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89833. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89834. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89836. * * 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)
  89837. * * 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)
  89838. * @returns the VertexData of the cylinder, cone or prism
  89839. */
  89840. static CreateCylinder(options: {
  89841. height?: number;
  89842. diameterTop?: number;
  89843. diameterBottom?: number;
  89844. diameter?: number;
  89845. tessellation?: number;
  89846. subdivisions?: number;
  89847. arc?: number;
  89848. faceColors?: Color4[];
  89849. faceUV?: Vector4[];
  89850. hasRings?: boolean;
  89851. enclose?: boolean;
  89852. sideOrientation?: number;
  89853. frontUVs?: Vector4;
  89854. backUVs?: Vector4;
  89855. }): VertexData;
  89856. /**
  89857. * Creates the VertexData for a torus
  89858. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89859. * * diameter the diameter of the torus, optional default 1
  89860. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89861. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89862. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89863. * * 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)
  89864. * * 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)
  89865. * @returns the VertexData of the torus
  89866. */
  89867. static CreateTorus(options: {
  89868. diameter?: number;
  89869. thickness?: number;
  89870. tessellation?: number;
  89871. sideOrientation?: number;
  89872. frontUVs?: Vector4;
  89873. backUVs?: Vector4;
  89874. }): VertexData;
  89875. /**
  89876. * Creates the VertexData of the LineSystem
  89877. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89878. * - lines an array of lines, each line being an array of successive Vector3
  89879. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89880. * @returns the VertexData of the LineSystem
  89881. */
  89882. static CreateLineSystem(options: {
  89883. lines: Vector3[][];
  89884. colors?: Nullable<Color4[][]>;
  89885. }): VertexData;
  89886. /**
  89887. * Create the VertexData for a DashedLines
  89888. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89889. * - points an array successive Vector3
  89890. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89891. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89892. * - dashNb the intended total number of dashes, optional, default 200
  89893. * @returns the VertexData for the DashedLines
  89894. */
  89895. static CreateDashedLines(options: {
  89896. points: Vector3[];
  89897. dashSize?: number;
  89898. gapSize?: number;
  89899. dashNb?: number;
  89900. }): VertexData;
  89901. /**
  89902. * Creates the VertexData for a Ground
  89903. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89904. * - width the width (x direction) of the ground, optional, default 1
  89905. * - height the height (z direction) of the ground, optional, default 1
  89906. * - subdivisions the number of subdivisions per side, optional, default 1
  89907. * @returns the VertexData of the Ground
  89908. */
  89909. static CreateGround(options: {
  89910. width?: number;
  89911. height?: number;
  89912. subdivisions?: number;
  89913. subdivisionsX?: number;
  89914. subdivisionsY?: number;
  89915. }): VertexData;
  89916. /**
  89917. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89918. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89919. * * xmin the ground minimum X coordinate, optional, default -1
  89920. * * zmin the ground minimum Z coordinate, optional, default -1
  89921. * * xmax the ground maximum X coordinate, optional, default 1
  89922. * * zmax the ground maximum Z coordinate, optional, default 1
  89923. * * 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}
  89924. * * 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}
  89925. * @returns the VertexData of the TiledGround
  89926. */
  89927. static CreateTiledGround(options: {
  89928. xmin: number;
  89929. zmin: number;
  89930. xmax: number;
  89931. zmax: number;
  89932. subdivisions?: {
  89933. w: number;
  89934. h: number;
  89935. };
  89936. precision?: {
  89937. w: number;
  89938. h: number;
  89939. };
  89940. }): VertexData;
  89941. /**
  89942. * Creates the VertexData of the Ground designed from a heightmap
  89943. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89944. * * width the width (x direction) of the ground
  89945. * * height the height (z direction) of the ground
  89946. * * subdivisions the number of subdivisions per side
  89947. * * minHeight the minimum altitude on the ground, optional, default 0
  89948. * * maxHeight the maximum altitude on the ground, optional default 1
  89949. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89950. * * buffer the array holding the image color data
  89951. * * bufferWidth the width of image
  89952. * * bufferHeight the height of image
  89953. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89954. * @returns the VertexData of the Ground designed from a heightmap
  89955. */
  89956. static CreateGroundFromHeightMap(options: {
  89957. width: number;
  89958. height: number;
  89959. subdivisions: number;
  89960. minHeight: number;
  89961. maxHeight: number;
  89962. colorFilter: Color3;
  89963. buffer: Uint8Array;
  89964. bufferWidth: number;
  89965. bufferHeight: number;
  89966. alphaFilter: number;
  89967. }): VertexData;
  89968. /**
  89969. * Creates the VertexData for a Plane
  89970. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89971. * * size sets the width and height of the plane to the value of size, optional default 1
  89972. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89973. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89975. * * 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)
  89976. * * 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)
  89977. * @returns the VertexData of the box
  89978. */
  89979. static CreatePlane(options: {
  89980. size?: number;
  89981. width?: number;
  89982. height?: number;
  89983. sideOrientation?: number;
  89984. frontUVs?: Vector4;
  89985. backUVs?: Vector4;
  89986. }): VertexData;
  89987. /**
  89988. * Creates the VertexData of the Disc or regular Polygon
  89989. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89990. * * radius the radius of the disc, optional default 0.5
  89991. * * tessellation the number of polygon sides, optional, default 64
  89992. * * 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
  89993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89994. * * 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)
  89995. * * 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)
  89996. * @returns the VertexData of the box
  89997. */
  89998. static CreateDisc(options: {
  89999. radius?: number;
  90000. tessellation?: number;
  90001. arc?: number;
  90002. sideOrientation?: number;
  90003. frontUVs?: Vector4;
  90004. backUVs?: Vector4;
  90005. }): VertexData;
  90006. /**
  90007. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90008. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90009. * @param polygon a mesh built from polygonTriangulation.build()
  90010. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90011. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90012. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90013. * @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)
  90014. * @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)
  90015. * @returns the VertexData of the Polygon
  90016. */
  90017. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90018. /**
  90019. * Creates the VertexData of the IcoSphere
  90020. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90021. * * radius the radius of the IcoSphere, optional default 1
  90022. * * radiusX allows stretching in the x direction, optional, default radius
  90023. * * radiusY allows stretching in the y direction, optional, default radius
  90024. * * radiusZ allows stretching in the z direction, optional, default radius
  90025. * * flat when true creates a flat shaded mesh, optional, default true
  90026. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90028. * * 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)
  90029. * * 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)
  90030. * @returns the VertexData of the IcoSphere
  90031. */
  90032. static CreateIcoSphere(options: {
  90033. radius?: number;
  90034. radiusX?: number;
  90035. radiusY?: number;
  90036. radiusZ?: number;
  90037. flat?: boolean;
  90038. subdivisions?: number;
  90039. sideOrientation?: number;
  90040. frontUVs?: Vector4;
  90041. backUVs?: Vector4;
  90042. }): VertexData;
  90043. /**
  90044. * Creates the VertexData for a Polyhedron
  90045. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90046. * * type provided types are:
  90047. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90048. * * 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)
  90049. * * size the size of the IcoSphere, optional default 1
  90050. * * sizeX allows stretching in the x direction, optional, default size
  90051. * * sizeY allows stretching in the y direction, optional, default size
  90052. * * sizeZ allows stretching in the z direction, optional, default size
  90053. * * 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
  90054. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90055. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90056. * * flat when true creates a flat shaded mesh, optional, default true
  90057. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90059. * * 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)
  90060. * * 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)
  90061. * @returns the VertexData of the Polyhedron
  90062. */
  90063. static CreatePolyhedron(options: {
  90064. type?: number;
  90065. size?: number;
  90066. sizeX?: number;
  90067. sizeY?: number;
  90068. sizeZ?: number;
  90069. custom?: any;
  90070. faceUV?: Vector4[];
  90071. faceColors?: Color4[];
  90072. flat?: boolean;
  90073. sideOrientation?: number;
  90074. frontUVs?: Vector4;
  90075. backUVs?: Vector4;
  90076. }): VertexData;
  90077. /**
  90078. * Creates the VertexData for a TorusKnot
  90079. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90080. * * radius the radius of the torus knot, optional, default 2
  90081. * * tube the thickness of the tube, optional, default 0.5
  90082. * * radialSegments the number of sides on each tube segments, optional, default 32
  90083. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90084. * * p the number of windings around the z axis, optional, default 2
  90085. * * q the number of windings around the x axis, optional, default 3
  90086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90087. * * 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)
  90088. * * 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)
  90089. * @returns the VertexData of the Torus Knot
  90090. */
  90091. static CreateTorusKnot(options: {
  90092. radius?: number;
  90093. tube?: number;
  90094. radialSegments?: number;
  90095. tubularSegments?: number;
  90096. p?: number;
  90097. q?: number;
  90098. sideOrientation?: number;
  90099. frontUVs?: Vector4;
  90100. backUVs?: Vector4;
  90101. }): VertexData;
  90102. /**
  90103. * Compute normals for given positions and indices
  90104. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90105. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90106. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90107. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90108. * * facetNormals : optional array of facet normals (vector3)
  90109. * * facetPositions : optional array of facet positions (vector3)
  90110. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90111. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90112. * * bInfo : optional bounding info, required for facetPartitioning computation
  90113. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90114. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90115. * * useRightHandedSystem: optional boolean to for right handed system computation
  90116. * * depthSort : optional boolean to enable the facet depth sort computation
  90117. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90118. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90119. */
  90120. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90121. facetNormals?: any;
  90122. facetPositions?: any;
  90123. facetPartitioning?: any;
  90124. ratio?: number;
  90125. bInfo?: any;
  90126. bbSize?: Vector3;
  90127. subDiv?: any;
  90128. useRightHandedSystem?: boolean;
  90129. depthSort?: boolean;
  90130. distanceTo?: Vector3;
  90131. depthSortedFacets?: any;
  90132. }): void;
  90133. /** @hidden */
  90134. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90135. /**
  90136. * Applies VertexData created from the imported parameters to the geometry
  90137. * @param parsedVertexData the parsed data from an imported file
  90138. * @param geometry the geometry to apply the VertexData to
  90139. */
  90140. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90141. }
  90142. }
  90143. declare module BABYLON {
  90144. /**
  90145. * Defines a target to use with MorphTargetManager
  90146. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90147. */
  90148. export class MorphTarget implements IAnimatable {
  90149. /** defines the name of the target */
  90150. name: string;
  90151. /**
  90152. * Gets or sets the list of animations
  90153. */
  90154. animations: Animation[];
  90155. private _scene;
  90156. private _positions;
  90157. private _normals;
  90158. private _tangents;
  90159. private _uvs;
  90160. private _influence;
  90161. private _uniqueId;
  90162. /**
  90163. * Observable raised when the influence changes
  90164. */
  90165. onInfluenceChanged: Observable<boolean>;
  90166. /** @hidden */
  90167. _onDataLayoutChanged: Observable<void>;
  90168. /**
  90169. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90170. */
  90171. influence: number;
  90172. /**
  90173. * Gets or sets the id of the morph Target
  90174. */
  90175. id: string;
  90176. private _animationPropertiesOverride;
  90177. /**
  90178. * Gets or sets the animation properties override
  90179. */
  90180. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90181. /**
  90182. * Creates a new MorphTarget
  90183. * @param name defines the name of the target
  90184. * @param influence defines the influence to use
  90185. * @param scene defines the scene the morphtarget belongs to
  90186. */
  90187. constructor(
  90188. /** defines the name of the target */
  90189. name: string, influence?: number, scene?: Nullable<Scene>);
  90190. /**
  90191. * Gets the unique ID of this manager
  90192. */
  90193. readonly uniqueId: number;
  90194. /**
  90195. * Gets a boolean defining if the target contains position data
  90196. */
  90197. readonly hasPositions: boolean;
  90198. /**
  90199. * Gets a boolean defining if the target contains normal data
  90200. */
  90201. readonly hasNormals: boolean;
  90202. /**
  90203. * Gets a boolean defining if the target contains tangent data
  90204. */
  90205. readonly hasTangents: boolean;
  90206. /**
  90207. * Gets a boolean defining if the target contains texture coordinates data
  90208. */
  90209. readonly hasUVs: boolean;
  90210. /**
  90211. * Affects position data to this target
  90212. * @param data defines the position data to use
  90213. */
  90214. setPositions(data: Nullable<FloatArray>): void;
  90215. /**
  90216. * Gets the position data stored in this target
  90217. * @returns a FloatArray containing the position data (or null if not present)
  90218. */
  90219. getPositions(): Nullable<FloatArray>;
  90220. /**
  90221. * Affects normal data to this target
  90222. * @param data defines the normal data to use
  90223. */
  90224. setNormals(data: Nullable<FloatArray>): void;
  90225. /**
  90226. * Gets the normal data stored in this target
  90227. * @returns a FloatArray containing the normal data (or null if not present)
  90228. */
  90229. getNormals(): Nullable<FloatArray>;
  90230. /**
  90231. * Affects tangent data to this target
  90232. * @param data defines the tangent data to use
  90233. */
  90234. setTangents(data: Nullable<FloatArray>): void;
  90235. /**
  90236. * Gets the tangent data stored in this target
  90237. * @returns a FloatArray containing the tangent data (or null if not present)
  90238. */
  90239. getTangents(): Nullable<FloatArray>;
  90240. /**
  90241. * Affects texture coordinates data to this target
  90242. * @param data defines the texture coordinates data to use
  90243. */
  90244. setUVs(data: Nullable<FloatArray>): void;
  90245. /**
  90246. * Gets the texture coordinates data stored in this target
  90247. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90248. */
  90249. getUVs(): Nullable<FloatArray>;
  90250. /**
  90251. * Clone the current target
  90252. * @returns a new MorphTarget
  90253. */
  90254. clone(): MorphTarget;
  90255. /**
  90256. * Serializes the current target into a Serialization object
  90257. * @returns the serialized object
  90258. */
  90259. serialize(): any;
  90260. /**
  90261. * Returns the string "MorphTarget"
  90262. * @returns "MorphTarget"
  90263. */
  90264. getClassName(): string;
  90265. /**
  90266. * Creates a new target from serialized data
  90267. * @param serializationObject defines the serialized data to use
  90268. * @returns a new MorphTarget
  90269. */
  90270. static Parse(serializationObject: any): MorphTarget;
  90271. /**
  90272. * Creates a MorphTarget from mesh data
  90273. * @param mesh defines the source mesh
  90274. * @param name defines the name to use for the new target
  90275. * @param influence defines the influence to attach to the target
  90276. * @returns a new MorphTarget
  90277. */
  90278. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90279. }
  90280. }
  90281. declare module BABYLON {
  90282. /**
  90283. * This class is used to deform meshes using morphing between different targets
  90284. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90285. */
  90286. export class MorphTargetManager {
  90287. private _targets;
  90288. private _targetInfluenceChangedObservers;
  90289. private _targetDataLayoutChangedObservers;
  90290. private _activeTargets;
  90291. private _scene;
  90292. private _influences;
  90293. private _supportsNormals;
  90294. private _supportsTangents;
  90295. private _supportsUVs;
  90296. private _vertexCount;
  90297. private _uniqueId;
  90298. private _tempInfluences;
  90299. /**
  90300. * Gets or sets a boolean indicating if normals must be morphed
  90301. */
  90302. enableNormalMorphing: boolean;
  90303. /**
  90304. * Gets or sets a boolean indicating if tangents must be morphed
  90305. */
  90306. enableTangentMorphing: boolean;
  90307. /**
  90308. * Gets or sets a boolean indicating if UV must be morphed
  90309. */
  90310. enableUVMorphing: boolean;
  90311. /**
  90312. * Creates a new MorphTargetManager
  90313. * @param scene defines the current scene
  90314. */
  90315. constructor(scene?: Nullable<Scene>);
  90316. /**
  90317. * Gets the unique ID of this manager
  90318. */
  90319. readonly uniqueId: number;
  90320. /**
  90321. * Gets the number of vertices handled by this manager
  90322. */
  90323. readonly vertexCount: number;
  90324. /**
  90325. * Gets a boolean indicating if this manager supports morphing of normals
  90326. */
  90327. readonly supportsNormals: boolean;
  90328. /**
  90329. * Gets a boolean indicating if this manager supports morphing of tangents
  90330. */
  90331. readonly supportsTangents: boolean;
  90332. /**
  90333. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90334. */
  90335. readonly supportsUVs: boolean;
  90336. /**
  90337. * Gets the number of targets stored in this manager
  90338. */
  90339. readonly numTargets: number;
  90340. /**
  90341. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90342. */
  90343. readonly numInfluencers: number;
  90344. /**
  90345. * Gets the list of influences (one per target)
  90346. */
  90347. readonly influences: Float32Array;
  90348. /**
  90349. * Gets the active target at specified index. An active target is a target with an influence > 0
  90350. * @param index defines the index to check
  90351. * @returns the requested target
  90352. */
  90353. getActiveTarget(index: number): MorphTarget;
  90354. /**
  90355. * Gets the target at specified index
  90356. * @param index defines the index to check
  90357. * @returns the requested target
  90358. */
  90359. getTarget(index: number): MorphTarget;
  90360. /**
  90361. * Add a new target to this manager
  90362. * @param target defines the target to add
  90363. */
  90364. addTarget(target: MorphTarget): void;
  90365. /**
  90366. * Removes a target from the manager
  90367. * @param target defines the target to remove
  90368. */
  90369. removeTarget(target: MorphTarget): void;
  90370. /**
  90371. * Clone the current manager
  90372. * @returns a new MorphTargetManager
  90373. */
  90374. clone(): MorphTargetManager;
  90375. /**
  90376. * Serializes the current manager into a Serialization object
  90377. * @returns the serialized object
  90378. */
  90379. serialize(): any;
  90380. private _syncActiveTargets;
  90381. /**
  90382. * Syncrhonize the targets with all the meshes using this morph target manager
  90383. */
  90384. synchronize(): void;
  90385. /**
  90386. * Creates a new MorphTargetManager from serialized data
  90387. * @param serializationObject defines the serialized data
  90388. * @param scene defines the hosting scene
  90389. * @returns the new MorphTargetManager
  90390. */
  90391. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90392. }
  90393. }
  90394. declare module BABYLON {
  90395. /**
  90396. * Class used to represent a specific level of detail of a mesh
  90397. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90398. */
  90399. export class MeshLODLevel {
  90400. /** Defines the distance where this level should start being displayed */
  90401. distance: number;
  90402. /** Defines the mesh to use to render this level */
  90403. mesh: Nullable<Mesh>;
  90404. /**
  90405. * Creates a new LOD level
  90406. * @param distance defines the distance where this level should star being displayed
  90407. * @param mesh defines the mesh to use to render this level
  90408. */
  90409. constructor(
  90410. /** Defines the distance where this level should start being displayed */
  90411. distance: number,
  90412. /** Defines the mesh to use to render this level */
  90413. mesh: Nullable<Mesh>);
  90414. }
  90415. }
  90416. declare module BABYLON {
  90417. /**
  90418. * Mesh representing the gorund
  90419. */
  90420. export class GroundMesh extends Mesh {
  90421. /** If octree should be generated */
  90422. generateOctree: boolean;
  90423. private _heightQuads;
  90424. /** @hidden */
  90425. _subdivisionsX: number;
  90426. /** @hidden */
  90427. _subdivisionsY: number;
  90428. /** @hidden */
  90429. _width: number;
  90430. /** @hidden */
  90431. _height: number;
  90432. /** @hidden */
  90433. _minX: number;
  90434. /** @hidden */
  90435. _maxX: number;
  90436. /** @hidden */
  90437. _minZ: number;
  90438. /** @hidden */
  90439. _maxZ: number;
  90440. constructor(name: string, scene: Scene);
  90441. /**
  90442. * "GroundMesh"
  90443. * @returns "GroundMesh"
  90444. */
  90445. getClassName(): string;
  90446. /**
  90447. * The minimum of x and y subdivisions
  90448. */
  90449. readonly subdivisions: number;
  90450. /**
  90451. * X subdivisions
  90452. */
  90453. readonly subdivisionsX: number;
  90454. /**
  90455. * Y subdivisions
  90456. */
  90457. readonly subdivisionsY: number;
  90458. /**
  90459. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90460. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90461. * @param chunksCount the number of subdivisions for x and y
  90462. * @param octreeBlocksSize (Default: 32)
  90463. */
  90464. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90465. /**
  90466. * Returns a height (y) value in the Worl system :
  90467. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90468. * @param x x coordinate
  90469. * @param z z coordinate
  90470. * @returns the ground y position if (x, z) are outside the ground surface.
  90471. */
  90472. getHeightAtCoordinates(x: number, z: number): number;
  90473. /**
  90474. * Returns a normalized vector (Vector3) orthogonal to the ground
  90475. * at the ground coordinates (x, z) expressed in the World system.
  90476. * @param x x coordinate
  90477. * @param z z coordinate
  90478. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90479. */
  90480. getNormalAtCoordinates(x: number, z: number): Vector3;
  90481. /**
  90482. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90483. * at the ground coordinates (x, z) expressed in the World system.
  90484. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90485. * @param x x coordinate
  90486. * @param z z coordinate
  90487. * @param ref vector to store the result
  90488. * @returns the GroundMesh.
  90489. */
  90490. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90491. /**
  90492. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90493. * if the ground has been updated.
  90494. * This can be used in the render loop.
  90495. * @returns the GroundMesh.
  90496. */
  90497. updateCoordinateHeights(): GroundMesh;
  90498. private _getFacetAt;
  90499. private _initHeightQuads;
  90500. private _computeHeightQuads;
  90501. /**
  90502. * Serializes this ground mesh
  90503. * @param serializationObject object to write serialization to
  90504. */
  90505. serialize(serializationObject: any): void;
  90506. /**
  90507. * Parses a serialized ground mesh
  90508. * @param parsedMesh the serialized mesh
  90509. * @param scene the scene to create the ground mesh in
  90510. * @returns the created ground mesh
  90511. */
  90512. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90513. }
  90514. }
  90515. declare module BABYLON {
  90516. /**
  90517. * Interface for Physics-Joint data
  90518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90519. */
  90520. export interface PhysicsJointData {
  90521. /**
  90522. * The main pivot of the joint
  90523. */
  90524. mainPivot?: Vector3;
  90525. /**
  90526. * The connected pivot of the joint
  90527. */
  90528. connectedPivot?: Vector3;
  90529. /**
  90530. * The main axis of the joint
  90531. */
  90532. mainAxis?: Vector3;
  90533. /**
  90534. * The connected axis of the joint
  90535. */
  90536. connectedAxis?: Vector3;
  90537. /**
  90538. * The collision of the joint
  90539. */
  90540. collision?: boolean;
  90541. /**
  90542. * Native Oimo/Cannon/Energy data
  90543. */
  90544. nativeParams?: any;
  90545. }
  90546. /**
  90547. * This is a holder class for the physics joint created by the physics plugin
  90548. * It holds a set of functions to control the underlying joint
  90549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90550. */
  90551. export class PhysicsJoint {
  90552. /**
  90553. * The type of the physics joint
  90554. */
  90555. type: number;
  90556. /**
  90557. * The data for the physics joint
  90558. */
  90559. jointData: PhysicsJointData;
  90560. private _physicsJoint;
  90561. protected _physicsPlugin: IPhysicsEnginePlugin;
  90562. /**
  90563. * Initializes the physics joint
  90564. * @param type The type of the physics joint
  90565. * @param jointData The data for the physics joint
  90566. */
  90567. constructor(
  90568. /**
  90569. * The type of the physics joint
  90570. */
  90571. type: number,
  90572. /**
  90573. * The data for the physics joint
  90574. */
  90575. jointData: PhysicsJointData);
  90576. /**
  90577. * Gets the physics joint
  90578. */
  90579. /**
  90580. * Sets the physics joint
  90581. */
  90582. physicsJoint: any;
  90583. /**
  90584. * Sets the physics plugin
  90585. */
  90586. physicsPlugin: IPhysicsEnginePlugin;
  90587. /**
  90588. * Execute a function that is physics-plugin specific.
  90589. * @param {Function} func the function that will be executed.
  90590. * It accepts two parameters: the physics world and the physics joint
  90591. */
  90592. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90593. /**
  90594. * Distance-Joint type
  90595. */
  90596. static DistanceJoint: number;
  90597. /**
  90598. * Hinge-Joint type
  90599. */
  90600. static HingeJoint: number;
  90601. /**
  90602. * Ball-and-Socket joint type
  90603. */
  90604. static BallAndSocketJoint: number;
  90605. /**
  90606. * Wheel-Joint type
  90607. */
  90608. static WheelJoint: number;
  90609. /**
  90610. * Slider-Joint type
  90611. */
  90612. static SliderJoint: number;
  90613. /**
  90614. * Prismatic-Joint type
  90615. */
  90616. static PrismaticJoint: number;
  90617. /**
  90618. * Universal-Joint type
  90619. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90620. */
  90621. static UniversalJoint: number;
  90622. /**
  90623. * Hinge-Joint 2 type
  90624. */
  90625. static Hinge2Joint: number;
  90626. /**
  90627. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90628. */
  90629. static PointToPointJoint: number;
  90630. /**
  90631. * Spring-Joint type
  90632. */
  90633. static SpringJoint: number;
  90634. /**
  90635. * Lock-Joint type
  90636. */
  90637. static LockJoint: number;
  90638. }
  90639. /**
  90640. * A class representing a physics distance joint
  90641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90642. */
  90643. export class DistanceJoint extends PhysicsJoint {
  90644. /**
  90645. *
  90646. * @param jointData The data for the Distance-Joint
  90647. */
  90648. constructor(jointData: DistanceJointData);
  90649. /**
  90650. * Update the predefined distance.
  90651. * @param maxDistance The maximum preferred distance
  90652. * @param minDistance The minimum preferred distance
  90653. */
  90654. updateDistance(maxDistance: number, minDistance?: number): void;
  90655. }
  90656. /**
  90657. * Represents a Motor-Enabled Joint
  90658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90659. */
  90660. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90661. /**
  90662. * Initializes the Motor-Enabled Joint
  90663. * @param type The type of the joint
  90664. * @param jointData The physica joint data for the joint
  90665. */
  90666. constructor(type: number, jointData: PhysicsJointData);
  90667. /**
  90668. * Set the motor values.
  90669. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90670. * @param force the force to apply
  90671. * @param maxForce max force for this motor.
  90672. */
  90673. setMotor(force?: number, maxForce?: number): void;
  90674. /**
  90675. * Set the motor's limits.
  90676. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90677. * @param upperLimit The upper limit of the motor
  90678. * @param lowerLimit The lower limit of the motor
  90679. */
  90680. setLimit(upperLimit: number, lowerLimit?: number): void;
  90681. }
  90682. /**
  90683. * This class represents a single physics Hinge-Joint
  90684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90685. */
  90686. export class HingeJoint extends MotorEnabledJoint {
  90687. /**
  90688. * Initializes the Hinge-Joint
  90689. * @param jointData The joint data for the Hinge-Joint
  90690. */
  90691. constructor(jointData: PhysicsJointData);
  90692. /**
  90693. * Set the motor values.
  90694. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90695. * @param {number} force the force to apply
  90696. * @param {number} maxForce max force for this motor.
  90697. */
  90698. setMotor(force?: number, maxForce?: number): void;
  90699. /**
  90700. * Set the motor's limits.
  90701. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90702. * @param upperLimit The upper limit of the motor
  90703. * @param lowerLimit The lower limit of the motor
  90704. */
  90705. setLimit(upperLimit: number, lowerLimit?: number): void;
  90706. }
  90707. /**
  90708. * This class represents a dual hinge physics joint (same as wheel joint)
  90709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90710. */
  90711. export class Hinge2Joint extends MotorEnabledJoint {
  90712. /**
  90713. * Initializes the Hinge2-Joint
  90714. * @param jointData The joint data for the Hinge2-Joint
  90715. */
  90716. constructor(jointData: PhysicsJointData);
  90717. /**
  90718. * Set the motor values.
  90719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90720. * @param {number} targetSpeed the speed the motor is to reach
  90721. * @param {number} maxForce max force for this motor.
  90722. * @param {motorIndex} the motor's index, 0 or 1.
  90723. */
  90724. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90725. /**
  90726. * Set the motor limits.
  90727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90728. * @param {number} upperLimit the upper limit
  90729. * @param {number} lowerLimit lower limit
  90730. * @param {motorIndex} the motor's index, 0 or 1.
  90731. */
  90732. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90733. }
  90734. /**
  90735. * Interface for a motor enabled joint
  90736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90737. */
  90738. export interface IMotorEnabledJoint {
  90739. /**
  90740. * Physics joint
  90741. */
  90742. physicsJoint: any;
  90743. /**
  90744. * Sets the motor of the motor-enabled joint
  90745. * @param force The force of the motor
  90746. * @param maxForce The maximum force of the motor
  90747. * @param motorIndex The index of the motor
  90748. */
  90749. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90750. /**
  90751. * Sets the limit of the motor
  90752. * @param upperLimit The upper limit of the motor
  90753. * @param lowerLimit The lower limit of the motor
  90754. * @param motorIndex The index of the motor
  90755. */
  90756. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90757. }
  90758. /**
  90759. * Joint data for a Distance-Joint
  90760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90761. */
  90762. export interface DistanceJointData extends PhysicsJointData {
  90763. /**
  90764. * Max distance the 2 joint objects can be apart
  90765. */
  90766. maxDistance: number;
  90767. }
  90768. /**
  90769. * Joint data from a spring joint
  90770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90771. */
  90772. export interface SpringJointData extends PhysicsJointData {
  90773. /**
  90774. * Length of the spring
  90775. */
  90776. length: number;
  90777. /**
  90778. * Stiffness of the spring
  90779. */
  90780. stiffness: number;
  90781. /**
  90782. * Damping of the spring
  90783. */
  90784. damping: number;
  90785. /** this callback will be called when applying the force to the impostors. */
  90786. forceApplicationCallback: () => void;
  90787. }
  90788. }
  90789. declare module BABYLON {
  90790. /**
  90791. * Holds the data for the raycast result
  90792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90793. */
  90794. export class PhysicsRaycastResult {
  90795. private _hasHit;
  90796. private _hitDistance;
  90797. private _hitNormalWorld;
  90798. private _hitPointWorld;
  90799. private _rayFromWorld;
  90800. private _rayToWorld;
  90801. /**
  90802. * Gets if there was a hit
  90803. */
  90804. readonly hasHit: boolean;
  90805. /**
  90806. * Gets the distance from the hit
  90807. */
  90808. readonly hitDistance: number;
  90809. /**
  90810. * Gets the hit normal/direction in the world
  90811. */
  90812. readonly hitNormalWorld: Vector3;
  90813. /**
  90814. * Gets the hit point in the world
  90815. */
  90816. readonly hitPointWorld: Vector3;
  90817. /**
  90818. * Gets the ray "start point" of the ray in the world
  90819. */
  90820. readonly rayFromWorld: Vector3;
  90821. /**
  90822. * Gets the ray "end point" of the ray in the world
  90823. */
  90824. readonly rayToWorld: Vector3;
  90825. /**
  90826. * Sets the hit data (normal & point in world space)
  90827. * @param hitNormalWorld defines the normal in world space
  90828. * @param hitPointWorld defines the point in world space
  90829. */
  90830. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90831. /**
  90832. * Sets the distance from the start point to the hit point
  90833. * @param distance
  90834. */
  90835. setHitDistance(distance: number): void;
  90836. /**
  90837. * Calculates the distance manually
  90838. */
  90839. calculateHitDistance(): void;
  90840. /**
  90841. * Resets all the values to default
  90842. * @param from The from point on world space
  90843. * @param to The to point on world space
  90844. */
  90845. reset(from?: Vector3, to?: Vector3): void;
  90846. }
  90847. /**
  90848. * Interface for the size containing width and height
  90849. */
  90850. interface IXYZ {
  90851. /**
  90852. * X
  90853. */
  90854. x: number;
  90855. /**
  90856. * Y
  90857. */
  90858. y: number;
  90859. /**
  90860. * Z
  90861. */
  90862. z: number;
  90863. }
  90864. }
  90865. declare module BABYLON {
  90866. /**
  90867. * Interface used to describe a physics joint
  90868. */
  90869. export interface PhysicsImpostorJoint {
  90870. /** Defines the main impostor to which the joint is linked */
  90871. mainImpostor: PhysicsImpostor;
  90872. /** Defines the impostor that is connected to the main impostor using this joint */
  90873. connectedImpostor: PhysicsImpostor;
  90874. /** Defines the joint itself */
  90875. joint: PhysicsJoint;
  90876. }
  90877. /** @hidden */
  90878. export interface IPhysicsEnginePlugin {
  90879. world: any;
  90880. name: string;
  90881. setGravity(gravity: Vector3): void;
  90882. setTimeStep(timeStep: number): void;
  90883. getTimeStep(): number;
  90884. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90885. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90888. removePhysicsBody(impostor: PhysicsImpostor): void;
  90889. generateJoint(joint: PhysicsImpostorJoint): void;
  90890. removeJoint(joint: PhysicsImpostorJoint): void;
  90891. isSupported(): boolean;
  90892. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90893. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90895. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90896. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90898. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90899. getBodyMass(impostor: PhysicsImpostor): number;
  90900. getBodyFriction(impostor: PhysicsImpostor): number;
  90901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90902. getBodyRestitution(impostor: PhysicsImpostor): number;
  90903. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90904. getBodyPressure?(impostor: PhysicsImpostor): number;
  90905. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90906. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90907. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90908. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90909. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90910. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90911. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90912. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90913. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90914. sleepBody(impostor: PhysicsImpostor): void;
  90915. wakeUpBody(impostor: PhysicsImpostor): void;
  90916. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90917. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90918. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90919. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90920. getRadius(impostor: PhysicsImpostor): number;
  90921. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90922. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90923. dispose(): void;
  90924. }
  90925. /**
  90926. * Interface used to define a physics engine
  90927. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90928. */
  90929. export interface IPhysicsEngine {
  90930. /**
  90931. * Gets the gravity vector used by the simulation
  90932. */
  90933. gravity: Vector3;
  90934. /**
  90935. * Sets the gravity vector used by the simulation
  90936. * @param gravity defines the gravity vector to use
  90937. */
  90938. setGravity(gravity: Vector3): void;
  90939. /**
  90940. * Set the time step of the physics engine.
  90941. * Default is 1/60.
  90942. * To slow it down, enter 1/600 for example.
  90943. * To speed it up, 1/30
  90944. * @param newTimeStep the new timestep to apply to this world.
  90945. */
  90946. setTimeStep(newTimeStep: number): void;
  90947. /**
  90948. * Get the time step of the physics engine.
  90949. * @returns the current time step
  90950. */
  90951. getTimeStep(): number;
  90952. /**
  90953. * Release all resources
  90954. */
  90955. dispose(): void;
  90956. /**
  90957. * Gets the name of the current physics plugin
  90958. * @returns the name of the plugin
  90959. */
  90960. getPhysicsPluginName(): string;
  90961. /**
  90962. * Adding a new impostor for the impostor tracking.
  90963. * This will be done by the impostor itself.
  90964. * @param impostor the impostor to add
  90965. */
  90966. addImpostor(impostor: PhysicsImpostor): void;
  90967. /**
  90968. * Remove an impostor from the engine.
  90969. * This impostor and its mesh will not longer be updated by the physics engine.
  90970. * @param impostor the impostor to remove
  90971. */
  90972. removeImpostor(impostor: PhysicsImpostor): void;
  90973. /**
  90974. * Add a joint to the physics engine
  90975. * @param mainImpostor defines the main impostor to which the joint is added.
  90976. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90977. * @param joint defines the joint that will connect both impostors.
  90978. */
  90979. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90980. /**
  90981. * Removes a joint from the simulation
  90982. * @param mainImpostor defines the impostor used with the joint
  90983. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90984. * @param joint defines the joint to remove
  90985. */
  90986. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90987. /**
  90988. * Gets the current plugin used to run the simulation
  90989. * @returns current plugin
  90990. */
  90991. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90992. /**
  90993. * Gets the list of physic impostors
  90994. * @returns an array of PhysicsImpostor
  90995. */
  90996. getImpostors(): Array<PhysicsImpostor>;
  90997. /**
  90998. * Gets the impostor for a physics enabled object
  90999. * @param object defines the object impersonated by the impostor
  91000. * @returns the PhysicsImpostor or null if not found
  91001. */
  91002. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91003. /**
  91004. * Gets the impostor for a physics body object
  91005. * @param body defines physics body used by the impostor
  91006. * @returns the PhysicsImpostor or null if not found
  91007. */
  91008. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91009. /**
  91010. * Does a raycast in the physics world
  91011. * @param from when should the ray start?
  91012. * @param to when should the ray end?
  91013. * @returns PhysicsRaycastResult
  91014. */
  91015. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91016. /**
  91017. * Called by the scene. No need to call it.
  91018. * @param delta defines the timespam between frames
  91019. */
  91020. _step(delta: number): void;
  91021. }
  91022. }
  91023. declare module BABYLON {
  91024. /**
  91025. * The interface for the physics imposter parameters
  91026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91027. */
  91028. export interface PhysicsImpostorParameters {
  91029. /**
  91030. * The mass of the physics imposter
  91031. */
  91032. mass: number;
  91033. /**
  91034. * The friction of the physics imposter
  91035. */
  91036. friction?: number;
  91037. /**
  91038. * The coefficient of restitution of the physics imposter
  91039. */
  91040. restitution?: number;
  91041. /**
  91042. * The native options of the physics imposter
  91043. */
  91044. nativeOptions?: any;
  91045. /**
  91046. * Specifies if the parent should be ignored
  91047. */
  91048. ignoreParent?: boolean;
  91049. /**
  91050. * Specifies if bi-directional transformations should be disabled
  91051. */
  91052. disableBidirectionalTransformation?: boolean;
  91053. /**
  91054. * The pressure inside the physics imposter, soft object only
  91055. */
  91056. pressure?: number;
  91057. /**
  91058. * The stiffness the physics imposter, soft object only
  91059. */
  91060. stiffness?: number;
  91061. /**
  91062. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91063. */
  91064. velocityIterations?: number;
  91065. /**
  91066. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91067. */
  91068. positionIterations?: number;
  91069. /**
  91070. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91071. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91072. * Add to fix multiple points
  91073. */
  91074. fixedPoints?: number;
  91075. /**
  91076. * The collision margin around a soft object
  91077. */
  91078. margin?: number;
  91079. /**
  91080. * The collision margin around a soft object
  91081. */
  91082. damping?: number;
  91083. /**
  91084. * The path for a rope based on an extrusion
  91085. */
  91086. path?: any;
  91087. /**
  91088. * The shape of an extrusion used for a rope based on an extrusion
  91089. */
  91090. shape?: any;
  91091. }
  91092. /**
  91093. * Interface for a physics-enabled object
  91094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91095. */
  91096. export interface IPhysicsEnabledObject {
  91097. /**
  91098. * The position of the physics-enabled object
  91099. */
  91100. position: Vector3;
  91101. /**
  91102. * The rotation of the physics-enabled object
  91103. */
  91104. rotationQuaternion: Nullable<Quaternion>;
  91105. /**
  91106. * The scale of the physics-enabled object
  91107. */
  91108. scaling: Vector3;
  91109. /**
  91110. * The rotation of the physics-enabled object
  91111. */
  91112. rotation?: Vector3;
  91113. /**
  91114. * The parent of the physics-enabled object
  91115. */
  91116. parent?: any;
  91117. /**
  91118. * The bounding info of the physics-enabled object
  91119. * @returns The bounding info of the physics-enabled object
  91120. */
  91121. getBoundingInfo(): BoundingInfo;
  91122. /**
  91123. * Computes the world matrix
  91124. * @param force Specifies if the world matrix should be computed by force
  91125. * @returns A world matrix
  91126. */
  91127. computeWorldMatrix(force: boolean): Matrix;
  91128. /**
  91129. * Gets the world matrix
  91130. * @returns A world matrix
  91131. */
  91132. getWorldMatrix?(): Matrix;
  91133. /**
  91134. * Gets the child meshes
  91135. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91136. * @returns An array of abstract meshes
  91137. */
  91138. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91139. /**
  91140. * Gets the vertex data
  91141. * @param kind The type of vertex data
  91142. * @returns A nullable array of numbers, or a float32 array
  91143. */
  91144. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91145. /**
  91146. * Gets the indices from the mesh
  91147. * @returns A nullable array of index arrays
  91148. */
  91149. getIndices?(): Nullable<IndicesArray>;
  91150. /**
  91151. * Gets the scene from the mesh
  91152. * @returns the indices array or null
  91153. */
  91154. getScene?(): Scene;
  91155. /**
  91156. * Gets the absolute position from the mesh
  91157. * @returns the absolute position
  91158. */
  91159. getAbsolutePosition(): Vector3;
  91160. /**
  91161. * Gets the absolute pivot point from the mesh
  91162. * @returns the absolute pivot point
  91163. */
  91164. getAbsolutePivotPoint(): Vector3;
  91165. /**
  91166. * Rotates the mesh
  91167. * @param axis The axis of rotation
  91168. * @param amount The amount of rotation
  91169. * @param space The space of the rotation
  91170. * @returns The rotation transform node
  91171. */
  91172. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91173. /**
  91174. * Translates the mesh
  91175. * @param axis The axis of translation
  91176. * @param distance The distance of translation
  91177. * @param space The space of the translation
  91178. * @returns The transform node
  91179. */
  91180. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91181. /**
  91182. * Sets the absolute position of the mesh
  91183. * @param absolutePosition The absolute position of the mesh
  91184. * @returns The transform node
  91185. */
  91186. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91187. /**
  91188. * Gets the class name of the mesh
  91189. * @returns The class name
  91190. */
  91191. getClassName(): string;
  91192. }
  91193. /**
  91194. * Represents a physics imposter
  91195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91196. */
  91197. export class PhysicsImpostor {
  91198. /**
  91199. * The physics-enabled object used as the physics imposter
  91200. */
  91201. object: IPhysicsEnabledObject;
  91202. /**
  91203. * The type of the physics imposter
  91204. */
  91205. type: number;
  91206. private _options;
  91207. private _scene?;
  91208. /**
  91209. * The default object size of the imposter
  91210. */
  91211. static DEFAULT_OBJECT_SIZE: Vector3;
  91212. /**
  91213. * The identity quaternion of the imposter
  91214. */
  91215. static IDENTITY_QUATERNION: Quaternion;
  91216. /** @hidden */
  91217. _pluginData: any;
  91218. private _physicsEngine;
  91219. private _physicsBody;
  91220. private _bodyUpdateRequired;
  91221. private _onBeforePhysicsStepCallbacks;
  91222. private _onAfterPhysicsStepCallbacks;
  91223. /** @hidden */
  91224. _onPhysicsCollideCallbacks: Array<{
  91225. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91226. otherImpostors: Array<PhysicsImpostor>;
  91227. }>;
  91228. private _deltaPosition;
  91229. private _deltaRotation;
  91230. private _deltaRotationConjugated;
  91231. /** @hidden */
  91232. _isFromLine: boolean;
  91233. private _parent;
  91234. private _isDisposed;
  91235. private static _tmpVecs;
  91236. private static _tmpQuat;
  91237. /**
  91238. * Specifies if the physics imposter is disposed
  91239. */
  91240. readonly isDisposed: boolean;
  91241. /**
  91242. * Gets the mass of the physics imposter
  91243. */
  91244. mass: number;
  91245. /**
  91246. * Gets the coefficient of friction
  91247. */
  91248. /**
  91249. * Sets the coefficient of friction
  91250. */
  91251. friction: number;
  91252. /**
  91253. * Gets the coefficient of restitution
  91254. */
  91255. /**
  91256. * Sets the coefficient of restitution
  91257. */
  91258. restitution: number;
  91259. /**
  91260. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91261. */
  91262. /**
  91263. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91264. */
  91265. pressure: number;
  91266. /**
  91267. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91268. */
  91269. /**
  91270. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91271. */
  91272. stiffness: number;
  91273. /**
  91274. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91275. */
  91276. /**
  91277. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91278. */
  91279. velocityIterations: number;
  91280. /**
  91281. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91282. */
  91283. /**
  91284. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91285. */
  91286. positionIterations: number;
  91287. /**
  91288. * The unique id of the physics imposter
  91289. * set by the physics engine when adding this impostor to the array
  91290. */
  91291. uniqueId: number;
  91292. /**
  91293. * @hidden
  91294. */
  91295. soft: boolean;
  91296. /**
  91297. * @hidden
  91298. */
  91299. segments: number;
  91300. private _joints;
  91301. /**
  91302. * Initializes the physics imposter
  91303. * @param object The physics-enabled object used as the physics imposter
  91304. * @param type The type of the physics imposter
  91305. * @param _options The options for the physics imposter
  91306. * @param _scene The Babylon scene
  91307. */
  91308. constructor(
  91309. /**
  91310. * The physics-enabled object used as the physics imposter
  91311. */
  91312. object: IPhysicsEnabledObject,
  91313. /**
  91314. * The type of the physics imposter
  91315. */
  91316. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91317. /**
  91318. * This function will completly initialize this impostor.
  91319. * It will create a new body - but only if this mesh has no parent.
  91320. * If it has, this impostor will not be used other than to define the impostor
  91321. * of the child mesh.
  91322. * @hidden
  91323. */
  91324. _init(): void;
  91325. private _getPhysicsParent;
  91326. /**
  91327. * Should a new body be generated.
  91328. * @returns boolean specifying if body initialization is required
  91329. */
  91330. isBodyInitRequired(): boolean;
  91331. /**
  91332. * Sets the updated scaling
  91333. * @param updated Specifies if the scaling is updated
  91334. */
  91335. setScalingUpdated(): void;
  91336. /**
  91337. * Force a regeneration of this or the parent's impostor's body.
  91338. * Use under cautious - This will remove all joints already implemented.
  91339. */
  91340. forceUpdate(): void;
  91341. /**
  91342. * Gets the body that holds this impostor. Either its own, or its parent.
  91343. */
  91344. /**
  91345. * Set the physics body. Used mainly by the physics engine/plugin
  91346. */
  91347. physicsBody: any;
  91348. /**
  91349. * Get the parent of the physics imposter
  91350. * @returns Physics imposter or null
  91351. */
  91352. /**
  91353. * Sets the parent of the physics imposter
  91354. */
  91355. parent: Nullable<PhysicsImpostor>;
  91356. /**
  91357. * Resets the update flags
  91358. */
  91359. resetUpdateFlags(): void;
  91360. /**
  91361. * Gets the object extend size
  91362. * @returns the object extend size
  91363. */
  91364. getObjectExtendSize(): Vector3;
  91365. /**
  91366. * Gets the object center
  91367. * @returns The object center
  91368. */
  91369. getObjectCenter(): Vector3;
  91370. /**
  91371. * Get a specific parametes from the options parameter
  91372. * @param paramName The object parameter name
  91373. * @returns The object parameter
  91374. */
  91375. getParam(paramName: string): any;
  91376. /**
  91377. * Sets a specific parameter in the options given to the physics plugin
  91378. * @param paramName The parameter name
  91379. * @param value The value of the parameter
  91380. */
  91381. setParam(paramName: string, value: number): void;
  91382. /**
  91383. * Specifically change the body's mass option. Won't recreate the physics body object
  91384. * @param mass The mass of the physics imposter
  91385. */
  91386. setMass(mass: number): void;
  91387. /**
  91388. * Gets the linear velocity
  91389. * @returns linear velocity or null
  91390. */
  91391. getLinearVelocity(): Nullable<Vector3>;
  91392. /**
  91393. * Sets the linear velocity
  91394. * @param velocity linear velocity or null
  91395. */
  91396. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91397. /**
  91398. * Gets the angular velocity
  91399. * @returns angular velocity or null
  91400. */
  91401. getAngularVelocity(): Nullable<Vector3>;
  91402. /**
  91403. * Sets the angular velocity
  91404. * @param velocity The velocity or null
  91405. */
  91406. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91407. /**
  91408. * Execute a function with the physics plugin native code
  91409. * Provide a function the will have two variables - the world object and the physics body object
  91410. * @param func The function to execute with the physics plugin native code
  91411. */
  91412. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91413. /**
  91414. * Register a function that will be executed before the physics world is stepping forward
  91415. * @param func The function to execute before the physics world is stepped forward
  91416. */
  91417. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91418. /**
  91419. * Unregister a function that will be executed before the physics world is stepping forward
  91420. * @param func The function to execute before the physics world is stepped forward
  91421. */
  91422. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91423. /**
  91424. * Register a function that will be executed after the physics step
  91425. * @param func The function to execute after physics step
  91426. */
  91427. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91428. /**
  91429. * Unregisters a function that will be executed after the physics step
  91430. * @param func The function to execute after physics step
  91431. */
  91432. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91433. /**
  91434. * register a function that will be executed when this impostor collides against a different body
  91435. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91436. * @param func Callback that is executed on collision
  91437. */
  91438. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91439. /**
  91440. * Unregisters the physics imposter on contact
  91441. * @param collideAgainst The physics object to collide against
  91442. * @param func Callback to execute on collision
  91443. */
  91444. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91445. private _tmpQuat;
  91446. private _tmpQuat2;
  91447. /**
  91448. * Get the parent rotation
  91449. * @returns The parent rotation
  91450. */
  91451. getParentsRotation(): Quaternion;
  91452. /**
  91453. * this function is executed by the physics engine.
  91454. */
  91455. beforeStep: () => void;
  91456. /**
  91457. * this function is executed by the physics engine
  91458. */
  91459. afterStep: () => void;
  91460. /**
  91461. * Legacy collision detection event support
  91462. */
  91463. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91464. /**
  91465. * event and body object due to cannon's event-based architecture.
  91466. */
  91467. onCollide: (e: {
  91468. body: any;
  91469. }) => void;
  91470. /**
  91471. * Apply a force
  91472. * @param force The force to apply
  91473. * @param contactPoint The contact point for the force
  91474. * @returns The physics imposter
  91475. */
  91476. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91477. /**
  91478. * Apply an impulse
  91479. * @param force The impulse force
  91480. * @param contactPoint The contact point for the impulse force
  91481. * @returns The physics imposter
  91482. */
  91483. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91484. /**
  91485. * A help function to create a joint
  91486. * @param otherImpostor A physics imposter used to create a joint
  91487. * @param jointType The type of joint
  91488. * @param jointData The data for the joint
  91489. * @returns The physics imposter
  91490. */
  91491. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91492. /**
  91493. * Add a joint to this impostor with a different impostor
  91494. * @param otherImpostor A physics imposter used to add a joint
  91495. * @param joint The joint to add
  91496. * @returns The physics imposter
  91497. */
  91498. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91499. /**
  91500. * Add an anchor to a cloth impostor
  91501. * @param otherImpostor rigid impostor to anchor to
  91502. * @param width ratio across width from 0 to 1
  91503. * @param height ratio up height from 0 to 1
  91504. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91505. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91506. * @returns impostor the soft imposter
  91507. */
  91508. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91509. /**
  91510. * Add a hook to a rope impostor
  91511. * @param otherImpostor rigid impostor to anchor to
  91512. * @param length ratio across rope from 0 to 1
  91513. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91514. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91515. * @returns impostor the rope imposter
  91516. */
  91517. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91518. /**
  91519. * Will keep this body still, in a sleep mode.
  91520. * @returns the physics imposter
  91521. */
  91522. sleep(): PhysicsImpostor;
  91523. /**
  91524. * Wake the body up.
  91525. * @returns The physics imposter
  91526. */
  91527. wakeUp(): PhysicsImpostor;
  91528. /**
  91529. * Clones the physics imposter
  91530. * @param newObject The physics imposter clones to this physics-enabled object
  91531. * @returns A nullable physics imposter
  91532. */
  91533. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91534. /**
  91535. * Disposes the physics imposter
  91536. */
  91537. dispose(): void;
  91538. /**
  91539. * Sets the delta position
  91540. * @param position The delta position amount
  91541. */
  91542. setDeltaPosition(position: Vector3): void;
  91543. /**
  91544. * Sets the delta rotation
  91545. * @param rotation The delta rotation amount
  91546. */
  91547. setDeltaRotation(rotation: Quaternion): void;
  91548. /**
  91549. * Gets the box size of the physics imposter and stores the result in the input parameter
  91550. * @param result Stores the box size
  91551. * @returns The physics imposter
  91552. */
  91553. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91554. /**
  91555. * Gets the radius of the physics imposter
  91556. * @returns Radius of the physics imposter
  91557. */
  91558. getRadius(): number;
  91559. /**
  91560. * Sync a bone with this impostor
  91561. * @param bone The bone to sync to the impostor.
  91562. * @param boneMesh The mesh that the bone is influencing.
  91563. * @param jointPivot The pivot of the joint / bone in local space.
  91564. * @param distToJoint Optional distance from the impostor to the joint.
  91565. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91566. */
  91567. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91568. /**
  91569. * Sync impostor to a bone
  91570. * @param bone The bone that the impostor will be synced to.
  91571. * @param boneMesh The mesh that the bone is influencing.
  91572. * @param jointPivot The pivot of the joint / bone in local space.
  91573. * @param distToJoint Optional distance from the impostor to the joint.
  91574. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91575. * @param boneAxis Optional vector3 axis the bone is aligned with
  91576. */
  91577. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91578. /**
  91579. * No-Imposter type
  91580. */
  91581. static NoImpostor: number;
  91582. /**
  91583. * Sphere-Imposter type
  91584. */
  91585. static SphereImpostor: number;
  91586. /**
  91587. * Box-Imposter type
  91588. */
  91589. static BoxImpostor: number;
  91590. /**
  91591. * Plane-Imposter type
  91592. */
  91593. static PlaneImpostor: number;
  91594. /**
  91595. * Mesh-imposter type
  91596. */
  91597. static MeshImpostor: number;
  91598. /**
  91599. * Capsule-Impostor type (Ammo.js plugin only)
  91600. */
  91601. static CapsuleImpostor: number;
  91602. /**
  91603. * Cylinder-Imposter type
  91604. */
  91605. static CylinderImpostor: number;
  91606. /**
  91607. * Particle-Imposter type
  91608. */
  91609. static ParticleImpostor: number;
  91610. /**
  91611. * Heightmap-Imposter type
  91612. */
  91613. static HeightmapImpostor: number;
  91614. /**
  91615. * ConvexHull-Impostor type (Ammo.js plugin only)
  91616. */
  91617. static ConvexHullImpostor: number;
  91618. /**
  91619. * Rope-Imposter type
  91620. */
  91621. static RopeImpostor: number;
  91622. /**
  91623. * Cloth-Imposter type
  91624. */
  91625. static ClothImpostor: number;
  91626. /**
  91627. * Softbody-Imposter type
  91628. */
  91629. static SoftbodyImpostor: number;
  91630. }
  91631. }
  91632. declare module BABYLON {
  91633. /**
  91634. * @hidden
  91635. **/
  91636. export class _CreationDataStorage {
  91637. closePath?: boolean;
  91638. closeArray?: boolean;
  91639. idx: number[];
  91640. dashSize: number;
  91641. gapSize: number;
  91642. path3D: Path3D;
  91643. pathArray: Vector3[][];
  91644. arc: number;
  91645. radius: number;
  91646. cap: number;
  91647. tessellation: number;
  91648. }
  91649. /**
  91650. * @hidden
  91651. **/
  91652. class _InstanceDataStorage {
  91653. visibleInstances: any;
  91654. batchCache: _InstancesBatch;
  91655. instancesBufferSize: number;
  91656. instancesBuffer: Nullable<Buffer>;
  91657. instancesData: Float32Array;
  91658. overridenInstanceCount: number;
  91659. isFrozen: boolean;
  91660. previousBatch: Nullable<_InstancesBatch>;
  91661. hardwareInstancedRendering: boolean;
  91662. sideOrientation: number;
  91663. }
  91664. /**
  91665. * @hidden
  91666. **/
  91667. export class _InstancesBatch {
  91668. mustReturn: boolean;
  91669. visibleInstances: Nullable<InstancedMesh[]>[];
  91670. renderSelf: boolean[];
  91671. hardwareInstancedRendering: boolean[];
  91672. }
  91673. /**
  91674. * Class used to represent renderable models
  91675. */
  91676. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91677. /**
  91678. * Mesh side orientation : usually the external or front surface
  91679. */
  91680. static readonly FRONTSIDE: number;
  91681. /**
  91682. * Mesh side orientation : usually the internal or back surface
  91683. */
  91684. static readonly BACKSIDE: number;
  91685. /**
  91686. * Mesh side orientation : both internal and external or front and back surfaces
  91687. */
  91688. static readonly DOUBLESIDE: number;
  91689. /**
  91690. * Mesh side orientation : by default, `FRONTSIDE`
  91691. */
  91692. static readonly DEFAULTSIDE: number;
  91693. /**
  91694. * Mesh cap setting : no cap
  91695. */
  91696. static readonly NO_CAP: number;
  91697. /**
  91698. * Mesh cap setting : one cap at the beginning of the mesh
  91699. */
  91700. static readonly CAP_START: number;
  91701. /**
  91702. * Mesh cap setting : one cap at the end of the mesh
  91703. */
  91704. static readonly CAP_END: number;
  91705. /**
  91706. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91707. */
  91708. static readonly CAP_ALL: number;
  91709. /**
  91710. * Mesh pattern setting : no flip or rotate
  91711. */
  91712. static readonly NO_FLIP: number;
  91713. /**
  91714. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91715. */
  91716. static readonly FLIP_TILE: number;
  91717. /**
  91718. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91719. */
  91720. static readonly ROTATE_TILE: number;
  91721. /**
  91722. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91723. */
  91724. static readonly FLIP_ROW: number;
  91725. /**
  91726. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91727. */
  91728. static readonly ROTATE_ROW: number;
  91729. /**
  91730. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91731. */
  91732. static readonly FLIP_N_ROTATE_TILE: number;
  91733. /**
  91734. * Mesh pattern setting : rotate pattern and rotate
  91735. */
  91736. static readonly FLIP_N_ROTATE_ROW: number;
  91737. /**
  91738. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91739. */
  91740. static readonly CENTER: number;
  91741. /**
  91742. * Mesh tile positioning : part tiles on left
  91743. */
  91744. static readonly LEFT: number;
  91745. /**
  91746. * Mesh tile positioning : part tiles on right
  91747. */
  91748. static readonly RIGHT: number;
  91749. /**
  91750. * Mesh tile positioning : part tiles on top
  91751. */
  91752. static readonly TOP: number;
  91753. /**
  91754. * Mesh tile positioning : part tiles on bottom
  91755. */
  91756. static readonly BOTTOM: number;
  91757. /**
  91758. * Gets the default side orientation.
  91759. * @param orientation the orientation to value to attempt to get
  91760. * @returns the default orientation
  91761. * @hidden
  91762. */
  91763. static _GetDefaultSideOrientation(orientation?: number): number;
  91764. private _internalMeshDataInfo;
  91765. /**
  91766. * An event triggered before rendering the mesh
  91767. */
  91768. readonly onBeforeRenderObservable: Observable<Mesh>;
  91769. /**
  91770. * An event triggered before binding the mesh
  91771. */
  91772. readonly onBeforeBindObservable: Observable<Mesh>;
  91773. /**
  91774. * An event triggered after rendering the mesh
  91775. */
  91776. readonly onAfterRenderObservable: Observable<Mesh>;
  91777. /**
  91778. * An event triggered before drawing the mesh
  91779. */
  91780. readonly onBeforeDrawObservable: Observable<Mesh>;
  91781. private _onBeforeDrawObserver;
  91782. /**
  91783. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91784. */
  91785. onBeforeDraw: () => void;
  91786. readonly hasInstances: boolean;
  91787. /**
  91788. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91789. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91790. */
  91791. delayLoadState: number;
  91792. /**
  91793. * Gets the list of instances created from this mesh
  91794. * it is not supposed to be modified manually.
  91795. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91796. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91797. */
  91798. instances: InstancedMesh[];
  91799. /**
  91800. * Gets the file containing delay loading data for this mesh
  91801. */
  91802. delayLoadingFile: string;
  91803. /** @hidden */
  91804. _binaryInfo: any;
  91805. /**
  91806. * User defined function used to change how LOD level selection is done
  91807. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91808. */
  91809. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91810. /**
  91811. * Gets or sets the morph target manager
  91812. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91813. */
  91814. morphTargetManager: Nullable<MorphTargetManager>;
  91815. /** @hidden */
  91816. _creationDataStorage: Nullable<_CreationDataStorage>;
  91817. /** @hidden */
  91818. _geometry: Nullable<Geometry>;
  91819. /** @hidden */
  91820. _delayInfo: Array<string>;
  91821. /** @hidden */
  91822. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91823. /** @hidden */
  91824. _instanceDataStorage: _InstanceDataStorage;
  91825. private _effectiveMaterial;
  91826. /** @hidden */
  91827. _shouldGenerateFlatShading: boolean;
  91828. /** @hidden */
  91829. _originalBuilderSideOrientation: number;
  91830. /**
  91831. * Use this property to change the original side orientation defined at construction time
  91832. */
  91833. overrideMaterialSideOrientation: Nullable<number>;
  91834. /**
  91835. * Gets the source mesh (the one used to clone this one from)
  91836. */
  91837. readonly source: Nullable<Mesh>;
  91838. /**
  91839. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91840. */
  91841. isUnIndexed: boolean;
  91842. /**
  91843. * @constructor
  91844. * @param name The value used by scene.getMeshByName() to do a lookup.
  91845. * @param scene The scene to add this mesh to.
  91846. * @param parent The parent of this mesh, if it has one
  91847. * @param source An optional Mesh from which geometry is shared, cloned.
  91848. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91849. * When false, achieved by calling a clone(), also passing False.
  91850. * This will make creation of children, recursive.
  91851. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91852. */
  91853. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91854. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91855. doNotInstantiate: boolean;
  91856. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91857. /**
  91858. * Gets the class name
  91859. * @returns the string "Mesh".
  91860. */
  91861. getClassName(): string;
  91862. /** @hidden */
  91863. readonly _isMesh: boolean;
  91864. /**
  91865. * Returns a description of this mesh
  91866. * @param fullDetails define if full details about this mesh must be used
  91867. * @returns a descriptive string representing this mesh
  91868. */
  91869. toString(fullDetails?: boolean): string;
  91870. /** @hidden */
  91871. _unBindEffect(): void;
  91872. /**
  91873. * Gets a boolean indicating if this mesh has LOD
  91874. */
  91875. readonly hasLODLevels: boolean;
  91876. /**
  91877. * Gets the list of MeshLODLevel associated with the current mesh
  91878. * @returns an array of MeshLODLevel
  91879. */
  91880. getLODLevels(): MeshLODLevel[];
  91881. private _sortLODLevels;
  91882. /**
  91883. * Add a mesh as LOD level triggered at the given distance.
  91884. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91885. * @param distance The distance from the center of the object to show this level
  91886. * @param mesh The mesh to be added as LOD level (can be null)
  91887. * @return This mesh (for chaining)
  91888. */
  91889. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91890. /**
  91891. * Returns the LOD level mesh at the passed distance or null if not found.
  91892. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91893. * @param distance The distance from the center of the object to show this level
  91894. * @returns a Mesh or `null`
  91895. */
  91896. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91897. /**
  91898. * Remove a mesh from the LOD array
  91899. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91900. * @param mesh defines the mesh to be removed
  91901. * @return This mesh (for chaining)
  91902. */
  91903. removeLODLevel(mesh: Mesh): Mesh;
  91904. /**
  91905. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91906. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91907. * @param camera defines the camera to use to compute distance
  91908. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91909. * @return This mesh (for chaining)
  91910. */
  91911. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91912. /**
  91913. * Gets the mesh internal Geometry object
  91914. */
  91915. readonly geometry: Nullable<Geometry>;
  91916. /**
  91917. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91918. * @returns the total number of vertices
  91919. */
  91920. getTotalVertices(): number;
  91921. /**
  91922. * Returns the content of an associated vertex buffer
  91923. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91924. * - VertexBuffer.PositionKind
  91925. * - VertexBuffer.UVKind
  91926. * - VertexBuffer.UV2Kind
  91927. * - VertexBuffer.UV3Kind
  91928. * - VertexBuffer.UV4Kind
  91929. * - VertexBuffer.UV5Kind
  91930. * - VertexBuffer.UV6Kind
  91931. * - VertexBuffer.ColorKind
  91932. * - VertexBuffer.MatricesIndicesKind
  91933. * - VertexBuffer.MatricesIndicesExtraKind
  91934. * - VertexBuffer.MatricesWeightsKind
  91935. * - VertexBuffer.MatricesWeightsExtraKind
  91936. * @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
  91937. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91938. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91939. */
  91940. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91941. /**
  91942. * Returns the mesh VertexBuffer object from the requested `kind`
  91943. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91944. * - VertexBuffer.PositionKind
  91945. * - VertexBuffer.NormalKind
  91946. * - VertexBuffer.UVKind
  91947. * - VertexBuffer.UV2Kind
  91948. * - VertexBuffer.UV3Kind
  91949. * - VertexBuffer.UV4Kind
  91950. * - VertexBuffer.UV5Kind
  91951. * - VertexBuffer.UV6Kind
  91952. * - VertexBuffer.ColorKind
  91953. * - VertexBuffer.MatricesIndicesKind
  91954. * - VertexBuffer.MatricesIndicesExtraKind
  91955. * - VertexBuffer.MatricesWeightsKind
  91956. * - VertexBuffer.MatricesWeightsExtraKind
  91957. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91958. */
  91959. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91960. /**
  91961. * Tests if a specific vertex buffer is associated with this mesh
  91962. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91963. * - VertexBuffer.PositionKind
  91964. * - VertexBuffer.NormalKind
  91965. * - VertexBuffer.UVKind
  91966. * - VertexBuffer.UV2Kind
  91967. * - VertexBuffer.UV3Kind
  91968. * - VertexBuffer.UV4Kind
  91969. * - VertexBuffer.UV5Kind
  91970. * - VertexBuffer.UV6Kind
  91971. * - VertexBuffer.ColorKind
  91972. * - VertexBuffer.MatricesIndicesKind
  91973. * - VertexBuffer.MatricesIndicesExtraKind
  91974. * - VertexBuffer.MatricesWeightsKind
  91975. * - VertexBuffer.MatricesWeightsExtraKind
  91976. * @returns a boolean
  91977. */
  91978. isVerticesDataPresent(kind: string): boolean;
  91979. /**
  91980. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91981. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91982. * - VertexBuffer.PositionKind
  91983. * - VertexBuffer.UVKind
  91984. * - VertexBuffer.UV2Kind
  91985. * - VertexBuffer.UV3Kind
  91986. * - VertexBuffer.UV4Kind
  91987. * - VertexBuffer.UV5Kind
  91988. * - VertexBuffer.UV6Kind
  91989. * - VertexBuffer.ColorKind
  91990. * - VertexBuffer.MatricesIndicesKind
  91991. * - VertexBuffer.MatricesIndicesExtraKind
  91992. * - VertexBuffer.MatricesWeightsKind
  91993. * - VertexBuffer.MatricesWeightsExtraKind
  91994. * @returns a boolean
  91995. */
  91996. isVertexBufferUpdatable(kind: string): boolean;
  91997. /**
  91998. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91999. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92000. * - VertexBuffer.PositionKind
  92001. * - VertexBuffer.NormalKind
  92002. * - VertexBuffer.UVKind
  92003. * - VertexBuffer.UV2Kind
  92004. * - VertexBuffer.UV3Kind
  92005. * - VertexBuffer.UV4Kind
  92006. * - VertexBuffer.UV5Kind
  92007. * - VertexBuffer.UV6Kind
  92008. * - VertexBuffer.ColorKind
  92009. * - VertexBuffer.MatricesIndicesKind
  92010. * - VertexBuffer.MatricesIndicesExtraKind
  92011. * - VertexBuffer.MatricesWeightsKind
  92012. * - VertexBuffer.MatricesWeightsExtraKind
  92013. * @returns an array of strings
  92014. */
  92015. getVerticesDataKinds(): string[];
  92016. /**
  92017. * Returns a positive integer : the total number of indices in this mesh geometry.
  92018. * @returns the numner of indices or zero if the mesh has no geometry.
  92019. */
  92020. getTotalIndices(): number;
  92021. /**
  92022. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92023. * @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.
  92024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92025. * @returns the indices array or an empty array if the mesh has no geometry
  92026. */
  92027. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92028. readonly isBlocked: boolean;
  92029. /**
  92030. * Determine if the current mesh is ready to be rendered
  92031. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92032. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92033. * @returns true if all associated assets are ready (material, textures, shaders)
  92034. */
  92035. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92036. /**
  92037. * 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.
  92038. */
  92039. readonly areNormalsFrozen: boolean;
  92040. /**
  92041. * 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.
  92042. * @returns the current mesh
  92043. */
  92044. freezeNormals(): Mesh;
  92045. /**
  92046. * 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
  92047. * @returns the current mesh
  92048. */
  92049. unfreezeNormals(): Mesh;
  92050. /**
  92051. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92052. */
  92053. overridenInstanceCount: number;
  92054. /** @hidden */
  92055. _preActivate(): Mesh;
  92056. /** @hidden */
  92057. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92058. /** @hidden */
  92059. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92060. /**
  92061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92062. * This means the mesh underlying bounding box and sphere are recomputed.
  92063. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92064. * @returns the current mesh
  92065. */
  92066. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92067. /** @hidden */
  92068. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92069. /**
  92070. * This function will subdivide the mesh into multiple submeshes
  92071. * @param count defines the expected number of submeshes
  92072. */
  92073. subdivide(count: number): void;
  92074. /**
  92075. * Copy a FloatArray into a specific associated vertex buffer
  92076. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92077. * - VertexBuffer.PositionKind
  92078. * - VertexBuffer.UVKind
  92079. * - VertexBuffer.UV2Kind
  92080. * - VertexBuffer.UV3Kind
  92081. * - VertexBuffer.UV4Kind
  92082. * - VertexBuffer.UV5Kind
  92083. * - VertexBuffer.UV6Kind
  92084. * - VertexBuffer.ColorKind
  92085. * - VertexBuffer.MatricesIndicesKind
  92086. * - VertexBuffer.MatricesIndicesExtraKind
  92087. * - VertexBuffer.MatricesWeightsKind
  92088. * - VertexBuffer.MatricesWeightsExtraKind
  92089. * @param data defines the data source
  92090. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92091. * @param stride defines the data stride size (can be null)
  92092. * @returns the current mesh
  92093. */
  92094. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92095. /**
  92096. * Delete a vertex buffer associated with this mesh
  92097. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92098. * - VertexBuffer.PositionKind
  92099. * - VertexBuffer.UVKind
  92100. * - VertexBuffer.UV2Kind
  92101. * - VertexBuffer.UV3Kind
  92102. * - VertexBuffer.UV4Kind
  92103. * - VertexBuffer.UV5Kind
  92104. * - VertexBuffer.UV6Kind
  92105. * - VertexBuffer.ColorKind
  92106. * - VertexBuffer.MatricesIndicesKind
  92107. * - VertexBuffer.MatricesIndicesExtraKind
  92108. * - VertexBuffer.MatricesWeightsKind
  92109. * - VertexBuffer.MatricesWeightsExtraKind
  92110. */
  92111. removeVerticesData(kind: string): void;
  92112. /**
  92113. * Flags an associated vertex buffer as updatable
  92114. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92115. * - VertexBuffer.PositionKind
  92116. * - VertexBuffer.UVKind
  92117. * - VertexBuffer.UV2Kind
  92118. * - VertexBuffer.UV3Kind
  92119. * - VertexBuffer.UV4Kind
  92120. * - VertexBuffer.UV5Kind
  92121. * - VertexBuffer.UV6Kind
  92122. * - VertexBuffer.ColorKind
  92123. * - VertexBuffer.MatricesIndicesKind
  92124. * - VertexBuffer.MatricesIndicesExtraKind
  92125. * - VertexBuffer.MatricesWeightsKind
  92126. * - VertexBuffer.MatricesWeightsExtraKind
  92127. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92128. */
  92129. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92130. /**
  92131. * Sets the mesh global Vertex Buffer
  92132. * @param buffer defines the buffer to use
  92133. * @returns the current mesh
  92134. */
  92135. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92136. /**
  92137. * Update a specific associated vertex buffer
  92138. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92139. * - VertexBuffer.PositionKind
  92140. * - VertexBuffer.UVKind
  92141. * - VertexBuffer.UV2Kind
  92142. * - VertexBuffer.UV3Kind
  92143. * - VertexBuffer.UV4Kind
  92144. * - VertexBuffer.UV5Kind
  92145. * - VertexBuffer.UV6Kind
  92146. * - VertexBuffer.ColorKind
  92147. * - VertexBuffer.MatricesIndicesKind
  92148. * - VertexBuffer.MatricesIndicesExtraKind
  92149. * - VertexBuffer.MatricesWeightsKind
  92150. * - VertexBuffer.MatricesWeightsExtraKind
  92151. * @param data defines the data source
  92152. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92153. * @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)
  92154. * @returns the current mesh
  92155. */
  92156. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92157. /**
  92158. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92159. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92160. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92161. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92162. * @returns the current mesh
  92163. */
  92164. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92165. /**
  92166. * Creates a un-shared specific occurence of the geometry for the mesh.
  92167. * @returns the current mesh
  92168. */
  92169. makeGeometryUnique(): Mesh;
  92170. /**
  92171. * Set the index buffer of this mesh
  92172. * @param indices defines the source data
  92173. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92174. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92175. * @returns the current mesh
  92176. */
  92177. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92178. /**
  92179. * Update the current index buffer
  92180. * @param indices defines the source data
  92181. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92182. * @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)
  92183. * @returns the current mesh
  92184. */
  92185. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92186. /**
  92187. * Invert the geometry to move from a right handed system to a left handed one.
  92188. * @returns the current mesh
  92189. */
  92190. toLeftHanded(): Mesh;
  92191. /** @hidden */
  92192. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92193. /** @hidden */
  92194. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92195. /**
  92196. * Registers for this mesh a javascript function called just before the rendering process
  92197. * @param func defines the function to call before rendering this mesh
  92198. * @returns the current mesh
  92199. */
  92200. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92201. /**
  92202. * Disposes a previously registered javascript function called before the rendering
  92203. * @param func defines the function to remove
  92204. * @returns the current mesh
  92205. */
  92206. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92207. /**
  92208. * Registers for this mesh a javascript function called just after the rendering is complete
  92209. * @param func defines the function to call after rendering this mesh
  92210. * @returns the current mesh
  92211. */
  92212. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92213. /**
  92214. * Disposes a previously registered javascript function called after the rendering.
  92215. * @param func defines the function to remove
  92216. * @returns the current mesh
  92217. */
  92218. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92219. /** @hidden */
  92220. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92221. /** @hidden */
  92222. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92223. /** @hidden */
  92224. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92225. /** @hidden */
  92226. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92227. /** @hidden */
  92228. _rebuild(): void;
  92229. /** @hidden */
  92230. _freeze(): void;
  92231. /** @hidden */
  92232. _unFreeze(): void;
  92233. /**
  92234. * 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
  92235. * @param subMesh defines the subMesh to render
  92236. * @param enableAlphaMode defines if alpha mode can be changed
  92237. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92238. * @returns the current mesh
  92239. */
  92240. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92241. private _onBeforeDraw;
  92242. /**
  92243. * Renormalize the mesh and patch it up if there are no weights
  92244. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92245. * However in the case of zero weights then we set just a single influence to 1.
  92246. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92247. */
  92248. cleanMatrixWeights(): void;
  92249. private normalizeSkinFourWeights;
  92250. private normalizeSkinWeightsAndExtra;
  92251. /**
  92252. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92253. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92254. * the user know there was an issue with importing the mesh
  92255. * @returns a validation object with skinned, valid and report string
  92256. */
  92257. validateSkinning(): {
  92258. skinned: boolean;
  92259. valid: boolean;
  92260. report: string;
  92261. };
  92262. /** @hidden */
  92263. _checkDelayState(): Mesh;
  92264. private _queueLoad;
  92265. /**
  92266. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92267. * A mesh is in the frustum if its bounding box intersects the frustum
  92268. * @param frustumPlanes defines the frustum to test
  92269. * @returns true if the mesh is in the frustum planes
  92270. */
  92271. isInFrustum(frustumPlanes: Plane[]): boolean;
  92272. /**
  92273. * Sets the mesh material by the material or multiMaterial `id` property
  92274. * @param id is a string identifying the material or the multiMaterial
  92275. * @returns the current mesh
  92276. */
  92277. setMaterialByID(id: string): Mesh;
  92278. /**
  92279. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92280. * @returns an array of IAnimatable
  92281. */
  92282. getAnimatables(): IAnimatable[];
  92283. /**
  92284. * Modifies the mesh geometry according to the passed transformation matrix.
  92285. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92286. * The mesh normals are modified using the same transformation.
  92287. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92288. * @param transform defines the transform matrix to use
  92289. * @see http://doc.babylonjs.com/resources/baking_transformations
  92290. * @returns the current mesh
  92291. */
  92292. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92293. /**
  92294. * Modifies the mesh geometry according to its own current World Matrix.
  92295. * The mesh World Matrix is then reset.
  92296. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92297. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92298. * @see http://doc.babylonjs.com/resources/baking_transformations
  92299. * @returns the current mesh
  92300. */
  92301. bakeCurrentTransformIntoVertices(): Mesh;
  92302. /** @hidden */
  92303. readonly _positions: Nullable<Vector3[]>;
  92304. /** @hidden */
  92305. _resetPointsArrayCache(): Mesh;
  92306. /** @hidden */
  92307. _generatePointsArray(): boolean;
  92308. /**
  92309. * Returns a new Mesh object generated from the current mesh properties.
  92310. * This method must not get confused with createInstance()
  92311. * @param name is a string, the name given to the new mesh
  92312. * @param newParent can be any Node object (default `null`)
  92313. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92314. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92315. * @returns a new mesh
  92316. */
  92317. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92318. /**
  92319. * Releases resources associated with this mesh.
  92320. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92321. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92322. */
  92323. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92324. /** @hidden */
  92325. _disposeInstanceSpecificData(): void;
  92326. /**
  92327. * Modifies the mesh geometry according to a displacement map.
  92328. * 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.
  92329. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92330. * @param url is a string, the URL from the image file is to be downloaded.
  92331. * @param minHeight is the lower limit of the displacement.
  92332. * @param maxHeight is the upper limit of the displacement.
  92333. * @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.
  92334. * @param uvOffset is an optional vector2 used to offset UV.
  92335. * @param uvScale is an optional vector2 used to scale UV.
  92336. * @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.
  92337. * @returns the Mesh.
  92338. */
  92339. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92340. /**
  92341. * Modifies the mesh geometry according to a displacementMap buffer.
  92342. * 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.
  92343. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92344. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92345. * @param heightMapWidth is the width of the buffer image.
  92346. * @param heightMapHeight is the height of the buffer image.
  92347. * @param minHeight is the lower limit of the displacement.
  92348. * @param maxHeight is the upper limit of the displacement.
  92349. * @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.
  92350. * @param uvOffset is an optional vector2 used to offset UV.
  92351. * @param uvScale is an optional vector2 used to scale UV.
  92352. * @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.
  92353. * @returns the Mesh.
  92354. */
  92355. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92356. /**
  92357. * Modify the mesh to get a flat shading rendering.
  92358. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92359. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92360. * @returns current mesh
  92361. */
  92362. convertToFlatShadedMesh(): Mesh;
  92363. /**
  92364. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92365. * In other words, more vertices, no more indices and a single bigger VBO.
  92366. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92367. * @returns current mesh
  92368. */
  92369. convertToUnIndexedMesh(): Mesh;
  92370. /**
  92371. * Inverses facet orientations.
  92372. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92373. * @param flipNormals will also inverts the normals
  92374. * @returns current mesh
  92375. */
  92376. flipFaces(flipNormals?: boolean): Mesh;
  92377. /**
  92378. * Increase the number of facets and hence vertices in a mesh
  92379. * Vertex normals are interpolated from existing vertex normals
  92380. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92381. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92382. */
  92383. increaseVertices(numberPerEdge: number): void;
  92384. /**
  92385. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92386. * This will undo any application of covertToFlatShadedMesh
  92387. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92388. */
  92389. forceSharedVertices(): void;
  92390. /** @hidden */
  92391. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92392. /** @hidden */
  92393. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92394. /**
  92395. * Creates a new InstancedMesh object from the mesh model.
  92396. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92397. * @param name defines the name of the new instance
  92398. * @returns a new InstancedMesh
  92399. */
  92400. createInstance(name: string): InstancedMesh;
  92401. /**
  92402. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92403. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92404. * @returns the current mesh
  92405. */
  92406. synchronizeInstances(): Mesh;
  92407. /**
  92408. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92409. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92410. * This should be used together with the simplification to avoid disappearing triangles.
  92411. * @param successCallback an optional success callback to be called after the optimization finished.
  92412. * @returns the current mesh
  92413. */
  92414. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92415. /**
  92416. * Serialize current mesh
  92417. * @param serializationObject defines the object which will receive the serialization data
  92418. */
  92419. serialize(serializationObject: any): void;
  92420. /** @hidden */
  92421. _syncGeometryWithMorphTargetManager(): void;
  92422. /** @hidden */
  92423. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92424. /**
  92425. * Returns a new Mesh object parsed from the source provided.
  92426. * @param parsedMesh is the source
  92427. * @param scene defines the hosting scene
  92428. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92429. * @returns a new Mesh
  92430. */
  92431. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92432. /**
  92433. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92434. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92435. * @param name defines the name of the mesh to create
  92436. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92437. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92438. * @param closePath creates a seam between the first and the last points of each path of the path array
  92439. * @param offset is taken in account only if the `pathArray` is containing a single path
  92440. * @param scene defines the hosting scene
  92441. * @param updatable defines if the mesh must be flagged as updatable
  92442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92443. * @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)
  92444. * @returns a new Mesh
  92445. */
  92446. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92447. /**
  92448. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92449. * @param name defines the name of the mesh to create
  92450. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92451. * @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
  92452. * @param scene defines the hosting scene
  92453. * @param updatable defines if the mesh must be flagged as updatable
  92454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92455. * @returns a new Mesh
  92456. */
  92457. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92458. /**
  92459. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92460. * @param name defines the name of the mesh to create
  92461. * @param size sets the size (float) of each box side (default 1)
  92462. * @param scene defines the hosting scene
  92463. * @param updatable defines if the mesh must be flagged as updatable
  92464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92465. * @returns a new Mesh
  92466. */
  92467. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92468. /**
  92469. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92470. * @param name defines the name of the mesh to create
  92471. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92472. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92473. * @param scene defines the hosting scene
  92474. * @param updatable defines if the mesh must be flagged as updatable
  92475. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92476. * @returns a new Mesh
  92477. */
  92478. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92479. /**
  92480. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92481. * @param name defines the name of the mesh to create
  92482. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92483. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92484. * @param scene defines the hosting scene
  92485. * @returns a new Mesh
  92486. */
  92487. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92488. /**
  92489. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92490. * @param name defines the name of the mesh to create
  92491. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92492. * @param diameterTop set the top cap diameter (floats, default 1)
  92493. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92494. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92495. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92496. * @param scene defines the hosting scene
  92497. * @param updatable defines if the mesh must be flagged as updatable
  92498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92499. * @returns a new Mesh
  92500. */
  92501. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92502. /**
  92503. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92504. * @param name defines the name of the mesh to create
  92505. * @param diameter sets the diameter size (float) of the torus (default 1)
  92506. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92507. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92508. * @param scene defines the hosting scene
  92509. * @param updatable defines if the mesh must be flagged as updatable
  92510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92511. * @returns a new Mesh
  92512. */
  92513. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92514. /**
  92515. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92516. * @param name defines the name of the mesh to create
  92517. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92518. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92519. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92520. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92521. * @param p the number of windings on X axis (positive integers, default 2)
  92522. * @param q the number of windings on Y axis (positive integers, default 3)
  92523. * @param scene defines the hosting scene
  92524. * @param updatable defines if the mesh must be flagged as updatable
  92525. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92526. * @returns a new Mesh
  92527. */
  92528. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92529. /**
  92530. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92531. * @param name defines the name of the mesh to create
  92532. * @param points is an array successive Vector3
  92533. * @param scene defines the hosting scene
  92534. * @param updatable defines if the mesh must be flagged as updatable
  92535. * @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).
  92536. * @returns a new Mesh
  92537. */
  92538. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92539. /**
  92540. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92541. * @param name defines the name of the mesh to create
  92542. * @param points is an array successive Vector3
  92543. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92544. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92545. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92546. * @param scene defines the hosting scene
  92547. * @param updatable defines if the mesh must be flagged as updatable
  92548. * @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)
  92549. * @returns a new Mesh
  92550. */
  92551. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92552. /**
  92553. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92554. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92555. * 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.
  92556. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92557. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92558. * Remember you can only change the shape positions, not their number when updating a polygon.
  92559. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92560. * @param name defines the name of the mesh to create
  92561. * @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
  92562. * @param scene defines the hosting scene
  92563. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92564. * @param updatable defines if the mesh must be flagged as updatable
  92565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92566. * @param earcutInjection can be used to inject your own earcut reference
  92567. * @returns a new Mesh
  92568. */
  92569. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92570. /**
  92571. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92572. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92573. * @param name defines the name of the mesh to create
  92574. * @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
  92575. * @param depth defines the height of extrusion
  92576. * @param scene defines the hosting scene
  92577. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92578. * @param updatable defines if the mesh must be flagged as updatable
  92579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92580. * @param earcutInjection can be used to inject your own earcut reference
  92581. * @returns a new Mesh
  92582. */
  92583. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92584. /**
  92585. * Creates an extruded shape mesh.
  92586. * 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
  92587. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92588. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92589. * @param name defines the name of the mesh to create
  92590. * @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
  92591. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92592. * @param scale is the value to scale the shape
  92593. * @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
  92594. * @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
  92595. * @param scene defines the hosting scene
  92596. * @param updatable defines if the mesh must be flagged as updatable
  92597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92598. * @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)
  92599. * @returns a new Mesh
  92600. */
  92601. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92602. /**
  92603. * Creates an custom extruded shape mesh.
  92604. * The custom extrusion is a parametric shape.
  92605. * It has no predefined shape. Its final shape will depend on the input parameters.
  92606. * Please consider using the same method from the MeshBuilder class instead
  92607. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92608. * @param name defines the name of the mesh to create
  92609. * @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
  92610. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92611. * @param scaleFunction is a custom Javascript function called on each path point
  92612. * @param rotationFunction is a custom Javascript function called on each path point
  92613. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92614. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92615. * @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
  92616. * @param scene defines the hosting scene
  92617. * @param updatable defines if the mesh must be flagged as updatable
  92618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92619. * @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)
  92620. * @returns a new Mesh
  92621. */
  92622. 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;
  92623. /**
  92624. * Creates lathe mesh.
  92625. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92626. * Please consider using the same method from the MeshBuilder class instead
  92627. * @param name defines the name of the mesh to create
  92628. * @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
  92629. * @param radius is the radius value of the lathe
  92630. * @param tessellation is the side number of the lathe.
  92631. * @param scene defines the hosting scene
  92632. * @param updatable defines if the mesh must be flagged as updatable
  92633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92634. * @returns a new Mesh
  92635. */
  92636. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92637. /**
  92638. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92639. * @param name defines the name of the mesh to create
  92640. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92641. * @param scene defines the hosting scene
  92642. * @param updatable defines if the mesh must be flagged as updatable
  92643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92644. * @returns a new Mesh
  92645. */
  92646. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92647. /**
  92648. * Creates a ground mesh.
  92649. * Please consider using the same method from the MeshBuilder class instead
  92650. * @param name defines the name of the mesh to create
  92651. * @param width set the width of the ground
  92652. * @param height set the height of the ground
  92653. * @param subdivisions sets the number of subdivisions per side
  92654. * @param scene defines the hosting scene
  92655. * @param updatable defines if the mesh must be flagged as updatable
  92656. * @returns a new Mesh
  92657. */
  92658. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92659. /**
  92660. * Creates a tiled ground mesh.
  92661. * Please consider using the same method from the MeshBuilder class instead
  92662. * @param name defines the name of the mesh to create
  92663. * @param xmin set the ground minimum X coordinate
  92664. * @param zmin set the ground minimum Y coordinate
  92665. * @param xmax set the ground maximum X coordinate
  92666. * @param zmax set the ground maximum Z coordinate
  92667. * @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
  92668. * @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
  92669. * @param scene defines the hosting scene
  92670. * @param updatable defines if the mesh must be flagged as updatable
  92671. * @returns a new Mesh
  92672. */
  92673. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92674. w: number;
  92675. h: number;
  92676. }, precision: {
  92677. w: number;
  92678. h: number;
  92679. }, scene: Scene, updatable?: boolean): Mesh;
  92680. /**
  92681. * Creates a ground mesh from a height map.
  92682. * Please consider using the same method from the MeshBuilder class instead
  92683. * @see http://doc.babylonjs.com/babylon101/height_map
  92684. * @param name defines the name of the mesh to create
  92685. * @param url sets the URL of the height map image resource
  92686. * @param width set the ground width size
  92687. * @param height set the ground height size
  92688. * @param subdivisions sets the number of subdivision per side
  92689. * @param minHeight is the minimum altitude on the ground
  92690. * @param maxHeight is the maximum altitude on the ground
  92691. * @param scene defines the hosting scene
  92692. * @param updatable defines if the mesh must be flagged as updatable
  92693. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92694. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92695. * @returns a new Mesh
  92696. */
  92697. 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;
  92698. /**
  92699. * Creates a tube mesh.
  92700. * The tube is a parametric shape.
  92701. * It has no predefined shape. Its final shape will depend on the input parameters.
  92702. * Please consider using the same method from the MeshBuilder class instead
  92703. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92704. * @param name defines the name of the mesh to create
  92705. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92706. * @param radius sets the tube radius size
  92707. * @param tessellation is the number of sides on the tubular surface
  92708. * @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
  92709. * @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
  92710. * @param scene defines the hosting scene
  92711. * @param updatable defines if the mesh must be flagged as updatable
  92712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92713. * @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)
  92714. * @returns a new Mesh
  92715. */
  92716. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92717. (i: number, distance: number): number;
  92718. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92719. /**
  92720. * Creates a polyhedron mesh.
  92721. * Please consider using the same method from the MeshBuilder class instead.
  92722. * * 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
  92723. * * The parameter `size` (positive float, default 1) sets the polygon size
  92724. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92725. * * 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`
  92726. * * 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
  92727. * * 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)`)
  92728. * * 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
  92729. * * 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
  92730. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92731. * * If you create a double-sided mesh, you can choose what parts of 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
  92732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92733. * @param name defines the name of the mesh to create
  92734. * @param options defines the options used to create the mesh
  92735. * @param scene defines the hosting scene
  92736. * @returns a new Mesh
  92737. */
  92738. static CreatePolyhedron(name: string, options: {
  92739. type?: number;
  92740. size?: number;
  92741. sizeX?: number;
  92742. sizeY?: number;
  92743. sizeZ?: number;
  92744. custom?: any;
  92745. faceUV?: Vector4[];
  92746. faceColors?: Color4[];
  92747. updatable?: boolean;
  92748. sideOrientation?: number;
  92749. }, scene: Scene): Mesh;
  92750. /**
  92751. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92752. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92753. * * 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`)
  92754. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92755. * * 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
  92756. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92757. * * If you create a double-sided mesh, you can choose what parts of 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
  92758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92759. * @param name defines the name of the mesh
  92760. * @param options defines the options used to create the mesh
  92761. * @param scene defines the hosting scene
  92762. * @returns a new Mesh
  92763. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92764. */
  92765. static CreateIcoSphere(name: string, options: {
  92766. radius?: number;
  92767. flat?: boolean;
  92768. subdivisions?: number;
  92769. sideOrientation?: number;
  92770. updatable?: boolean;
  92771. }, scene: Scene): Mesh;
  92772. /**
  92773. * Creates a decal mesh.
  92774. * Please consider using the same method from the MeshBuilder class instead.
  92775. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92776. * @param name defines the name of the mesh
  92777. * @param sourceMesh defines the mesh receiving the decal
  92778. * @param position sets the position of the decal in world coordinates
  92779. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92780. * @param size sets the decal scaling
  92781. * @param angle sets the angle to rotate the decal
  92782. * @returns a new Mesh
  92783. */
  92784. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92785. /**
  92786. * Prepare internal position array for software CPU skinning
  92787. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92788. */
  92789. setPositionsForCPUSkinning(): Float32Array;
  92790. /**
  92791. * Prepare internal normal array for software CPU skinning
  92792. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92793. */
  92794. setNormalsForCPUSkinning(): Float32Array;
  92795. /**
  92796. * Updates the vertex buffer by applying transformation from the bones
  92797. * @param skeleton defines the skeleton to apply to current mesh
  92798. * @returns the current mesh
  92799. */
  92800. applySkeleton(skeleton: Skeleton): Mesh;
  92801. /**
  92802. * 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
  92803. * @param meshes defines the list of meshes to scan
  92804. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92805. */
  92806. static MinMax(meshes: AbstractMesh[]): {
  92807. min: Vector3;
  92808. max: Vector3;
  92809. };
  92810. /**
  92811. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92812. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92813. * @returns a vector3
  92814. */
  92815. static Center(meshesOrMinMaxVector: {
  92816. min: Vector3;
  92817. max: Vector3;
  92818. } | AbstractMesh[]): Vector3;
  92819. /**
  92820. * Merge the array of meshes into a single mesh for performance reasons.
  92821. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92822. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92823. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92824. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92825. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92826. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92827. * @returns a new mesh
  92828. */
  92829. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92830. /** @hidden */
  92831. addInstance(instance: InstancedMesh): void;
  92832. /** @hidden */
  92833. removeInstance(instance: InstancedMesh): void;
  92834. }
  92835. }
  92836. declare module BABYLON {
  92837. /**
  92838. * This is the base class of all the camera used in the application.
  92839. * @see http://doc.babylonjs.com/features/cameras
  92840. */
  92841. export class Camera extends Node {
  92842. /** @hidden */
  92843. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92844. /**
  92845. * This is the default projection mode used by the cameras.
  92846. * It helps recreating a feeling of perspective and better appreciate depth.
  92847. * This is the best way to simulate real life cameras.
  92848. */
  92849. static readonly PERSPECTIVE_CAMERA: number;
  92850. /**
  92851. * This helps creating camera with an orthographic mode.
  92852. * 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.
  92853. */
  92854. static readonly ORTHOGRAPHIC_CAMERA: number;
  92855. /**
  92856. * This is the default FOV mode for perspective cameras.
  92857. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92858. */
  92859. static readonly FOVMODE_VERTICAL_FIXED: number;
  92860. /**
  92861. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92862. */
  92863. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92864. /**
  92865. * This specifies ther is no need for a camera rig.
  92866. * Basically only one eye is rendered corresponding to the camera.
  92867. */
  92868. static readonly RIG_MODE_NONE: number;
  92869. /**
  92870. * Simulates a camera Rig with one blue eye and one red eye.
  92871. * This can be use with 3d blue and red glasses.
  92872. */
  92873. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92874. /**
  92875. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92876. */
  92877. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92878. /**
  92879. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92880. */
  92881. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92882. /**
  92883. * Defines that both eyes of the camera will be rendered over under each other.
  92884. */
  92885. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92886. /**
  92887. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92888. */
  92889. static readonly RIG_MODE_VR: number;
  92890. /**
  92891. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92892. */
  92893. static readonly RIG_MODE_WEBVR: number;
  92894. /**
  92895. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92896. */
  92897. static readonly RIG_MODE_CUSTOM: number;
  92898. /**
  92899. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92900. */
  92901. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92902. /**
  92903. * Define the input manager associated with the camera.
  92904. */
  92905. inputs: CameraInputsManager<Camera>;
  92906. /** @hidden */
  92907. _position: Vector3;
  92908. /**
  92909. * Define the current local position of the camera in the scene
  92910. */
  92911. position: Vector3;
  92912. /**
  92913. * The vector the camera should consider as up.
  92914. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92915. */
  92916. upVector: Vector3;
  92917. /**
  92918. * Define the current limit on the left side for an orthographic camera
  92919. * In scene unit
  92920. */
  92921. orthoLeft: Nullable<number>;
  92922. /**
  92923. * Define the current limit on the right side for an orthographic camera
  92924. * In scene unit
  92925. */
  92926. orthoRight: Nullable<number>;
  92927. /**
  92928. * Define the current limit on the bottom side for an orthographic camera
  92929. * In scene unit
  92930. */
  92931. orthoBottom: Nullable<number>;
  92932. /**
  92933. * Define the current limit on the top side for an orthographic camera
  92934. * In scene unit
  92935. */
  92936. orthoTop: Nullable<number>;
  92937. /**
  92938. * Field Of View is set in Radians. (default is 0.8)
  92939. */
  92940. fov: number;
  92941. /**
  92942. * Define the minimum distance the camera can see from.
  92943. * This is important to note that the depth buffer are not infinite and the closer it starts
  92944. * the more your scene might encounter depth fighting issue.
  92945. */
  92946. minZ: number;
  92947. /**
  92948. * Define the maximum distance the camera can see to.
  92949. * This is important to note that the depth buffer are not infinite and the further it end
  92950. * the more your scene might encounter depth fighting issue.
  92951. */
  92952. maxZ: number;
  92953. /**
  92954. * Define the default inertia of the camera.
  92955. * This helps giving a smooth feeling to the camera movement.
  92956. */
  92957. inertia: number;
  92958. /**
  92959. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92960. */
  92961. mode: number;
  92962. /**
  92963. * Define wether the camera is intermediate.
  92964. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92965. */
  92966. isIntermediate: boolean;
  92967. /**
  92968. * Define the viewport of the camera.
  92969. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92970. */
  92971. viewport: Viewport;
  92972. /**
  92973. * Restricts the camera to viewing objects with the same layerMask.
  92974. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92975. */
  92976. layerMask: number;
  92977. /**
  92978. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92979. */
  92980. fovMode: number;
  92981. /**
  92982. * Rig mode of the camera.
  92983. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92984. * This is normally controlled byt the camera themselves as internal use.
  92985. */
  92986. cameraRigMode: number;
  92987. /**
  92988. * Defines the distance between both "eyes" in case of a RIG
  92989. */
  92990. interaxialDistance: number;
  92991. /**
  92992. * Defines if stereoscopic rendering is done side by side or over under.
  92993. */
  92994. isStereoscopicSideBySide: boolean;
  92995. /**
  92996. * 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
  92997. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92998. * else in the scene. (Eg. security camera)
  92999. *
  93000. * 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)
  93001. */
  93002. customRenderTargets: RenderTargetTexture[];
  93003. /**
  93004. * When set, the camera will render to this render target instead of the default canvas
  93005. *
  93006. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93007. */
  93008. outputRenderTarget: Nullable<RenderTargetTexture>;
  93009. /**
  93010. * Observable triggered when the camera view matrix has changed.
  93011. */
  93012. onViewMatrixChangedObservable: Observable<Camera>;
  93013. /**
  93014. * Observable triggered when the camera Projection matrix has changed.
  93015. */
  93016. onProjectionMatrixChangedObservable: Observable<Camera>;
  93017. /**
  93018. * Observable triggered when the inputs have been processed.
  93019. */
  93020. onAfterCheckInputsObservable: Observable<Camera>;
  93021. /**
  93022. * Observable triggered when reset has been called and applied to the camera.
  93023. */
  93024. onRestoreStateObservable: Observable<Camera>;
  93025. /** @hidden */
  93026. _cameraRigParams: any;
  93027. /** @hidden */
  93028. _rigCameras: Camera[];
  93029. /** @hidden */
  93030. _rigPostProcess: Nullable<PostProcess>;
  93031. protected _webvrViewMatrix: Matrix;
  93032. /** @hidden */
  93033. _skipRendering: boolean;
  93034. /** @hidden */
  93035. _projectionMatrix: Matrix;
  93036. /** @hidden */
  93037. _postProcesses: Nullable<PostProcess>[];
  93038. /** @hidden */
  93039. _activeMeshes: SmartArray<AbstractMesh>;
  93040. protected _globalPosition: Vector3;
  93041. /** @hidden */
  93042. _computedViewMatrix: Matrix;
  93043. private _doNotComputeProjectionMatrix;
  93044. private _transformMatrix;
  93045. private _frustumPlanes;
  93046. private _refreshFrustumPlanes;
  93047. private _storedFov;
  93048. private _stateStored;
  93049. /**
  93050. * Instantiates a new camera object.
  93051. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93052. * @see http://doc.babylonjs.com/features/cameras
  93053. * @param name Defines the name of the camera in the scene
  93054. * @param position Defines the position of the camera
  93055. * @param scene Defines the scene the camera belongs too
  93056. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93057. */
  93058. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93059. /**
  93060. * Store current camera state (fov, position, etc..)
  93061. * @returns the camera
  93062. */
  93063. storeState(): Camera;
  93064. /**
  93065. * Restores the camera state values if it has been stored. You must call storeState() first
  93066. */
  93067. protected _restoreStateValues(): boolean;
  93068. /**
  93069. * Restored camera state. You must call storeState() first.
  93070. * @returns true if restored and false otherwise
  93071. */
  93072. restoreState(): boolean;
  93073. /**
  93074. * Gets the class name of the camera.
  93075. * @returns the class name
  93076. */
  93077. getClassName(): string;
  93078. /** @hidden */
  93079. readonly _isCamera: boolean;
  93080. /**
  93081. * Gets a string representation of the camera useful for debug purpose.
  93082. * @param fullDetails Defines that a more verboe level of logging is required
  93083. * @returns the string representation
  93084. */
  93085. toString(fullDetails?: boolean): string;
  93086. /**
  93087. * Gets the current world space position of the camera.
  93088. */
  93089. readonly globalPosition: Vector3;
  93090. /**
  93091. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93092. * @returns the active meshe list
  93093. */
  93094. getActiveMeshes(): SmartArray<AbstractMesh>;
  93095. /**
  93096. * Check wether a mesh is part of the current active mesh list of the camera
  93097. * @param mesh Defines the mesh to check
  93098. * @returns true if active, false otherwise
  93099. */
  93100. isActiveMesh(mesh: Mesh): boolean;
  93101. /**
  93102. * Is this camera ready to be used/rendered
  93103. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93104. * @return true if the camera is ready
  93105. */
  93106. isReady(completeCheck?: boolean): boolean;
  93107. /** @hidden */
  93108. _initCache(): void;
  93109. /** @hidden */
  93110. _updateCache(ignoreParentClass?: boolean): void;
  93111. /** @hidden */
  93112. _isSynchronized(): boolean;
  93113. /** @hidden */
  93114. _isSynchronizedViewMatrix(): boolean;
  93115. /** @hidden */
  93116. _isSynchronizedProjectionMatrix(): boolean;
  93117. /**
  93118. * Attach the input controls to a specific dom element to get the input from.
  93119. * @param element Defines the element the controls should be listened from
  93120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93121. */
  93122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93123. /**
  93124. * Detach the current controls from the specified dom element.
  93125. * @param element Defines the element to stop listening the inputs from
  93126. */
  93127. detachControl(element: HTMLElement): void;
  93128. /**
  93129. * Update the camera state according to the different inputs gathered during the frame.
  93130. */
  93131. update(): void;
  93132. /** @hidden */
  93133. _checkInputs(): void;
  93134. /** @hidden */
  93135. readonly rigCameras: Camera[];
  93136. /**
  93137. * Gets the post process used by the rig cameras
  93138. */
  93139. readonly rigPostProcess: Nullable<PostProcess>;
  93140. /**
  93141. * Internal, gets the first post proces.
  93142. * @returns the first post process to be run on this camera.
  93143. */
  93144. _getFirstPostProcess(): Nullable<PostProcess>;
  93145. private _cascadePostProcessesToRigCams;
  93146. /**
  93147. * Attach a post process to the camera.
  93148. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93149. * @param postProcess The post process to attach to the camera
  93150. * @param insertAt The position of the post process in case several of them are in use in the scene
  93151. * @returns the position the post process has been inserted at
  93152. */
  93153. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93154. /**
  93155. * Detach a post process to the camera.
  93156. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93157. * @param postProcess The post process to detach from the camera
  93158. */
  93159. detachPostProcess(postProcess: PostProcess): void;
  93160. /**
  93161. * Gets the current world matrix of the camera
  93162. */
  93163. getWorldMatrix(): Matrix;
  93164. /** @hidden */
  93165. _getViewMatrix(): Matrix;
  93166. /**
  93167. * Gets the current view matrix of the camera.
  93168. * @param force forces the camera to recompute the matrix without looking at the cached state
  93169. * @returns the view matrix
  93170. */
  93171. getViewMatrix(force?: boolean): Matrix;
  93172. /**
  93173. * Freeze the projection matrix.
  93174. * It will prevent the cache check of the camera projection compute and can speed up perf
  93175. * if no parameter of the camera are meant to change
  93176. * @param projection Defines manually a projection if necessary
  93177. */
  93178. freezeProjectionMatrix(projection?: Matrix): void;
  93179. /**
  93180. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93181. */
  93182. unfreezeProjectionMatrix(): void;
  93183. /**
  93184. * Gets the current projection matrix of the camera.
  93185. * @param force forces the camera to recompute the matrix without looking at the cached state
  93186. * @returns the projection matrix
  93187. */
  93188. getProjectionMatrix(force?: boolean): Matrix;
  93189. /**
  93190. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93191. * @returns a Matrix
  93192. */
  93193. getTransformationMatrix(): Matrix;
  93194. private _updateFrustumPlanes;
  93195. /**
  93196. * Checks if a cullable object (mesh...) is in the camera frustum
  93197. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93198. * @param target The object to check
  93199. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93200. * @returns true if the object is in frustum otherwise false
  93201. */
  93202. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93203. /**
  93204. * Checks if a cullable object (mesh...) is in the camera frustum
  93205. * Unlike isInFrustum this cheks the full bounding box
  93206. * @param target The object to check
  93207. * @returns true if the object is in frustum otherwise false
  93208. */
  93209. isCompletelyInFrustum(target: ICullable): boolean;
  93210. /**
  93211. * Gets a ray in the forward direction from the camera.
  93212. * @param length Defines the length of the ray to create
  93213. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93214. * @param origin Defines the start point of the ray which defaults to the camera position
  93215. * @returns the forward ray
  93216. */
  93217. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93218. /**
  93219. * Releases resources associated with this node.
  93220. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93221. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93222. */
  93223. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93224. /** @hidden */
  93225. _isLeftCamera: boolean;
  93226. /**
  93227. * Gets the left camera of a rig setup in case of Rigged Camera
  93228. */
  93229. readonly isLeftCamera: boolean;
  93230. /** @hidden */
  93231. _isRightCamera: boolean;
  93232. /**
  93233. * Gets the right camera of a rig setup in case of Rigged Camera
  93234. */
  93235. readonly isRightCamera: boolean;
  93236. /**
  93237. * Gets the left camera of a rig setup in case of Rigged Camera
  93238. */
  93239. readonly leftCamera: Nullable<FreeCamera>;
  93240. /**
  93241. * Gets the right camera of a rig setup in case of Rigged Camera
  93242. */
  93243. readonly rightCamera: Nullable<FreeCamera>;
  93244. /**
  93245. * Gets the left camera target of a rig setup in case of Rigged Camera
  93246. * @returns the target position
  93247. */
  93248. getLeftTarget(): Nullable<Vector3>;
  93249. /**
  93250. * Gets the right camera target of a rig setup in case of Rigged Camera
  93251. * @returns the target position
  93252. */
  93253. getRightTarget(): Nullable<Vector3>;
  93254. /**
  93255. * @hidden
  93256. */
  93257. setCameraRigMode(mode: number, rigParams: any): void;
  93258. /** @hidden */
  93259. static _setStereoscopicRigMode(camera: Camera): void;
  93260. /** @hidden */
  93261. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93262. /** @hidden */
  93263. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93264. /** @hidden */
  93265. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93266. /** @hidden */
  93267. _getVRProjectionMatrix(): Matrix;
  93268. protected _updateCameraRotationMatrix(): void;
  93269. protected _updateWebVRCameraRotationMatrix(): void;
  93270. /**
  93271. * This function MUST be overwritten by the different WebVR cameras available.
  93272. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93273. * @hidden
  93274. */
  93275. _getWebVRProjectionMatrix(): Matrix;
  93276. /**
  93277. * This function MUST be overwritten by the different WebVR cameras available.
  93278. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93279. * @hidden
  93280. */
  93281. _getWebVRViewMatrix(): Matrix;
  93282. /** @hidden */
  93283. setCameraRigParameter(name: string, value: any): void;
  93284. /**
  93285. * needs to be overridden by children so sub has required properties to be copied
  93286. * @hidden
  93287. */
  93288. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93289. /**
  93290. * May need to be overridden by children
  93291. * @hidden
  93292. */
  93293. _updateRigCameras(): void;
  93294. /** @hidden */
  93295. _setupInputs(): void;
  93296. /**
  93297. * Serialiaze the camera setup to a json represention
  93298. * @returns the JSON representation
  93299. */
  93300. serialize(): any;
  93301. /**
  93302. * Clones the current camera.
  93303. * @param name The cloned camera name
  93304. * @returns the cloned camera
  93305. */
  93306. clone(name: string): Camera;
  93307. /**
  93308. * Gets the direction of the camera relative to a given local axis.
  93309. * @param localAxis Defines the reference axis to provide a relative direction.
  93310. * @return the direction
  93311. */
  93312. getDirection(localAxis: Vector3): Vector3;
  93313. /**
  93314. * Returns the current camera absolute rotation
  93315. */
  93316. readonly absoluteRotation: Quaternion;
  93317. /**
  93318. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93319. * @param localAxis Defines the reference axis to provide a relative direction.
  93320. * @param result Defines the vector to store the result in
  93321. */
  93322. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93323. /**
  93324. * Gets a camera constructor for a given camera type
  93325. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93326. * @param name The name of the camera the result will be able to instantiate
  93327. * @param scene The scene the result will construct the camera in
  93328. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93329. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93330. * @returns a factory method to construc the camera
  93331. */
  93332. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93333. /**
  93334. * Compute the world matrix of the camera.
  93335. * @returns the camera world matrix
  93336. */
  93337. computeWorldMatrix(): Matrix;
  93338. /**
  93339. * Parse a JSON and creates the camera from the parsed information
  93340. * @param parsedCamera The JSON to parse
  93341. * @param scene The scene to instantiate the camera in
  93342. * @returns the newly constructed camera
  93343. */
  93344. static Parse(parsedCamera: any, scene: Scene): Camera;
  93345. }
  93346. }
  93347. declare module BABYLON {
  93348. /**
  93349. * Class containing static functions to help procedurally build meshes
  93350. */
  93351. export class DiscBuilder {
  93352. /**
  93353. * Creates a plane polygonal mesh. By default, this is a disc
  93354. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93355. * * 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
  93356. * * 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
  93357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93360. * @param name defines the name of the mesh
  93361. * @param options defines the options used to create the mesh
  93362. * @param scene defines the hosting scene
  93363. * @returns the plane polygonal mesh
  93364. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93365. */
  93366. static CreateDisc(name: string, options: {
  93367. radius?: number;
  93368. tessellation?: number;
  93369. arc?: number;
  93370. updatable?: boolean;
  93371. sideOrientation?: number;
  93372. frontUVs?: Vector4;
  93373. backUVs?: Vector4;
  93374. }, scene?: Nullable<Scene>): Mesh;
  93375. }
  93376. }
  93377. declare module BABYLON {
  93378. /**
  93379. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93380. *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.
  93381. * The SPS is also a particle system. It provides some methods to manage the particles.
  93382. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93383. *
  93384. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93385. */
  93386. export class SolidParticleSystem implements IDisposable {
  93387. /**
  93388. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93389. * Example : var p = SPS.particles[i];
  93390. */
  93391. particles: SolidParticle[];
  93392. /**
  93393. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93394. */
  93395. nbParticles: number;
  93396. /**
  93397. * If the particles must ever face the camera (default false). Useful for planar particles.
  93398. */
  93399. billboard: boolean;
  93400. /**
  93401. * Recompute normals when adding a shape
  93402. */
  93403. recomputeNormals: boolean;
  93404. /**
  93405. * This a counter ofr your own usage. It's not set by any SPS functions.
  93406. */
  93407. counter: number;
  93408. /**
  93409. * The SPS name. This name is also given to the underlying mesh.
  93410. */
  93411. name: string;
  93412. /**
  93413. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93414. */
  93415. mesh: Mesh;
  93416. /**
  93417. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93418. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93419. */
  93420. vars: any;
  93421. /**
  93422. * This array is populated when the SPS is set as 'pickable'.
  93423. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93424. * Each element of this array is an object `{idx: int, faceId: int}`.
  93425. * `idx` is the picked particle index in the `SPS.particles` array
  93426. * `faceId` is the picked face index counted within this particle.
  93427. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93428. */
  93429. pickedParticles: {
  93430. idx: number;
  93431. faceId: number;
  93432. }[];
  93433. /**
  93434. * This array is populated when `enableDepthSort` is set to true.
  93435. * Each element of this array is an instance of the class DepthSortedParticle.
  93436. */
  93437. depthSortedParticles: DepthSortedParticle[];
  93438. /**
  93439. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93440. * @hidden
  93441. */
  93442. _bSphereOnly: boolean;
  93443. /**
  93444. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93445. * @hidden
  93446. */
  93447. _bSphereRadiusFactor: number;
  93448. private _scene;
  93449. private _positions;
  93450. private _indices;
  93451. private _normals;
  93452. private _colors;
  93453. private _uvs;
  93454. private _indices32;
  93455. private _positions32;
  93456. private _normals32;
  93457. private _fixedNormal32;
  93458. private _colors32;
  93459. private _uvs32;
  93460. private _index;
  93461. private _updatable;
  93462. private _pickable;
  93463. private _isVisibilityBoxLocked;
  93464. private _alwaysVisible;
  93465. private _depthSort;
  93466. private _expandable;
  93467. private _shapeCounter;
  93468. private _copy;
  93469. private _color;
  93470. private _computeParticleColor;
  93471. private _computeParticleTexture;
  93472. private _computeParticleRotation;
  93473. private _computeParticleVertex;
  93474. private _computeBoundingBox;
  93475. private _depthSortParticles;
  93476. private _camera;
  93477. private _mustUnrotateFixedNormals;
  93478. private _particlesIntersect;
  93479. private _needs32Bits;
  93480. private _isNotBuilt;
  93481. private _lastParticleId;
  93482. private _idxOfId;
  93483. /**
  93484. * Creates a SPS (Solid Particle System) object.
  93485. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93486. * @param scene (Scene) is the scene in which the SPS is added.
  93487. * @param options defines the options of the sps e.g.
  93488. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93489. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93490. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93491. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93492. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93493. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93494. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93495. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93496. */
  93497. constructor(name: string, scene: Scene, options?: {
  93498. updatable?: boolean;
  93499. isPickable?: boolean;
  93500. enableDepthSort?: boolean;
  93501. particleIntersection?: boolean;
  93502. boundingSphereOnly?: boolean;
  93503. bSphereRadiusFactor?: number;
  93504. expandable?: boolean;
  93505. });
  93506. /**
  93507. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93508. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93509. * @returns the created mesh
  93510. */
  93511. buildMesh(): Mesh;
  93512. /**
  93513. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93514. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93515. * Thus the particles generated from `digest()` have their property `position` set yet.
  93516. * @param mesh ( Mesh ) is the mesh to be digested
  93517. * @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
  93518. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93519. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93520. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93521. * @returns the current SPS
  93522. */
  93523. digest(mesh: Mesh, options?: {
  93524. facetNb?: number;
  93525. number?: number;
  93526. delta?: number;
  93527. storage?: [];
  93528. }): SolidParticleSystem;
  93529. /**
  93530. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93531. * @hidden
  93532. */
  93533. private _unrotateFixedNormals;
  93534. /**
  93535. * Resets the temporary working copy particle
  93536. * @hidden
  93537. */
  93538. private _resetCopy;
  93539. /**
  93540. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93541. * @param p the current index in the positions array to be updated
  93542. * @param shape a Vector3 array, the shape geometry
  93543. * @param positions the positions array to be updated
  93544. * @param meshInd the shape indices array
  93545. * @param indices the indices array to be updated
  93546. * @param meshUV the shape uv array
  93547. * @param uvs the uv array to be updated
  93548. * @param meshCol the shape color array
  93549. * @param colors the color array to be updated
  93550. * @param meshNor the shape normals array
  93551. * @param normals the normals array to be updated
  93552. * @param idx the particle index
  93553. * @param idxInShape the particle index in its shape
  93554. * @param options the addShape() method passed options
  93555. * @hidden
  93556. */
  93557. private _meshBuilder;
  93558. /**
  93559. * Returns a shape Vector3 array from positions float array
  93560. * @param positions float array
  93561. * @returns a vector3 array
  93562. * @hidden
  93563. */
  93564. private _posToShape;
  93565. /**
  93566. * Returns a shapeUV array from a float uvs (array deep copy)
  93567. * @param uvs as a float array
  93568. * @returns a shapeUV array
  93569. * @hidden
  93570. */
  93571. private _uvsToShapeUV;
  93572. /**
  93573. * Adds a new particle object in the particles array
  93574. * @param idx particle index in particles array
  93575. * @param id particle id
  93576. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93577. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93578. * @param model particle ModelShape object
  93579. * @param shapeId model shape identifier
  93580. * @param idxInShape index of the particle in the current model
  93581. * @param bInfo model bounding info object
  93582. * @param storage target storage array, if any
  93583. * @hidden
  93584. */
  93585. private _addParticle;
  93586. /**
  93587. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93588. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93589. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93590. * @param nb (positive integer) the number of particles to be created from this model
  93591. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93592. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93593. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93594. * @returns the number of shapes in the system
  93595. */
  93596. addShape(mesh: Mesh, nb: number, options?: {
  93597. positionFunction?: any;
  93598. vertexFunction?: any;
  93599. storage?: [];
  93600. }): number;
  93601. /**
  93602. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93603. * @hidden
  93604. */
  93605. private _rebuildParticle;
  93606. /**
  93607. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93608. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  93609. * @returns the SPS.
  93610. */
  93611. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93612. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93613. * Returns an array with the removed particles.
  93614. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  93615. * The SPS can't be empty so at least one particle needs to remain in place.
  93616. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93617. * @param start index of the first particle to remove
  93618. * @param end index of the last particle to remove (included)
  93619. * @returns an array populated with the removed particles
  93620. */
  93621. removeParticles(start: number, end: number): SolidParticle[];
  93622. /**
  93623. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93624. * @param solidParticleArray an array populated with Solid Particles objects
  93625. * @returns the SPS
  93626. */
  93627. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93628. /**
  93629. * Creates a new particle and modifies the SPS mesh geometry :
  93630. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93631. * - calls _addParticle() to populate the particle array
  93632. * factorized code from addShape() and insertParticlesFromArray()
  93633. * @param idx particle index in the particles array
  93634. * @param i particle index in its shape
  93635. * @param modelShape particle ModelShape object
  93636. * @param shape shape vertex array
  93637. * @param meshInd shape indices array
  93638. * @param meshUV shape uv array
  93639. * @param meshCol shape color array
  93640. * @param meshNor shape normals array
  93641. * @param bbInfo shape bounding info
  93642. * @param storage target particle storage
  93643. * @options addShape() passed options
  93644. * @hidden
  93645. */
  93646. private _insertNewParticle;
  93647. /**
  93648. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93649. * This method calls `updateParticle()` for each particle of the SPS.
  93650. * For an animated SPS, it is usually called within the render loop.
  93651. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  93652. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93653. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93654. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93655. * @returns the SPS.
  93656. */
  93657. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93658. /**
  93659. * Disposes the SPS.
  93660. */
  93661. dispose(): void;
  93662. /**
  93663. * Returns a SolidParticle object from its identifier : particle.id
  93664. * @param id (integer) the particle Id
  93665. * @returns the searched particle or null if not found in the SPS.
  93666. */
  93667. getParticleById(id: number): Nullable<SolidParticle>;
  93668. /**
  93669. * Returns a new array populated with the particles having the passed shapeId.
  93670. * @param shapeId (integer) the shape identifier
  93671. * @returns a new solid particle array
  93672. */
  93673. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93674. /**
  93675. * Populates the passed array "ref" with the particles having the passed shapeId.
  93676. * @param shapeId the shape identifier
  93677. * @returns the SPS
  93678. * @param ref
  93679. */
  93680. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93681. /**
  93682. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93683. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93684. * @returns the SPS.
  93685. */
  93686. refreshVisibleSize(): SolidParticleSystem;
  93687. /**
  93688. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93689. * @param size the size (float) of the visibility box
  93690. * note : this doesn't lock the SPS mesh bounding box.
  93691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93692. */
  93693. setVisibilityBox(size: number): void;
  93694. /**
  93695. * Gets whether the SPS as always visible or not
  93696. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93697. */
  93698. /**
  93699. * Sets the SPS as always visible or not
  93700. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93701. */
  93702. isAlwaysVisible: boolean;
  93703. /**
  93704. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93705. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93706. */
  93707. /**
  93708. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93709. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93710. */
  93711. isVisibilityBoxLocked: boolean;
  93712. /**
  93713. * Tells to `setParticles()` to compute the particle rotations or not.
  93714. * Default value : true. The SPS is faster when it's set to false.
  93715. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93716. */
  93717. /**
  93718. * Gets if `setParticles()` computes the particle rotations or not.
  93719. * Default value : true. The SPS is faster when it's set to false.
  93720. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93721. */
  93722. computeParticleRotation: boolean;
  93723. /**
  93724. * Tells to `setParticles()` to compute the particle colors or not.
  93725. * Default value : true. The SPS is faster when it's set to false.
  93726. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93727. */
  93728. /**
  93729. * Gets if `setParticles()` computes the particle colors or not.
  93730. * Default value : true. The SPS is faster when it's set to false.
  93731. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93732. */
  93733. computeParticleColor: boolean;
  93734. /**
  93735. * Gets if `setParticles()` computes the particle textures or not.
  93736. * Default value : true. The SPS is faster when it's set to false.
  93737. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93738. */
  93739. computeParticleTexture: boolean;
  93740. /**
  93741. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93742. * Default value : false. The SPS is faster when it's set to false.
  93743. * Note : the particle custom vertex positions aren't stored values.
  93744. */
  93745. /**
  93746. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93747. * Default value : false. The SPS is faster when it's set to false.
  93748. * Note : the particle custom vertex positions aren't stored values.
  93749. */
  93750. computeParticleVertex: boolean;
  93751. /**
  93752. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93753. */
  93754. /**
  93755. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93756. */
  93757. computeBoundingBox: boolean;
  93758. /**
  93759. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93760. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93761. * Default : `true`
  93762. */
  93763. /**
  93764. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93765. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93766. * Default : `true`
  93767. */
  93768. depthSortParticles: boolean;
  93769. /**
  93770. * Gets if the SPS is created as expandable at construction time.
  93771. * Default : `false`
  93772. */
  93773. readonly expandable: boolean;
  93774. /**
  93775. * This function does nothing. It may be overwritten to set all the particle first values.
  93776. * The SPS doesn't call this function, you may have to call it by your own.
  93777. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93778. */
  93779. initParticles(): void;
  93780. /**
  93781. * This function does nothing. It may be overwritten to recycle a particle.
  93782. * The SPS doesn't call this function, you may have to call it by your own.
  93783. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93784. * @param particle The particle to recycle
  93785. * @returns the recycled particle
  93786. */
  93787. recycleParticle(particle: SolidParticle): SolidParticle;
  93788. /**
  93789. * Updates a particle : this function should be overwritten by the user.
  93790. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93792. * @example : just set a particle position or velocity and recycle conditions
  93793. * @param particle The particle to update
  93794. * @returns the updated particle
  93795. */
  93796. updateParticle(particle: SolidParticle): SolidParticle;
  93797. /**
  93798. * Updates a vertex of a particle : it can be overwritten by the user.
  93799. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93800. * @param particle the current particle
  93801. * @param vertex the current index of the current particle
  93802. * @param pt the index of the current vertex in the particle shape
  93803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93804. * @example : just set a vertex particle position
  93805. * @returns the updated vertex
  93806. */
  93807. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93808. /**
  93809. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93810. * This does nothing and may be overwritten by the user.
  93811. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93812. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93813. * @param update the boolean update value actually passed to setParticles()
  93814. */
  93815. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93816. /**
  93817. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93818. * This will be passed three parameters.
  93819. * This does nothing and may be overwritten by the user.
  93820. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93821. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93822. * @param update the boolean update value actually passed to setParticles()
  93823. */
  93824. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93825. }
  93826. }
  93827. declare module BABYLON {
  93828. /**
  93829. * Represents one particle of a solid particle system.
  93830. */
  93831. export class SolidParticle {
  93832. /**
  93833. * particle global index
  93834. */
  93835. idx: number;
  93836. /**
  93837. * particle identifier
  93838. */
  93839. id: number;
  93840. /**
  93841. * The color of the particle
  93842. */
  93843. color: Nullable<Color4>;
  93844. /**
  93845. * The world space position of the particle.
  93846. */
  93847. position: Vector3;
  93848. /**
  93849. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93850. */
  93851. rotation: Vector3;
  93852. /**
  93853. * The world space rotation quaternion of the particle.
  93854. */
  93855. rotationQuaternion: Nullable<Quaternion>;
  93856. /**
  93857. * The scaling of the particle.
  93858. */
  93859. scaling: Vector3;
  93860. /**
  93861. * The uvs of the particle.
  93862. */
  93863. uvs: Vector4;
  93864. /**
  93865. * The current speed of the particle.
  93866. */
  93867. velocity: Vector3;
  93868. /**
  93869. * The pivot point in the particle local space.
  93870. */
  93871. pivot: Vector3;
  93872. /**
  93873. * Must the particle be translated from its pivot point in its local space ?
  93874. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93875. * Default : false
  93876. */
  93877. translateFromPivot: boolean;
  93878. /**
  93879. * Is the particle active or not ?
  93880. */
  93881. alive: boolean;
  93882. /**
  93883. * Is the particle visible or not ?
  93884. */
  93885. isVisible: boolean;
  93886. /**
  93887. * Index of this particle in the global "positions" array (Internal use)
  93888. * @hidden
  93889. */
  93890. _pos: number;
  93891. /**
  93892. * @hidden Index of this particle in the global "indices" array (Internal use)
  93893. */
  93894. _ind: number;
  93895. /**
  93896. * @hidden ModelShape of this particle (Internal use)
  93897. */
  93898. _model: ModelShape;
  93899. /**
  93900. * ModelShape id of this particle
  93901. */
  93902. shapeId: number;
  93903. /**
  93904. * Index of the particle in its shape id
  93905. */
  93906. idxInShape: number;
  93907. /**
  93908. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93909. */
  93910. _modelBoundingInfo: BoundingInfo;
  93911. /**
  93912. * @hidden Particle BoundingInfo object (Internal use)
  93913. */
  93914. _boundingInfo: BoundingInfo;
  93915. /**
  93916. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93917. */
  93918. _sps: SolidParticleSystem;
  93919. /**
  93920. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93921. */
  93922. _stillInvisible: boolean;
  93923. /**
  93924. * @hidden Last computed particle rotation matrix
  93925. */
  93926. _rotationMatrix: number[];
  93927. /**
  93928. * Parent particle Id, if any.
  93929. * Default null.
  93930. */
  93931. parentId: Nullable<number>;
  93932. /**
  93933. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93934. * The possible values are :
  93935. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93936. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93937. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93938. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93939. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93940. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93941. * */
  93942. cullingStrategy: number;
  93943. /**
  93944. * @hidden Internal global position in the SPS.
  93945. */
  93946. _globalPosition: Vector3;
  93947. /**
  93948. * Creates a Solid Particle object.
  93949. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93950. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  93951. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  93952. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93953. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93954. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93955. * @param shapeId (integer) is the model shape identifier in the SPS.
  93956. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93957. * @param sps defines the sps it is associated to
  93958. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93959. */
  93960. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93961. /**
  93962. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  93963. * @param target the particle target
  93964. * @returns the current particle
  93965. */
  93966. copyToRef(target: SolidParticle): SolidParticle;
  93967. /**
  93968. * Legacy support, changed scale to scaling
  93969. */
  93970. /**
  93971. * Legacy support, changed scale to scaling
  93972. */
  93973. scale: Vector3;
  93974. /**
  93975. * Legacy support, changed quaternion to rotationQuaternion
  93976. */
  93977. /**
  93978. * Legacy support, changed quaternion to rotationQuaternion
  93979. */
  93980. quaternion: Nullable<Quaternion>;
  93981. /**
  93982. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93983. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93984. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93985. * @returns true if it intersects
  93986. */
  93987. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93988. /**
  93989. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93990. * A particle is in the frustum if its bounding box intersects the frustum
  93991. * @param frustumPlanes defines the frustum to test
  93992. * @returns true if the particle is in the frustum planes
  93993. */
  93994. isInFrustum(frustumPlanes: Plane[]): boolean;
  93995. /**
  93996. * get the rotation matrix of the particle
  93997. * @hidden
  93998. */
  93999. getRotationMatrix(m: Matrix): void;
  94000. }
  94001. /**
  94002. * Represents the shape of the model used by one particle of a solid particle system.
  94003. * SPS internal tool, don't use it manually.
  94004. */
  94005. export class ModelShape {
  94006. /**
  94007. * The shape id
  94008. * @hidden
  94009. */
  94010. shapeID: number;
  94011. /**
  94012. * flat array of model positions (internal use)
  94013. * @hidden
  94014. */
  94015. _shape: Vector3[];
  94016. /**
  94017. * flat array of model UVs (internal use)
  94018. * @hidden
  94019. */
  94020. _shapeUV: number[];
  94021. /**
  94022. * color array of the model
  94023. * @hidden
  94024. */
  94025. _shapeColors: number[];
  94026. /**
  94027. * indices array of the model
  94028. * @hidden
  94029. */
  94030. _indices: number[];
  94031. /**
  94032. * normals array of the model
  94033. * @hidden
  94034. */
  94035. _normals: number[];
  94036. /**
  94037. * length of the shape in the model indices array (internal use)
  94038. * @hidden
  94039. */
  94040. _indicesLength: number;
  94041. /**
  94042. * Custom position function (internal use)
  94043. * @hidden
  94044. */
  94045. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94046. /**
  94047. * Custom vertex function (internal use)
  94048. * @hidden
  94049. */
  94050. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94051. /**
  94052. * 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.
  94053. * SPS internal tool, don't use it manually.
  94054. * @hidden
  94055. */
  94056. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  94057. }
  94058. /**
  94059. * Represents a Depth Sorted Particle in the solid particle system.
  94060. */
  94061. export class DepthSortedParticle {
  94062. /**
  94063. * Index of the particle in the "indices" array
  94064. */
  94065. ind: number;
  94066. /**
  94067. * Length of the particle shape in the "indices" array
  94068. */
  94069. indicesLength: number;
  94070. /**
  94071. * Squared distance from the particle to the camera
  94072. */
  94073. sqDistance: number;
  94074. }
  94075. }
  94076. declare module BABYLON {
  94077. /**
  94078. * @hidden
  94079. */
  94080. export class _MeshCollisionData {
  94081. _checkCollisions: boolean;
  94082. _collisionMask: number;
  94083. _collisionGroup: number;
  94084. _collider: Nullable<Collider>;
  94085. _oldPositionForCollisions: Vector3;
  94086. _diffPositionForCollisions: Vector3;
  94087. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94088. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94089. }
  94090. }
  94091. declare module BABYLON {
  94092. /** @hidden */
  94093. class _FacetDataStorage {
  94094. facetPositions: Vector3[];
  94095. facetNormals: Vector3[];
  94096. facetPartitioning: number[][];
  94097. facetNb: number;
  94098. partitioningSubdivisions: number;
  94099. partitioningBBoxRatio: number;
  94100. facetDataEnabled: boolean;
  94101. facetParameters: any;
  94102. bbSize: Vector3;
  94103. subDiv: {
  94104. max: number;
  94105. X: number;
  94106. Y: number;
  94107. Z: number;
  94108. };
  94109. facetDepthSort: boolean;
  94110. facetDepthSortEnabled: boolean;
  94111. depthSortedIndices: IndicesArray;
  94112. depthSortedFacets: {
  94113. ind: number;
  94114. sqDistance: number;
  94115. }[];
  94116. facetDepthSortFunction: (f1: {
  94117. ind: number;
  94118. sqDistance: number;
  94119. }, f2: {
  94120. ind: number;
  94121. sqDistance: number;
  94122. }) => number;
  94123. facetDepthSortFrom: Vector3;
  94124. facetDepthSortOrigin: Vector3;
  94125. invertedMatrix: Matrix;
  94126. }
  94127. /**
  94128. * @hidden
  94129. **/
  94130. class _InternalAbstractMeshDataInfo {
  94131. _hasVertexAlpha: boolean;
  94132. _useVertexColors: boolean;
  94133. _numBoneInfluencers: number;
  94134. _applyFog: boolean;
  94135. _receiveShadows: boolean;
  94136. _facetData: _FacetDataStorage;
  94137. _visibility: number;
  94138. _skeleton: Nullable<Skeleton>;
  94139. _layerMask: number;
  94140. _computeBonesUsingShaders: boolean;
  94141. _isActive: boolean;
  94142. _onlyForInstances: boolean;
  94143. _isActiveIntermediate: boolean;
  94144. _onlyForInstancesIntermediate: boolean;
  94145. _actAsRegularMesh: boolean;
  94146. }
  94147. /**
  94148. * Class used to store all common mesh properties
  94149. */
  94150. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94151. /** No occlusion */
  94152. static OCCLUSION_TYPE_NONE: number;
  94153. /** Occlusion set to optimisitic */
  94154. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94155. /** Occlusion set to strict */
  94156. static OCCLUSION_TYPE_STRICT: number;
  94157. /** Use an accurante occlusion algorithm */
  94158. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94159. /** Use a conservative occlusion algorithm */
  94160. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94161. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94162. * Test order :
  94163. * Is the bounding sphere outside the frustum ?
  94164. * If not, are the bounding box vertices outside the frustum ?
  94165. * It not, then the cullable object is in the frustum.
  94166. */
  94167. static readonly CULLINGSTRATEGY_STANDARD: number;
  94168. /** Culling strategy : Bounding Sphere Only.
  94169. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94170. * It's also less accurate than the standard because some not visible objects can still be selected.
  94171. * Test : is the bounding sphere outside the frustum ?
  94172. * If not, then the cullable object is in the frustum.
  94173. */
  94174. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94175. /** Culling strategy : Optimistic Inclusion.
  94176. * This in an inclusion test first, then the standard exclusion test.
  94177. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94178. * 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.
  94179. * Anyway, it's as accurate as the standard strategy.
  94180. * Test :
  94181. * Is the cullable object bounding sphere center in the frustum ?
  94182. * If not, apply the default culling strategy.
  94183. */
  94184. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94185. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94186. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94187. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94188. * 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.
  94189. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94190. * Test :
  94191. * Is the cullable object bounding sphere center in the frustum ?
  94192. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94193. */
  94194. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94195. /**
  94196. * No billboard
  94197. */
  94198. static readonly BILLBOARDMODE_NONE: number;
  94199. /** Billboard on X axis */
  94200. static readonly BILLBOARDMODE_X: number;
  94201. /** Billboard on Y axis */
  94202. static readonly BILLBOARDMODE_Y: number;
  94203. /** Billboard on Z axis */
  94204. static readonly BILLBOARDMODE_Z: number;
  94205. /** Billboard on all axes */
  94206. static readonly BILLBOARDMODE_ALL: number;
  94207. /** Billboard on using position instead of orientation */
  94208. static readonly BILLBOARDMODE_USE_POSITION: number;
  94209. /** @hidden */
  94210. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94211. /**
  94212. * The culling strategy to use to check whether the mesh must be rendered or not.
  94213. * This value can be changed at any time and will be used on the next render mesh selection.
  94214. * The possible values are :
  94215. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94216. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94217. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94218. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94219. * Please read each static variable documentation to get details about the culling process.
  94220. * */
  94221. cullingStrategy: number;
  94222. /**
  94223. * Gets the number of facets in the mesh
  94224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94225. */
  94226. readonly facetNb: number;
  94227. /**
  94228. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94230. */
  94231. partitioningSubdivisions: number;
  94232. /**
  94233. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94234. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94236. */
  94237. partitioningBBoxRatio: number;
  94238. /**
  94239. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94240. * Works only for updatable meshes.
  94241. * Doesn't work with multi-materials
  94242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94243. */
  94244. mustDepthSortFacets: boolean;
  94245. /**
  94246. * The location (Vector3) where the facet depth sort must be computed from.
  94247. * By default, the active camera position.
  94248. * Used only when facet depth sort is enabled
  94249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94250. */
  94251. facetDepthSortFrom: Vector3;
  94252. /**
  94253. * gets a boolean indicating if facetData is enabled
  94254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94255. */
  94256. readonly isFacetDataEnabled: boolean;
  94257. /** @hidden */
  94258. _updateNonUniformScalingState(value: boolean): boolean;
  94259. /**
  94260. * An event triggered when this mesh collides with another one
  94261. */
  94262. onCollideObservable: Observable<AbstractMesh>;
  94263. /** Set a function to call when this mesh collides with another one */
  94264. onCollide: () => void;
  94265. /**
  94266. * An event triggered when the collision's position changes
  94267. */
  94268. onCollisionPositionChangeObservable: Observable<Vector3>;
  94269. /** Set a function to call when the collision's position changes */
  94270. onCollisionPositionChange: () => void;
  94271. /**
  94272. * An event triggered when material is changed
  94273. */
  94274. onMaterialChangedObservable: Observable<AbstractMesh>;
  94275. /**
  94276. * Gets or sets the orientation for POV movement & rotation
  94277. */
  94278. definedFacingForward: boolean;
  94279. /** @hidden */
  94280. _occlusionQuery: Nullable<WebGLQuery>;
  94281. /** @hidden */
  94282. _renderingGroup: Nullable<RenderingGroup>;
  94283. /**
  94284. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94285. */
  94286. /**
  94287. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94288. */
  94289. visibility: number;
  94290. /** Gets or sets the alpha index used to sort transparent meshes
  94291. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94292. */
  94293. alphaIndex: number;
  94294. /**
  94295. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94296. */
  94297. isVisible: boolean;
  94298. /**
  94299. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94300. */
  94301. isPickable: boolean;
  94302. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94303. showSubMeshesBoundingBox: boolean;
  94304. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94305. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94306. */
  94307. isBlocker: boolean;
  94308. /**
  94309. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94310. */
  94311. enablePointerMoveEvents: boolean;
  94312. /**
  94313. * Specifies the rendering group id for this mesh (0 by default)
  94314. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94315. */
  94316. renderingGroupId: number;
  94317. private _material;
  94318. /** Gets or sets current material */
  94319. material: Nullable<Material>;
  94320. /**
  94321. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94322. * @see http://doc.babylonjs.com/babylon101/shadows
  94323. */
  94324. receiveShadows: boolean;
  94325. /** Defines color to use when rendering outline */
  94326. outlineColor: Color3;
  94327. /** Define width to use when rendering outline */
  94328. outlineWidth: number;
  94329. /** Defines color to use when rendering overlay */
  94330. overlayColor: Color3;
  94331. /** Defines alpha to use when rendering overlay */
  94332. overlayAlpha: number;
  94333. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94334. hasVertexAlpha: boolean;
  94335. /** 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) */
  94336. useVertexColors: boolean;
  94337. /**
  94338. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94339. */
  94340. computeBonesUsingShaders: boolean;
  94341. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94342. numBoneInfluencers: number;
  94343. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94344. applyFog: boolean;
  94345. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94346. useOctreeForRenderingSelection: boolean;
  94347. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94348. useOctreeForPicking: boolean;
  94349. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94350. useOctreeForCollisions: boolean;
  94351. /**
  94352. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94353. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94354. */
  94355. layerMask: number;
  94356. /**
  94357. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94358. */
  94359. alwaysSelectAsActiveMesh: boolean;
  94360. /**
  94361. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94362. */
  94363. doNotSyncBoundingInfo: boolean;
  94364. /**
  94365. * Gets or sets the current action manager
  94366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94367. */
  94368. actionManager: Nullable<AbstractActionManager>;
  94369. private _meshCollisionData;
  94370. /**
  94371. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94373. */
  94374. ellipsoid: Vector3;
  94375. /**
  94376. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94378. */
  94379. ellipsoidOffset: Vector3;
  94380. /**
  94381. * Gets or sets a collision mask used to mask collisions (default is -1).
  94382. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94383. */
  94384. collisionMask: number;
  94385. /**
  94386. * Gets or sets the current collision group mask (-1 by default).
  94387. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94388. */
  94389. collisionGroup: number;
  94390. /**
  94391. * Defines edge width used when edgesRenderer is enabled
  94392. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94393. */
  94394. edgesWidth: number;
  94395. /**
  94396. * Defines edge color used when edgesRenderer is enabled
  94397. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94398. */
  94399. edgesColor: Color4;
  94400. /** @hidden */
  94401. _edgesRenderer: Nullable<IEdgesRenderer>;
  94402. /** @hidden */
  94403. _masterMesh: Nullable<AbstractMesh>;
  94404. /** @hidden */
  94405. _boundingInfo: Nullable<BoundingInfo>;
  94406. /** @hidden */
  94407. _renderId: number;
  94408. /**
  94409. * Gets or sets the list of subMeshes
  94410. * @see http://doc.babylonjs.com/how_to/multi_materials
  94411. */
  94412. subMeshes: SubMesh[];
  94413. /** @hidden */
  94414. _intersectionsInProgress: AbstractMesh[];
  94415. /** @hidden */
  94416. _unIndexed: boolean;
  94417. /** @hidden */
  94418. _lightSources: Light[];
  94419. /** Gets the list of lights affecting that mesh */
  94420. readonly lightSources: Light[];
  94421. /** @hidden */
  94422. readonly _positions: Nullable<Vector3[]>;
  94423. /** @hidden */
  94424. _waitingData: {
  94425. lods: Nullable<any>;
  94426. actions: Nullable<any>;
  94427. freezeWorldMatrix: Nullable<boolean>;
  94428. };
  94429. /** @hidden */
  94430. _bonesTransformMatrices: Nullable<Float32Array>;
  94431. /** @hidden */
  94432. _transformMatrixTexture: Nullable<RawTexture>;
  94433. /**
  94434. * Gets or sets a skeleton to apply skining transformations
  94435. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94436. */
  94437. skeleton: Nullable<Skeleton>;
  94438. /**
  94439. * An event triggered when the mesh is rebuilt.
  94440. */
  94441. onRebuildObservable: Observable<AbstractMesh>;
  94442. /**
  94443. * Creates a new AbstractMesh
  94444. * @param name defines the name of the mesh
  94445. * @param scene defines the hosting scene
  94446. */
  94447. constructor(name: string, scene?: Nullable<Scene>);
  94448. /**
  94449. * Returns the string "AbstractMesh"
  94450. * @returns "AbstractMesh"
  94451. */
  94452. getClassName(): string;
  94453. /**
  94454. * Gets a string representation of the current mesh
  94455. * @param fullDetails defines a boolean indicating if full details must be included
  94456. * @returns a string representation of the current mesh
  94457. */
  94458. toString(fullDetails?: boolean): string;
  94459. /**
  94460. * @hidden
  94461. */
  94462. protected _getEffectiveParent(): Nullable<Node>;
  94463. /** @hidden */
  94464. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94465. /** @hidden */
  94466. _rebuild(): void;
  94467. /** @hidden */
  94468. _resyncLightSources(): void;
  94469. /** @hidden */
  94470. _resyncLighSource(light: Light): void;
  94471. /** @hidden */
  94472. _unBindEffect(): void;
  94473. /** @hidden */
  94474. _removeLightSource(light: Light, dispose: boolean): void;
  94475. private _markSubMeshesAsDirty;
  94476. /** @hidden */
  94477. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94478. /** @hidden */
  94479. _markSubMeshesAsAttributesDirty(): void;
  94480. /** @hidden */
  94481. _markSubMeshesAsMiscDirty(): void;
  94482. /**
  94483. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94484. */
  94485. scaling: Vector3;
  94486. /**
  94487. * Returns true if the mesh is blocked. Implemented by child classes
  94488. */
  94489. readonly isBlocked: boolean;
  94490. /**
  94491. * Returns the mesh itself by default. Implemented by child classes
  94492. * @param camera defines the camera to use to pick the right LOD level
  94493. * @returns the currentAbstractMesh
  94494. */
  94495. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94496. /**
  94497. * Returns 0 by default. Implemented by child classes
  94498. * @returns an integer
  94499. */
  94500. getTotalVertices(): number;
  94501. /**
  94502. * Returns a positive integer : the total number of indices in this mesh geometry.
  94503. * @returns the numner of indices or zero if the mesh has no geometry.
  94504. */
  94505. getTotalIndices(): number;
  94506. /**
  94507. * Returns null by default. Implemented by child classes
  94508. * @returns null
  94509. */
  94510. getIndices(): Nullable<IndicesArray>;
  94511. /**
  94512. * Returns the array of the requested vertex data kind. Implemented by child classes
  94513. * @param kind defines the vertex data kind to use
  94514. * @returns null
  94515. */
  94516. getVerticesData(kind: string): Nullable<FloatArray>;
  94517. /**
  94518. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94519. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94520. * Note that a new underlying VertexBuffer object is created each call.
  94521. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94522. * @param kind defines vertex data kind:
  94523. * * VertexBuffer.PositionKind
  94524. * * VertexBuffer.UVKind
  94525. * * VertexBuffer.UV2Kind
  94526. * * VertexBuffer.UV3Kind
  94527. * * VertexBuffer.UV4Kind
  94528. * * VertexBuffer.UV5Kind
  94529. * * VertexBuffer.UV6Kind
  94530. * * VertexBuffer.ColorKind
  94531. * * VertexBuffer.MatricesIndicesKind
  94532. * * VertexBuffer.MatricesIndicesExtraKind
  94533. * * VertexBuffer.MatricesWeightsKind
  94534. * * VertexBuffer.MatricesWeightsExtraKind
  94535. * @param data defines the data source
  94536. * @param updatable defines if the data must be flagged as updatable (or static)
  94537. * @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
  94538. * @returns the current mesh
  94539. */
  94540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94541. /**
  94542. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94543. * If the mesh has no geometry, it is simply returned as it is.
  94544. * @param kind defines vertex data kind:
  94545. * * VertexBuffer.PositionKind
  94546. * * VertexBuffer.UVKind
  94547. * * VertexBuffer.UV2Kind
  94548. * * VertexBuffer.UV3Kind
  94549. * * VertexBuffer.UV4Kind
  94550. * * VertexBuffer.UV5Kind
  94551. * * VertexBuffer.UV6Kind
  94552. * * VertexBuffer.ColorKind
  94553. * * VertexBuffer.MatricesIndicesKind
  94554. * * VertexBuffer.MatricesIndicesExtraKind
  94555. * * VertexBuffer.MatricesWeightsKind
  94556. * * VertexBuffer.MatricesWeightsExtraKind
  94557. * @param data defines the data source
  94558. * @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
  94559. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94560. * @returns the current mesh
  94561. */
  94562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94563. /**
  94564. * Sets the mesh indices,
  94565. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94566. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94567. * @param totalVertices Defines the total number of vertices
  94568. * @returns the current mesh
  94569. */
  94570. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94571. /**
  94572. * Gets a boolean indicating if specific vertex data is present
  94573. * @param kind defines the vertex data kind to use
  94574. * @returns true is data kind is present
  94575. */
  94576. isVerticesDataPresent(kind: string): boolean;
  94577. /**
  94578. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94579. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94580. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94581. * @returns a BoundingInfo
  94582. */
  94583. getBoundingInfo(): BoundingInfo;
  94584. /**
  94585. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94586. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94587. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94588. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94589. * @returns the current mesh
  94590. */
  94591. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94592. /**
  94593. * Overwrite the current bounding info
  94594. * @param boundingInfo defines the new bounding info
  94595. * @returns the current mesh
  94596. */
  94597. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94598. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94599. readonly useBones: boolean;
  94600. /** @hidden */
  94601. _preActivate(): void;
  94602. /** @hidden */
  94603. _preActivateForIntermediateRendering(renderId: number): void;
  94604. /** @hidden */
  94605. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94606. /** @hidden */
  94607. _postActivate(): void;
  94608. /** @hidden */
  94609. _freeze(): void;
  94610. /** @hidden */
  94611. _unFreeze(): void;
  94612. /**
  94613. * Gets the current world matrix
  94614. * @returns a Matrix
  94615. */
  94616. getWorldMatrix(): Matrix;
  94617. /** @hidden */
  94618. _getWorldMatrixDeterminant(): number;
  94619. /**
  94620. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94621. */
  94622. readonly isAnInstance: boolean;
  94623. /**
  94624. * Gets a boolean indicating if this mesh has instances
  94625. */
  94626. readonly hasInstances: boolean;
  94627. /**
  94628. * Perform relative position change from the point of view of behind the front of the mesh.
  94629. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94630. * Supports definition of mesh facing forward or backward
  94631. * @param amountRight defines the distance on the right axis
  94632. * @param amountUp defines the distance on the up axis
  94633. * @param amountForward defines the distance on the forward axis
  94634. * @returns the current mesh
  94635. */
  94636. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94637. /**
  94638. * Calculate relative position change from the point of view of behind the front of the mesh.
  94639. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94640. * Supports definition of mesh facing forward or backward
  94641. * @param amountRight defines the distance on the right axis
  94642. * @param amountUp defines the distance on the up axis
  94643. * @param amountForward defines the distance on the forward axis
  94644. * @returns the new displacement vector
  94645. */
  94646. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94647. /**
  94648. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94649. * Supports definition of mesh facing forward or backward
  94650. * @param flipBack defines the flip
  94651. * @param twirlClockwise defines the twirl
  94652. * @param tiltRight defines the tilt
  94653. * @returns the current mesh
  94654. */
  94655. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94656. /**
  94657. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94658. * Supports definition of mesh facing forward or backward.
  94659. * @param flipBack defines the flip
  94660. * @param twirlClockwise defines the twirl
  94661. * @param tiltRight defines the tilt
  94662. * @returns the new rotation vector
  94663. */
  94664. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94665. /**
  94666. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94667. * This means the mesh underlying bounding box and sphere are recomputed.
  94668. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94669. * @returns the current mesh
  94670. */
  94671. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94672. /** @hidden */
  94673. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94674. /** @hidden */
  94675. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94676. /** @hidden */
  94677. _updateBoundingInfo(): AbstractMesh;
  94678. /** @hidden */
  94679. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94680. /** @hidden */
  94681. protected _afterComputeWorldMatrix(): void;
  94682. /** @hidden */
  94683. readonly _effectiveMesh: AbstractMesh;
  94684. /**
  94685. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94686. * A mesh is in the frustum if its bounding box intersects the frustum
  94687. * @param frustumPlanes defines the frustum to test
  94688. * @returns true if the mesh is in the frustum planes
  94689. */
  94690. isInFrustum(frustumPlanes: Plane[]): boolean;
  94691. /**
  94692. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94693. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94694. * @param frustumPlanes defines the frustum to test
  94695. * @returns true if the mesh is completely in the frustum planes
  94696. */
  94697. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94698. /**
  94699. * True if the mesh intersects another mesh or a SolidParticle object
  94700. * @param mesh defines a target mesh or SolidParticle to test
  94701. * @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)
  94702. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94703. * @returns true if there is an intersection
  94704. */
  94705. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94706. /**
  94707. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94708. * @param point defines the point to test
  94709. * @returns true if there is an intersection
  94710. */
  94711. intersectsPoint(point: Vector3): boolean;
  94712. /**
  94713. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94714. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94715. */
  94716. checkCollisions: boolean;
  94717. /**
  94718. * Gets Collider object used to compute collisions (not physics)
  94719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94720. */
  94721. readonly collider: Nullable<Collider>;
  94722. /**
  94723. * Move the mesh using collision engine
  94724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94725. * @param displacement defines the requested displacement vector
  94726. * @returns the current mesh
  94727. */
  94728. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94729. private _onCollisionPositionChange;
  94730. /** @hidden */
  94731. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94732. /** @hidden */
  94733. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94734. /** @hidden */
  94735. _checkCollision(collider: Collider): AbstractMesh;
  94736. /** @hidden */
  94737. _generatePointsArray(): boolean;
  94738. /**
  94739. * Checks if the passed Ray intersects with the mesh
  94740. * @param ray defines the ray to use
  94741. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94742. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94743. * @returns the picking info
  94744. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94745. */
  94746. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94747. /**
  94748. * Clones the current mesh
  94749. * @param name defines the mesh name
  94750. * @param newParent defines the new mesh parent
  94751. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94752. * @returns the new mesh
  94753. */
  94754. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94755. /**
  94756. * Disposes all the submeshes of the current meshnp
  94757. * @returns the current mesh
  94758. */
  94759. releaseSubMeshes(): AbstractMesh;
  94760. /**
  94761. * Releases resources associated with this abstract mesh.
  94762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94764. */
  94765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94766. /**
  94767. * Adds the passed mesh as a child to the current mesh
  94768. * @param mesh defines the child mesh
  94769. * @returns the current mesh
  94770. */
  94771. addChild(mesh: AbstractMesh): AbstractMesh;
  94772. /**
  94773. * Removes the passed mesh from the current mesh children list
  94774. * @param mesh defines the child mesh
  94775. * @returns the current mesh
  94776. */
  94777. removeChild(mesh: AbstractMesh): AbstractMesh;
  94778. /** @hidden */
  94779. private _initFacetData;
  94780. /**
  94781. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94782. * This method can be called within the render loop.
  94783. * 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
  94784. * @returns the current mesh
  94785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94786. */
  94787. updateFacetData(): AbstractMesh;
  94788. /**
  94789. * Returns the facetLocalNormals array.
  94790. * The normals are expressed in the mesh local spac
  94791. * @returns an array of Vector3
  94792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94793. */
  94794. getFacetLocalNormals(): Vector3[];
  94795. /**
  94796. * Returns the facetLocalPositions array.
  94797. * The facet positions are expressed in the mesh local space
  94798. * @returns an array of Vector3
  94799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94800. */
  94801. getFacetLocalPositions(): Vector3[];
  94802. /**
  94803. * Returns the facetLocalPartioning array
  94804. * @returns an array of array of numbers
  94805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94806. */
  94807. getFacetLocalPartitioning(): number[][];
  94808. /**
  94809. * Returns the i-th facet position in the world system.
  94810. * This method allocates a new Vector3 per call
  94811. * @param i defines the facet index
  94812. * @returns a new Vector3
  94813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94814. */
  94815. getFacetPosition(i: number): Vector3;
  94816. /**
  94817. * Sets the reference Vector3 with the i-th facet position in the world system
  94818. * @param i defines the facet index
  94819. * @param ref defines the target vector
  94820. * @returns the current mesh
  94821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94822. */
  94823. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94824. /**
  94825. * Returns the i-th facet normal in the world system.
  94826. * This method allocates a new Vector3 per call
  94827. * @param i defines the facet index
  94828. * @returns a new Vector3
  94829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94830. */
  94831. getFacetNormal(i: number): Vector3;
  94832. /**
  94833. * Sets the reference Vector3 with the i-th facet normal in the world system
  94834. * @param i defines the facet index
  94835. * @param ref defines the target vector
  94836. * @returns the current mesh
  94837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94838. */
  94839. getFacetNormalToRef(i: number, ref: Vector3): this;
  94840. /**
  94841. * 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)
  94842. * @param x defines x coordinate
  94843. * @param y defines y coordinate
  94844. * @param z defines z coordinate
  94845. * @returns the array of facet indexes
  94846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94847. */
  94848. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94849. /**
  94850. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94851. * @param projected sets as the (x,y,z) world projection on the facet
  94852. * @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
  94853. * @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
  94854. * @param x defines x coordinate
  94855. * @param y defines y coordinate
  94856. * @param z defines z coordinate
  94857. * @returns the face index if found (or null instead)
  94858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94859. */
  94860. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94861. /**
  94862. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94863. * @param projected sets as the (x,y,z) local projection on the facet
  94864. * @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
  94865. * @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
  94866. * @param x defines x coordinate
  94867. * @param y defines y coordinate
  94868. * @param z defines z coordinate
  94869. * @returns the face index if found (or null instead)
  94870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94871. */
  94872. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94873. /**
  94874. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94875. * @returns the parameters
  94876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94877. */
  94878. getFacetDataParameters(): any;
  94879. /**
  94880. * Disables the feature FacetData and frees the related memory
  94881. * @returns the current mesh
  94882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94883. */
  94884. disableFacetData(): AbstractMesh;
  94885. /**
  94886. * Updates the AbstractMesh indices array
  94887. * @param indices defines the data source
  94888. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94889. * @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)
  94890. * @returns the current mesh
  94891. */
  94892. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94893. /**
  94894. * Creates new normals data for the mesh
  94895. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94896. * @returns the current mesh
  94897. */
  94898. createNormals(updatable: boolean): AbstractMesh;
  94899. /**
  94900. * Align the mesh with a normal
  94901. * @param normal defines the normal to use
  94902. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94903. * @returns the current mesh
  94904. */
  94905. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94906. /** @hidden */
  94907. _checkOcclusionQuery(): boolean;
  94908. /**
  94909. * Disables the mesh edge rendering mode
  94910. * @returns the currentAbstractMesh
  94911. */
  94912. disableEdgesRendering(): AbstractMesh;
  94913. /**
  94914. * Enables the edge rendering mode on the mesh.
  94915. * This mode makes the mesh edges visible
  94916. * @param epsilon defines the maximal distance between two angles to detect a face
  94917. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94918. * @returns the currentAbstractMesh
  94919. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94920. */
  94921. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94922. }
  94923. }
  94924. declare module BABYLON {
  94925. /**
  94926. * Interface used to define ActionEvent
  94927. */
  94928. export interface IActionEvent {
  94929. /** The mesh or sprite that triggered the action */
  94930. source: any;
  94931. /** The X mouse cursor position at the time of the event */
  94932. pointerX: number;
  94933. /** The Y mouse cursor position at the time of the event */
  94934. pointerY: number;
  94935. /** The mesh that is currently pointed at (can be null) */
  94936. meshUnderPointer: Nullable<AbstractMesh>;
  94937. /** the original (browser) event that triggered the ActionEvent */
  94938. sourceEvent?: any;
  94939. /** additional data for the event */
  94940. additionalData?: any;
  94941. }
  94942. /**
  94943. * ActionEvent is the event being sent when an action is triggered.
  94944. */
  94945. export class ActionEvent implements IActionEvent {
  94946. /** The mesh or sprite that triggered the action */
  94947. source: any;
  94948. /** The X mouse cursor position at the time of the event */
  94949. pointerX: number;
  94950. /** The Y mouse cursor position at the time of the event */
  94951. pointerY: number;
  94952. /** The mesh that is currently pointed at (can be null) */
  94953. meshUnderPointer: Nullable<AbstractMesh>;
  94954. /** the original (browser) event that triggered the ActionEvent */
  94955. sourceEvent?: any;
  94956. /** additional data for the event */
  94957. additionalData?: any;
  94958. /**
  94959. * Creates a new ActionEvent
  94960. * @param source The mesh or sprite that triggered the action
  94961. * @param pointerX The X mouse cursor position at the time of the event
  94962. * @param pointerY The Y mouse cursor position at the time of the event
  94963. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94964. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94965. * @param additionalData additional data for the event
  94966. */
  94967. constructor(
  94968. /** The mesh or sprite that triggered the action */
  94969. source: any,
  94970. /** The X mouse cursor position at the time of the event */
  94971. pointerX: number,
  94972. /** The Y mouse cursor position at the time of the event */
  94973. pointerY: number,
  94974. /** The mesh that is currently pointed at (can be null) */
  94975. meshUnderPointer: Nullable<AbstractMesh>,
  94976. /** the original (browser) event that triggered the ActionEvent */
  94977. sourceEvent?: any,
  94978. /** additional data for the event */
  94979. additionalData?: any);
  94980. /**
  94981. * Helper function to auto-create an ActionEvent from a source mesh.
  94982. * @param source The source mesh that triggered the event
  94983. * @param evt The original (browser) event
  94984. * @param additionalData additional data for the event
  94985. * @returns the new ActionEvent
  94986. */
  94987. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94988. /**
  94989. * Helper function to auto-create an ActionEvent from a source sprite
  94990. * @param source The source sprite that triggered the event
  94991. * @param scene Scene associated with the sprite
  94992. * @param evt The original (browser) event
  94993. * @param additionalData additional data for the event
  94994. * @returns the new ActionEvent
  94995. */
  94996. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94997. /**
  94998. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94999. * @param scene the scene where the event occurred
  95000. * @param evt The original (browser) event
  95001. * @returns the new ActionEvent
  95002. */
  95003. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95004. /**
  95005. * Helper function to auto-create an ActionEvent from a primitive
  95006. * @param prim defines the target primitive
  95007. * @param pointerPos defines the pointer position
  95008. * @param evt The original (browser) event
  95009. * @param additionalData additional data for the event
  95010. * @returns the new ActionEvent
  95011. */
  95012. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95013. }
  95014. }
  95015. declare module BABYLON {
  95016. /**
  95017. * Abstract class used to decouple action Manager from scene and meshes.
  95018. * Do not instantiate.
  95019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95020. */
  95021. export abstract class AbstractActionManager implements IDisposable {
  95022. /** Gets the list of active triggers */
  95023. static Triggers: {
  95024. [key: string]: number;
  95025. };
  95026. /** Gets the cursor to use when hovering items */
  95027. hoverCursor: string;
  95028. /** Gets the list of actions */
  95029. actions: IAction[];
  95030. /**
  95031. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95032. */
  95033. isRecursive: boolean;
  95034. /**
  95035. * Releases all associated resources
  95036. */
  95037. abstract dispose(): void;
  95038. /**
  95039. * Does this action manager has pointer triggers
  95040. */
  95041. abstract readonly hasPointerTriggers: boolean;
  95042. /**
  95043. * Does this action manager has pick triggers
  95044. */
  95045. abstract readonly hasPickTriggers: boolean;
  95046. /**
  95047. * Process a specific trigger
  95048. * @param trigger defines the trigger to process
  95049. * @param evt defines the event details to be processed
  95050. */
  95051. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95052. /**
  95053. * Does this action manager handles actions of any of the given triggers
  95054. * @param triggers defines the triggers to be tested
  95055. * @return a boolean indicating whether one (or more) of the triggers is handled
  95056. */
  95057. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95058. /**
  95059. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95060. * speed.
  95061. * @param triggerA defines the trigger to be tested
  95062. * @param triggerB defines the trigger to be tested
  95063. * @return a boolean indicating whether one (or more) of the triggers is handled
  95064. */
  95065. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95066. /**
  95067. * Does this action manager handles actions of a given trigger
  95068. * @param trigger defines the trigger to be tested
  95069. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95070. * @return whether the trigger is handled
  95071. */
  95072. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95073. /**
  95074. * Serialize this manager to a JSON object
  95075. * @param name defines the property name to store this manager
  95076. * @returns a JSON representation of this manager
  95077. */
  95078. abstract serialize(name: string): any;
  95079. /**
  95080. * Registers an action to this action manager
  95081. * @param action defines the action to be registered
  95082. * @return the action amended (prepared) after registration
  95083. */
  95084. abstract registerAction(action: IAction): Nullable<IAction>;
  95085. /**
  95086. * Unregisters an action to this action manager
  95087. * @param action defines the action to be unregistered
  95088. * @return a boolean indicating whether the action has been unregistered
  95089. */
  95090. abstract unregisterAction(action: IAction): Boolean;
  95091. /**
  95092. * Does exist one action manager with at least one trigger
  95093. **/
  95094. static readonly HasTriggers: boolean;
  95095. /**
  95096. * Does exist one action manager with at least one pick trigger
  95097. **/
  95098. static readonly HasPickTriggers: boolean;
  95099. /**
  95100. * Does exist one action manager that handles actions of a given trigger
  95101. * @param trigger defines the trigger to be tested
  95102. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95103. **/
  95104. static HasSpecificTrigger(trigger: number): boolean;
  95105. }
  95106. }
  95107. declare module BABYLON {
  95108. /**
  95109. * Defines how a node can be built from a string name.
  95110. */
  95111. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95112. /**
  95113. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95114. */
  95115. export class Node implements IBehaviorAware<Node> {
  95116. /** @hidden */
  95117. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95118. private static _NodeConstructors;
  95119. /**
  95120. * Add a new node constructor
  95121. * @param type defines the type name of the node to construct
  95122. * @param constructorFunc defines the constructor function
  95123. */
  95124. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95125. /**
  95126. * Returns a node constructor based on type name
  95127. * @param type defines the type name
  95128. * @param name defines the new node name
  95129. * @param scene defines the hosting scene
  95130. * @param options defines optional options to transmit to constructors
  95131. * @returns the new constructor or null
  95132. */
  95133. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95134. /**
  95135. * Gets or sets the name of the node
  95136. */
  95137. name: string;
  95138. /**
  95139. * Gets or sets the id of the node
  95140. */
  95141. id: string;
  95142. /**
  95143. * Gets or sets the unique id of the node
  95144. */
  95145. uniqueId: number;
  95146. /**
  95147. * Gets or sets a string used to store user defined state for the node
  95148. */
  95149. state: string;
  95150. /**
  95151. * Gets or sets an object used to store user defined information for the node
  95152. */
  95153. metadata: any;
  95154. /**
  95155. * For internal use only. Please do not use.
  95156. */
  95157. reservedDataStore: any;
  95158. /**
  95159. * List of inspectable custom properties (used by the Inspector)
  95160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95161. */
  95162. inspectableCustomProperties: IInspectable[];
  95163. private _doNotSerialize;
  95164. /**
  95165. * Gets or sets a boolean used to define if the node must be serialized
  95166. */
  95167. doNotSerialize: boolean;
  95168. /** @hidden */
  95169. _isDisposed: boolean;
  95170. /**
  95171. * Gets a list of Animations associated with the node
  95172. */
  95173. animations: Animation[];
  95174. protected _ranges: {
  95175. [name: string]: Nullable<AnimationRange>;
  95176. };
  95177. /**
  95178. * Callback raised when the node is ready to be used
  95179. */
  95180. onReady: Nullable<(node: Node) => void>;
  95181. private _isEnabled;
  95182. private _isParentEnabled;
  95183. private _isReady;
  95184. /** @hidden */
  95185. _currentRenderId: number;
  95186. private _parentUpdateId;
  95187. /** @hidden */
  95188. _childUpdateId: number;
  95189. /** @hidden */
  95190. _waitingParentId: Nullable<string>;
  95191. /** @hidden */
  95192. _scene: Scene;
  95193. /** @hidden */
  95194. _cache: any;
  95195. private _parentNode;
  95196. private _children;
  95197. /** @hidden */
  95198. _worldMatrix: Matrix;
  95199. /** @hidden */
  95200. _worldMatrixDeterminant: number;
  95201. /** @hidden */
  95202. _worldMatrixDeterminantIsDirty: boolean;
  95203. /** @hidden */
  95204. private _sceneRootNodesIndex;
  95205. /**
  95206. * Gets a boolean indicating if the node has been disposed
  95207. * @returns true if the node was disposed
  95208. */
  95209. isDisposed(): boolean;
  95210. /**
  95211. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95212. * @see https://doc.babylonjs.com/how_to/parenting
  95213. */
  95214. parent: Nullable<Node>;
  95215. /** @hidden */
  95216. _addToSceneRootNodes(): void;
  95217. /** @hidden */
  95218. _removeFromSceneRootNodes(): void;
  95219. private _animationPropertiesOverride;
  95220. /**
  95221. * Gets or sets the animation properties override
  95222. */
  95223. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95224. /**
  95225. * Gets a string idenfifying the name of the class
  95226. * @returns "Node" string
  95227. */
  95228. getClassName(): string;
  95229. /** @hidden */
  95230. readonly _isNode: boolean;
  95231. /**
  95232. * An event triggered when the mesh is disposed
  95233. */
  95234. onDisposeObservable: Observable<Node>;
  95235. private _onDisposeObserver;
  95236. /**
  95237. * Sets a callback that will be raised when the node will be disposed
  95238. */
  95239. onDispose: () => void;
  95240. /**
  95241. * Creates a new Node
  95242. * @param name the name and id to be given to this node
  95243. * @param scene the scene this node will be added to
  95244. */
  95245. constructor(name: string, scene?: Nullable<Scene>);
  95246. /**
  95247. * Gets the scene of the node
  95248. * @returns a scene
  95249. */
  95250. getScene(): Scene;
  95251. /**
  95252. * Gets the engine of the node
  95253. * @returns a Engine
  95254. */
  95255. getEngine(): Engine;
  95256. private _behaviors;
  95257. /**
  95258. * Attach a behavior to the node
  95259. * @see http://doc.babylonjs.com/features/behaviour
  95260. * @param behavior defines the behavior to attach
  95261. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95262. * @returns the current Node
  95263. */
  95264. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95265. /**
  95266. * Remove an attached behavior
  95267. * @see http://doc.babylonjs.com/features/behaviour
  95268. * @param behavior defines the behavior to attach
  95269. * @returns the current Node
  95270. */
  95271. removeBehavior(behavior: Behavior<Node>): Node;
  95272. /**
  95273. * Gets the list of attached behaviors
  95274. * @see http://doc.babylonjs.com/features/behaviour
  95275. */
  95276. readonly behaviors: Behavior<Node>[];
  95277. /**
  95278. * Gets an attached behavior by name
  95279. * @param name defines the name of the behavior to look for
  95280. * @see http://doc.babylonjs.com/features/behaviour
  95281. * @returns null if behavior was not found else the requested behavior
  95282. */
  95283. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95284. /**
  95285. * Returns the latest update of the World matrix
  95286. * @returns a Matrix
  95287. */
  95288. getWorldMatrix(): Matrix;
  95289. /** @hidden */
  95290. _getWorldMatrixDeterminant(): number;
  95291. /**
  95292. * Returns directly the latest state of the mesh World matrix.
  95293. * A Matrix is returned.
  95294. */
  95295. readonly worldMatrixFromCache: Matrix;
  95296. /** @hidden */
  95297. _initCache(): void;
  95298. /** @hidden */
  95299. updateCache(force?: boolean): void;
  95300. /** @hidden */
  95301. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95302. /** @hidden */
  95303. _updateCache(ignoreParentClass?: boolean): void;
  95304. /** @hidden */
  95305. _isSynchronized(): boolean;
  95306. /** @hidden */
  95307. _markSyncedWithParent(): void;
  95308. /** @hidden */
  95309. isSynchronizedWithParent(): boolean;
  95310. /** @hidden */
  95311. isSynchronized(): boolean;
  95312. /**
  95313. * Is this node ready to be used/rendered
  95314. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95315. * @return true if the node is ready
  95316. */
  95317. isReady(completeCheck?: boolean): boolean;
  95318. /**
  95319. * Is this node enabled?
  95320. * 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
  95321. * @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
  95322. * @return whether this node (and its parent) is enabled
  95323. */
  95324. isEnabled(checkAncestors?: boolean): boolean;
  95325. /** @hidden */
  95326. protected _syncParentEnabledState(): void;
  95327. /**
  95328. * Set the enabled state of this node
  95329. * @param value defines the new enabled state
  95330. */
  95331. setEnabled(value: boolean): void;
  95332. /**
  95333. * Is this node a descendant of the given node?
  95334. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95335. * @param ancestor defines the parent node to inspect
  95336. * @returns a boolean indicating if this node is a descendant of the given node
  95337. */
  95338. isDescendantOf(ancestor: Node): boolean;
  95339. /** @hidden */
  95340. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95341. /**
  95342. * Will return all nodes that have this node as ascendant
  95343. * @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
  95344. * @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
  95345. * @return all children nodes of all types
  95346. */
  95347. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95348. /**
  95349. * Get all child-meshes of this node
  95350. * @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)
  95351. * @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
  95352. * @returns an array of AbstractMesh
  95353. */
  95354. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95355. /**
  95356. * Get all direct children of this node
  95357. * @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
  95358. * @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)
  95359. * @returns an array of Node
  95360. */
  95361. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95362. /** @hidden */
  95363. _setReady(state: boolean): void;
  95364. /**
  95365. * Get an animation by name
  95366. * @param name defines the name of the animation to look for
  95367. * @returns null if not found else the requested animation
  95368. */
  95369. getAnimationByName(name: string): Nullable<Animation>;
  95370. /**
  95371. * Creates an animation range for this node
  95372. * @param name defines the name of the range
  95373. * @param from defines the starting key
  95374. * @param to defines the end key
  95375. */
  95376. createAnimationRange(name: string, from: number, to: number): void;
  95377. /**
  95378. * Delete a specific animation range
  95379. * @param name defines the name of the range to delete
  95380. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95381. */
  95382. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95383. /**
  95384. * Get an animation range by name
  95385. * @param name defines the name of the animation range to look for
  95386. * @returns null if not found else the requested animation range
  95387. */
  95388. getAnimationRange(name: string): Nullable<AnimationRange>;
  95389. /**
  95390. * Gets the list of all animation ranges defined on this node
  95391. * @returns an array
  95392. */
  95393. getAnimationRanges(): Nullable<AnimationRange>[];
  95394. /**
  95395. * Will start the animation sequence
  95396. * @param name defines the range frames for animation sequence
  95397. * @param loop defines if the animation should loop (false by default)
  95398. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95399. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95400. * @returns the object created for this animation. If range does not exist, it will return null
  95401. */
  95402. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95403. /**
  95404. * Serialize animation ranges into a JSON compatible object
  95405. * @returns serialization object
  95406. */
  95407. serializeAnimationRanges(): any;
  95408. /**
  95409. * Computes the world matrix of the node
  95410. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95411. * @returns the world matrix
  95412. */
  95413. computeWorldMatrix(force?: boolean): Matrix;
  95414. /**
  95415. * Releases resources associated with this node.
  95416. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95417. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95418. */
  95419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95420. /**
  95421. * Parse animation range data from a serialization object and store them into a given node
  95422. * @param node defines where to store the animation ranges
  95423. * @param parsedNode defines the serialization object to read data from
  95424. * @param scene defines the hosting scene
  95425. */
  95426. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95427. /**
  95428. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95429. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95430. * @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
  95431. * @returns the new bounding vectors
  95432. */
  95433. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95434. min: Vector3;
  95435. max: Vector3;
  95436. };
  95437. }
  95438. }
  95439. declare module BABYLON {
  95440. /**
  95441. * @hidden
  95442. */
  95443. export class _IAnimationState {
  95444. key: number;
  95445. repeatCount: number;
  95446. workValue?: any;
  95447. loopMode?: number;
  95448. offsetValue?: any;
  95449. highLimitValue?: any;
  95450. }
  95451. /**
  95452. * Class used to store any kind of animation
  95453. */
  95454. export class Animation {
  95455. /**Name of the animation */
  95456. name: string;
  95457. /**Property to animate */
  95458. targetProperty: string;
  95459. /**The frames per second of the animation */
  95460. framePerSecond: number;
  95461. /**The data type of the animation */
  95462. dataType: number;
  95463. /**The loop mode of the animation */
  95464. loopMode?: number | undefined;
  95465. /**Specifies if blending should be enabled */
  95466. enableBlending?: boolean | undefined;
  95467. /**
  95468. * Use matrix interpolation instead of using direct key value when animating matrices
  95469. */
  95470. static AllowMatricesInterpolation: boolean;
  95471. /**
  95472. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95473. */
  95474. static AllowMatrixDecomposeForInterpolation: boolean;
  95475. /**
  95476. * Stores the key frames of the animation
  95477. */
  95478. private _keys;
  95479. /**
  95480. * Stores the easing function of the animation
  95481. */
  95482. private _easingFunction;
  95483. /**
  95484. * @hidden Internal use only
  95485. */
  95486. _runtimeAnimations: RuntimeAnimation[];
  95487. /**
  95488. * The set of event that will be linked to this animation
  95489. */
  95490. private _events;
  95491. /**
  95492. * Stores an array of target property paths
  95493. */
  95494. targetPropertyPath: string[];
  95495. /**
  95496. * Stores the blending speed of the animation
  95497. */
  95498. blendingSpeed: number;
  95499. /**
  95500. * Stores the animation ranges for the animation
  95501. */
  95502. private _ranges;
  95503. /**
  95504. * @hidden Internal use
  95505. */
  95506. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95507. /**
  95508. * Sets up an animation
  95509. * @param property The property to animate
  95510. * @param animationType The animation type to apply
  95511. * @param framePerSecond The frames per second of the animation
  95512. * @param easingFunction The easing function used in the animation
  95513. * @returns The created animation
  95514. */
  95515. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95516. /**
  95517. * Create and start an animation on a node
  95518. * @param name defines the name of the global animation that will be run on all nodes
  95519. * @param node defines the root node where the animation will take place
  95520. * @param targetProperty defines property to animate
  95521. * @param framePerSecond defines the number of frame per second yo use
  95522. * @param totalFrame defines the number of frames in total
  95523. * @param from defines the initial value
  95524. * @param to defines the final value
  95525. * @param loopMode defines which loop mode you want to use (off by default)
  95526. * @param easingFunction defines the easing function to use (linear by default)
  95527. * @param onAnimationEnd defines the callback to call when animation end
  95528. * @returns the animatable created for this animation
  95529. */
  95530. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95531. /**
  95532. * Create and start an animation on a node and its descendants
  95533. * @param name defines the name of the global animation that will be run on all nodes
  95534. * @param node defines the root node where the animation will take place
  95535. * @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
  95536. * @param targetProperty defines property to animate
  95537. * @param framePerSecond defines the number of frame per second to use
  95538. * @param totalFrame defines the number of frames in total
  95539. * @param from defines the initial value
  95540. * @param to defines the final value
  95541. * @param loopMode defines which loop mode you want to use (off by default)
  95542. * @param easingFunction defines the easing function to use (linear by default)
  95543. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95544. * @returns the list of animatables created for all nodes
  95545. * @example https://www.babylonjs-playground.com/#MH0VLI
  95546. */
  95547. 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[]>;
  95548. /**
  95549. * Creates a new animation, merges it with the existing animations and starts it
  95550. * @param name Name of the animation
  95551. * @param node Node which contains the scene that begins the animations
  95552. * @param targetProperty Specifies which property to animate
  95553. * @param framePerSecond The frames per second of the animation
  95554. * @param totalFrame The total number of frames
  95555. * @param from The frame at the beginning of the animation
  95556. * @param to The frame at the end of the animation
  95557. * @param loopMode Specifies the loop mode of the animation
  95558. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95559. * @param onAnimationEnd Callback to run once the animation is complete
  95560. * @returns Nullable animation
  95561. */
  95562. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95563. /**
  95564. * Transition property of an host to the target Value
  95565. * @param property The property to transition
  95566. * @param targetValue The target Value of the property
  95567. * @param host The object where the property to animate belongs
  95568. * @param scene Scene used to run the animation
  95569. * @param frameRate Framerate (in frame/s) to use
  95570. * @param transition The transition type we want to use
  95571. * @param duration The duration of the animation, in milliseconds
  95572. * @param onAnimationEnd Callback trigger at the end of the animation
  95573. * @returns Nullable animation
  95574. */
  95575. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95576. /**
  95577. * Return the array of runtime animations currently using this animation
  95578. */
  95579. readonly runtimeAnimations: RuntimeAnimation[];
  95580. /**
  95581. * Specifies if any of the runtime animations are currently running
  95582. */
  95583. readonly hasRunningRuntimeAnimations: boolean;
  95584. /**
  95585. * Initializes the animation
  95586. * @param name Name of the animation
  95587. * @param targetProperty Property to animate
  95588. * @param framePerSecond The frames per second of the animation
  95589. * @param dataType The data type of the animation
  95590. * @param loopMode The loop mode of the animation
  95591. * @param enableBlending Specifies if blending should be enabled
  95592. */
  95593. constructor(
  95594. /**Name of the animation */
  95595. name: string,
  95596. /**Property to animate */
  95597. targetProperty: string,
  95598. /**The frames per second of the animation */
  95599. framePerSecond: number,
  95600. /**The data type of the animation */
  95601. dataType: number,
  95602. /**The loop mode of the animation */
  95603. loopMode?: number | undefined,
  95604. /**Specifies if blending should be enabled */
  95605. enableBlending?: boolean | undefined);
  95606. /**
  95607. * Converts the animation to a string
  95608. * @param fullDetails support for multiple levels of logging within scene loading
  95609. * @returns String form of the animation
  95610. */
  95611. toString(fullDetails?: boolean): string;
  95612. /**
  95613. * Add an event to this animation
  95614. * @param event Event to add
  95615. */
  95616. addEvent(event: AnimationEvent): void;
  95617. /**
  95618. * Remove all events found at the given frame
  95619. * @param frame The frame to remove events from
  95620. */
  95621. removeEvents(frame: number): void;
  95622. /**
  95623. * Retrieves all the events from the animation
  95624. * @returns Events from the animation
  95625. */
  95626. getEvents(): AnimationEvent[];
  95627. /**
  95628. * Creates an animation range
  95629. * @param name Name of the animation range
  95630. * @param from Starting frame of the animation range
  95631. * @param to Ending frame of the animation
  95632. */
  95633. createRange(name: string, from: number, to: number): void;
  95634. /**
  95635. * Deletes an animation range by name
  95636. * @param name Name of the animation range to delete
  95637. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95638. */
  95639. deleteRange(name: string, deleteFrames?: boolean): void;
  95640. /**
  95641. * Gets the animation range by name, or null if not defined
  95642. * @param name Name of the animation range
  95643. * @returns Nullable animation range
  95644. */
  95645. getRange(name: string): Nullable<AnimationRange>;
  95646. /**
  95647. * Gets the key frames from the animation
  95648. * @returns The key frames of the animation
  95649. */
  95650. getKeys(): Array<IAnimationKey>;
  95651. /**
  95652. * Gets the highest frame rate of the animation
  95653. * @returns Highest frame rate of the animation
  95654. */
  95655. getHighestFrame(): number;
  95656. /**
  95657. * Gets the easing function of the animation
  95658. * @returns Easing function of the animation
  95659. */
  95660. getEasingFunction(): IEasingFunction;
  95661. /**
  95662. * Sets the easing function of the animation
  95663. * @param easingFunction A custom mathematical formula for animation
  95664. */
  95665. setEasingFunction(easingFunction: EasingFunction): void;
  95666. /**
  95667. * Interpolates a scalar linearly
  95668. * @param startValue Start value of the animation curve
  95669. * @param endValue End value of the animation curve
  95670. * @param gradient Scalar amount to interpolate
  95671. * @returns Interpolated scalar value
  95672. */
  95673. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95674. /**
  95675. * Interpolates a scalar cubically
  95676. * @param startValue Start value of the animation curve
  95677. * @param outTangent End tangent of the animation
  95678. * @param endValue End value of the animation curve
  95679. * @param inTangent Start tangent of the animation curve
  95680. * @param gradient Scalar amount to interpolate
  95681. * @returns Interpolated scalar value
  95682. */
  95683. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95684. /**
  95685. * Interpolates a quaternion using a spherical linear interpolation
  95686. * @param startValue Start value of the animation curve
  95687. * @param endValue End value of the animation curve
  95688. * @param gradient Scalar amount to interpolate
  95689. * @returns Interpolated quaternion value
  95690. */
  95691. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95692. /**
  95693. * Interpolates a quaternion cubically
  95694. * @param startValue Start value of the animation curve
  95695. * @param outTangent End tangent of the animation curve
  95696. * @param endValue End value of the animation curve
  95697. * @param inTangent Start tangent of the animation curve
  95698. * @param gradient Scalar amount to interpolate
  95699. * @returns Interpolated quaternion value
  95700. */
  95701. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95702. /**
  95703. * Interpolates a Vector3 linearl
  95704. * @param startValue Start value of the animation curve
  95705. * @param endValue End value of the animation curve
  95706. * @param gradient Scalar amount to interpolate
  95707. * @returns Interpolated scalar value
  95708. */
  95709. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95710. /**
  95711. * Interpolates a Vector3 cubically
  95712. * @param startValue Start value of the animation curve
  95713. * @param outTangent End tangent of the animation
  95714. * @param endValue End value of the animation curve
  95715. * @param inTangent Start tangent of the animation curve
  95716. * @param gradient Scalar amount to interpolate
  95717. * @returns InterpolatedVector3 value
  95718. */
  95719. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95720. /**
  95721. * Interpolates a Vector2 linearly
  95722. * @param startValue Start value of the animation curve
  95723. * @param endValue End value of the animation curve
  95724. * @param gradient Scalar amount to interpolate
  95725. * @returns Interpolated Vector2 value
  95726. */
  95727. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95728. /**
  95729. * Interpolates a Vector2 cubically
  95730. * @param startValue Start value of the animation curve
  95731. * @param outTangent End tangent of the animation
  95732. * @param endValue End value of the animation curve
  95733. * @param inTangent Start tangent of the animation curve
  95734. * @param gradient Scalar amount to interpolate
  95735. * @returns Interpolated Vector2 value
  95736. */
  95737. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95738. /**
  95739. * Interpolates a size linearly
  95740. * @param startValue Start value of the animation curve
  95741. * @param endValue End value of the animation curve
  95742. * @param gradient Scalar amount to interpolate
  95743. * @returns Interpolated Size value
  95744. */
  95745. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95746. /**
  95747. * Interpolates a Color3 linearly
  95748. * @param startValue Start value of the animation curve
  95749. * @param endValue End value of the animation curve
  95750. * @param gradient Scalar amount to interpolate
  95751. * @returns Interpolated Color3 value
  95752. */
  95753. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95754. /**
  95755. * Interpolates a Color4 linearly
  95756. * @param startValue Start value of the animation curve
  95757. * @param endValue End value of the animation curve
  95758. * @param gradient Scalar amount to interpolate
  95759. * @returns Interpolated Color3 value
  95760. */
  95761. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95762. /**
  95763. * @hidden Internal use only
  95764. */
  95765. _getKeyValue(value: any): any;
  95766. /**
  95767. * @hidden Internal use only
  95768. */
  95769. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95770. /**
  95771. * Defines the function to use to interpolate matrices
  95772. * @param startValue defines the start matrix
  95773. * @param endValue defines the end matrix
  95774. * @param gradient defines the gradient between both matrices
  95775. * @param result defines an optional target matrix where to store the interpolation
  95776. * @returns the interpolated matrix
  95777. */
  95778. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95779. /**
  95780. * Makes a copy of the animation
  95781. * @returns Cloned animation
  95782. */
  95783. clone(): Animation;
  95784. /**
  95785. * Sets the key frames of the animation
  95786. * @param values The animation key frames to set
  95787. */
  95788. setKeys(values: Array<IAnimationKey>): void;
  95789. /**
  95790. * Serializes the animation to an object
  95791. * @returns Serialized object
  95792. */
  95793. serialize(): any;
  95794. /**
  95795. * Float animation type
  95796. */
  95797. static readonly ANIMATIONTYPE_FLOAT: number;
  95798. /**
  95799. * Vector3 animation type
  95800. */
  95801. static readonly ANIMATIONTYPE_VECTOR3: number;
  95802. /**
  95803. * Quaternion animation type
  95804. */
  95805. static readonly ANIMATIONTYPE_QUATERNION: number;
  95806. /**
  95807. * Matrix animation type
  95808. */
  95809. static readonly ANIMATIONTYPE_MATRIX: number;
  95810. /**
  95811. * Color3 animation type
  95812. */
  95813. static readonly ANIMATIONTYPE_COLOR3: number;
  95814. /**
  95815. * Color3 animation type
  95816. */
  95817. static readonly ANIMATIONTYPE_COLOR4: number;
  95818. /**
  95819. * Vector2 animation type
  95820. */
  95821. static readonly ANIMATIONTYPE_VECTOR2: number;
  95822. /**
  95823. * Size animation type
  95824. */
  95825. static readonly ANIMATIONTYPE_SIZE: number;
  95826. /**
  95827. * Relative Loop Mode
  95828. */
  95829. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95830. /**
  95831. * Cycle Loop Mode
  95832. */
  95833. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95834. /**
  95835. * Constant Loop Mode
  95836. */
  95837. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95838. /** @hidden */
  95839. static _UniversalLerp(left: any, right: any, amount: number): any;
  95840. /**
  95841. * Parses an animation object and creates an animation
  95842. * @param parsedAnimation Parsed animation object
  95843. * @returns Animation object
  95844. */
  95845. static Parse(parsedAnimation: any): Animation;
  95846. /**
  95847. * Appends the serialized animations from the source animations
  95848. * @param source Source containing the animations
  95849. * @param destination Target to store the animations
  95850. */
  95851. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95852. }
  95853. }
  95854. declare module BABYLON {
  95855. /**
  95856. * Interface containing an array of animations
  95857. */
  95858. export interface IAnimatable {
  95859. /**
  95860. * Array of animations
  95861. */
  95862. animations: Nullable<Array<Animation>>;
  95863. }
  95864. }
  95865. declare module BABYLON {
  95866. /**
  95867. * This represents all the required information to add a fresnel effect on a material:
  95868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95869. */
  95870. export class FresnelParameters {
  95871. private _isEnabled;
  95872. /**
  95873. * Define if the fresnel effect is enable or not.
  95874. */
  95875. isEnabled: boolean;
  95876. /**
  95877. * Define the color used on edges (grazing angle)
  95878. */
  95879. leftColor: Color3;
  95880. /**
  95881. * Define the color used on center
  95882. */
  95883. rightColor: Color3;
  95884. /**
  95885. * Define bias applied to computed fresnel term
  95886. */
  95887. bias: number;
  95888. /**
  95889. * Defined the power exponent applied to fresnel term
  95890. */
  95891. power: number;
  95892. /**
  95893. * Clones the current fresnel and its valuues
  95894. * @returns a clone fresnel configuration
  95895. */
  95896. clone(): FresnelParameters;
  95897. /**
  95898. * Serializes the current fresnel parameters to a JSON representation.
  95899. * @return the JSON serialization
  95900. */
  95901. serialize(): any;
  95902. /**
  95903. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95904. * @param parsedFresnelParameters Define the JSON representation
  95905. * @returns the parsed parameters
  95906. */
  95907. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95908. }
  95909. }
  95910. declare module BABYLON {
  95911. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95912. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95913. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95914. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95915. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95916. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95917. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95918. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95919. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95920. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95921. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95922. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95923. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95924. /**
  95925. * Decorator used to define property that can be serialized as reference to a camera
  95926. * @param sourceName defines the name of the property to decorate
  95927. */
  95928. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95929. /**
  95930. * Class used to help serialization objects
  95931. */
  95932. export class SerializationHelper {
  95933. /** @hidden */
  95934. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95935. /** @hidden */
  95936. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95937. /** @hidden */
  95938. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95939. /** @hidden */
  95940. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95941. /**
  95942. * Appends the serialized animations from the source animations
  95943. * @param source Source containing the animations
  95944. * @param destination Target to store the animations
  95945. */
  95946. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95947. /**
  95948. * Static function used to serialized a specific entity
  95949. * @param entity defines the entity to serialize
  95950. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95951. * @returns a JSON compatible object representing the serialization of the entity
  95952. */
  95953. static Serialize<T>(entity: T, serializationObject?: any): any;
  95954. /**
  95955. * Creates a new entity from a serialization data object
  95956. * @param creationFunction defines a function used to instanciated the new entity
  95957. * @param source defines the source serialization data
  95958. * @param scene defines the hosting scene
  95959. * @param rootUrl defines the root url for resources
  95960. * @returns a new entity
  95961. */
  95962. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95963. /**
  95964. * Clones an object
  95965. * @param creationFunction defines the function used to instanciate the new object
  95966. * @param source defines the source object
  95967. * @returns the cloned object
  95968. */
  95969. static Clone<T>(creationFunction: () => T, source: T): T;
  95970. /**
  95971. * Instanciates a new object based on a source one (some data will be shared between both object)
  95972. * @param creationFunction defines the function used to instanciate the new object
  95973. * @param source defines the source object
  95974. * @returns the new object
  95975. */
  95976. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95977. }
  95978. }
  95979. declare module BABYLON {
  95980. /**
  95981. * Class used to manipulate GUIDs
  95982. */
  95983. export class GUID {
  95984. /**
  95985. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95986. * Be aware Math.random() could cause collisions, but:
  95987. * "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"
  95988. * @returns a pseudo random id
  95989. */
  95990. static RandomId(): string;
  95991. }
  95992. }
  95993. declare module BABYLON {
  95994. /**
  95995. * Base class of all the textures in babylon.
  95996. * It groups all the common properties the materials, post process, lights... might need
  95997. * in order to make a correct use of the texture.
  95998. */
  95999. export class BaseTexture implements IAnimatable {
  96000. /**
  96001. * Default anisotropic filtering level for the application.
  96002. * It is set to 4 as a good tradeoff between perf and quality.
  96003. */
  96004. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96005. /**
  96006. * Gets or sets the unique id of the texture
  96007. */
  96008. uniqueId: number;
  96009. /**
  96010. * Define the name of the texture.
  96011. */
  96012. name: string;
  96013. /**
  96014. * Gets or sets an object used to store user defined information.
  96015. */
  96016. metadata: any;
  96017. /**
  96018. * For internal use only. Please do not use.
  96019. */
  96020. reservedDataStore: any;
  96021. private _hasAlpha;
  96022. /**
  96023. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96024. */
  96025. hasAlpha: boolean;
  96026. /**
  96027. * Defines if the alpha value should be determined via the rgb values.
  96028. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96029. */
  96030. getAlphaFromRGB: boolean;
  96031. /**
  96032. * Intensity or strength of the texture.
  96033. * It is commonly used by materials to fine tune the intensity of the texture
  96034. */
  96035. level: number;
  96036. /**
  96037. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96038. * This is part of the texture as textures usually maps to one uv set.
  96039. */
  96040. coordinatesIndex: number;
  96041. private _coordinatesMode;
  96042. /**
  96043. * How a texture is mapped.
  96044. *
  96045. * | Value | Type | Description |
  96046. * | ----- | ----------------------------------- | ----------- |
  96047. * | 0 | EXPLICIT_MODE | |
  96048. * | 1 | SPHERICAL_MODE | |
  96049. * | 2 | PLANAR_MODE | |
  96050. * | 3 | CUBIC_MODE | |
  96051. * | 4 | PROJECTION_MODE | |
  96052. * | 5 | SKYBOX_MODE | |
  96053. * | 6 | INVCUBIC_MODE | |
  96054. * | 7 | EQUIRECTANGULAR_MODE | |
  96055. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96056. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96057. */
  96058. coordinatesMode: number;
  96059. /**
  96060. * | Value | Type | Description |
  96061. * | ----- | ------------------ | ----------- |
  96062. * | 0 | CLAMP_ADDRESSMODE | |
  96063. * | 1 | WRAP_ADDRESSMODE | |
  96064. * | 2 | MIRROR_ADDRESSMODE | |
  96065. */
  96066. wrapU: number;
  96067. /**
  96068. * | Value | Type | Description |
  96069. * | ----- | ------------------ | ----------- |
  96070. * | 0 | CLAMP_ADDRESSMODE | |
  96071. * | 1 | WRAP_ADDRESSMODE | |
  96072. * | 2 | MIRROR_ADDRESSMODE | |
  96073. */
  96074. wrapV: number;
  96075. /**
  96076. * | Value | Type | Description |
  96077. * | ----- | ------------------ | ----------- |
  96078. * | 0 | CLAMP_ADDRESSMODE | |
  96079. * | 1 | WRAP_ADDRESSMODE | |
  96080. * | 2 | MIRROR_ADDRESSMODE | |
  96081. */
  96082. wrapR: number;
  96083. /**
  96084. * With compliant hardware and browser (supporting anisotropic filtering)
  96085. * this defines the level of anisotropic filtering in the texture.
  96086. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96087. */
  96088. anisotropicFilteringLevel: number;
  96089. /**
  96090. * Define if the texture is a cube texture or if false a 2d texture.
  96091. */
  96092. isCube: boolean;
  96093. /**
  96094. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96095. */
  96096. is3D: boolean;
  96097. /**
  96098. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96099. */
  96100. is2DArray: boolean;
  96101. /**
  96102. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96103. * HDR texture are usually stored in linear space.
  96104. * This only impacts the PBR and Background materials
  96105. */
  96106. gammaSpace: boolean;
  96107. /**
  96108. * Gets or sets whether or not the texture contains RGBD data.
  96109. */
  96110. isRGBD: boolean;
  96111. /**
  96112. * Is Z inverted in the texture (useful in a cube texture).
  96113. */
  96114. invertZ: boolean;
  96115. /**
  96116. * Are mip maps generated for this texture or not.
  96117. */
  96118. readonly noMipmap: boolean;
  96119. /**
  96120. * @hidden
  96121. */
  96122. lodLevelInAlpha: boolean;
  96123. /**
  96124. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96125. */
  96126. lodGenerationOffset: number;
  96127. /**
  96128. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96129. */
  96130. lodGenerationScale: number;
  96131. /**
  96132. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96133. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96134. * average roughness values.
  96135. */
  96136. linearSpecularLOD: boolean;
  96137. /**
  96138. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96139. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96140. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96141. */
  96142. irradianceTexture: Nullable<BaseTexture>;
  96143. /**
  96144. * Define if the texture is a render target.
  96145. */
  96146. isRenderTarget: boolean;
  96147. /**
  96148. * Define the unique id of the texture in the scene.
  96149. */
  96150. readonly uid: string;
  96151. /**
  96152. * Return a string representation of the texture.
  96153. * @returns the texture as a string
  96154. */
  96155. toString(): string;
  96156. /**
  96157. * Get the class name of the texture.
  96158. * @returns "BaseTexture"
  96159. */
  96160. getClassName(): string;
  96161. /**
  96162. * Define the list of animation attached to the texture.
  96163. */
  96164. animations: Animation[];
  96165. /**
  96166. * An event triggered when the texture is disposed.
  96167. */
  96168. onDisposeObservable: Observable<BaseTexture>;
  96169. private _onDisposeObserver;
  96170. /**
  96171. * Callback triggered when the texture has been disposed.
  96172. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96173. */
  96174. onDispose: () => void;
  96175. /**
  96176. * Define the current state of the loading sequence when in delayed load mode.
  96177. */
  96178. delayLoadState: number;
  96179. private _scene;
  96180. /** @hidden */
  96181. _texture: Nullable<InternalTexture>;
  96182. private _uid;
  96183. /**
  96184. * Define if the texture is preventinga material to render or not.
  96185. * If not and the texture is not ready, the engine will use a default black texture instead.
  96186. */
  96187. readonly isBlocking: boolean;
  96188. /**
  96189. * Instantiates a new BaseTexture.
  96190. * Base class of all the textures in babylon.
  96191. * It groups all the common properties the materials, post process, lights... might need
  96192. * in order to make a correct use of the texture.
  96193. * @param scene Define the scene the texture blongs to
  96194. */
  96195. constructor(scene: Nullable<Scene>);
  96196. /**
  96197. * Get the scene the texture belongs to.
  96198. * @returns the scene or null if undefined
  96199. */
  96200. getScene(): Nullable<Scene>;
  96201. /**
  96202. * Get the texture transform matrix used to offset tile the texture for istance.
  96203. * @returns the transformation matrix
  96204. */
  96205. getTextureMatrix(): Matrix;
  96206. /**
  96207. * Get the texture reflection matrix used to rotate/transform the reflection.
  96208. * @returns the reflection matrix
  96209. */
  96210. getReflectionTextureMatrix(): Matrix;
  96211. /**
  96212. * Get the underlying lower level texture from Babylon.
  96213. * @returns the insternal texture
  96214. */
  96215. getInternalTexture(): Nullable<InternalTexture>;
  96216. /**
  96217. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96218. * @returns true if ready or not blocking
  96219. */
  96220. isReadyOrNotBlocking(): boolean;
  96221. /**
  96222. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96223. * @returns true if fully ready
  96224. */
  96225. isReady(): boolean;
  96226. private _cachedSize;
  96227. /**
  96228. * Get the size of the texture.
  96229. * @returns the texture size.
  96230. */
  96231. getSize(): ISize;
  96232. /**
  96233. * Get the base size of the texture.
  96234. * It can be different from the size if the texture has been resized for POT for instance
  96235. * @returns the base size
  96236. */
  96237. getBaseSize(): ISize;
  96238. /**
  96239. * Update the sampling mode of the texture.
  96240. * Default is Trilinear mode.
  96241. *
  96242. * | Value | Type | Description |
  96243. * | ----- | ------------------ | ----------- |
  96244. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96245. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96246. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96247. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96248. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96249. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96250. * | 7 | NEAREST_LINEAR | |
  96251. * | 8 | NEAREST_NEAREST | |
  96252. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96253. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96254. * | 11 | LINEAR_LINEAR | |
  96255. * | 12 | LINEAR_NEAREST | |
  96256. *
  96257. * > _mag_: magnification filter (close to the viewer)
  96258. * > _min_: minification filter (far from the viewer)
  96259. * > _mip_: filter used between mip map levels
  96260. *@param samplingMode Define the new sampling mode of the texture
  96261. */
  96262. updateSamplingMode(samplingMode: number): void;
  96263. /**
  96264. * Scales the texture if is `canRescale()`
  96265. * @param ratio the resize factor we want to use to rescale
  96266. */
  96267. scale(ratio: number): void;
  96268. /**
  96269. * Get if the texture can rescale.
  96270. */
  96271. readonly canRescale: boolean;
  96272. /** @hidden */
  96273. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96274. /** @hidden */
  96275. _rebuild(): void;
  96276. /**
  96277. * Triggers the load sequence in delayed load mode.
  96278. */
  96279. delayLoad(): void;
  96280. /**
  96281. * Clones the texture.
  96282. * @returns the cloned texture
  96283. */
  96284. clone(): Nullable<BaseTexture>;
  96285. /**
  96286. * Get the texture underlying type (INT, FLOAT...)
  96287. */
  96288. readonly textureType: number;
  96289. /**
  96290. * Get the texture underlying format (RGB, RGBA...)
  96291. */
  96292. readonly textureFormat: number;
  96293. /**
  96294. * Indicates that textures need to be re-calculated for all materials
  96295. */
  96296. protected _markAllSubMeshesAsTexturesDirty(): void;
  96297. /**
  96298. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96299. * This will returns an RGBA array buffer containing either in values (0-255) or
  96300. * float values (0-1) depending of the underlying buffer type.
  96301. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96302. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96303. * @param buffer defines a user defined buffer to fill with data (can be null)
  96304. * @returns The Array buffer containing the pixels data.
  96305. */
  96306. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96307. /**
  96308. * Release and destroy the underlying lower level texture aka internalTexture.
  96309. */
  96310. releaseInternalTexture(): void;
  96311. /** @hidden */
  96312. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96313. /** @hidden */
  96314. readonly _lodTextureMid: Nullable<BaseTexture>;
  96315. /** @hidden */
  96316. readonly _lodTextureLow: Nullable<BaseTexture>;
  96317. /**
  96318. * Dispose the texture and release its associated resources.
  96319. */
  96320. dispose(): void;
  96321. /**
  96322. * Serialize the texture into a JSON representation that can be parsed later on.
  96323. * @returns the JSON representation of the texture
  96324. */
  96325. serialize(): any;
  96326. /**
  96327. * Helper function to be called back once a list of texture contains only ready textures.
  96328. * @param textures Define the list of textures to wait for
  96329. * @param callback Define the callback triggered once the entire list will be ready
  96330. */
  96331. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96332. }
  96333. }
  96334. declare module BABYLON {
  96335. /**
  96336. * Options to be used when creating an effect.
  96337. */
  96338. export interface IEffectCreationOptions {
  96339. /**
  96340. * Atrributes that will be used in the shader.
  96341. */
  96342. attributes: string[];
  96343. /**
  96344. * Uniform varible names that will be set in the shader.
  96345. */
  96346. uniformsNames: string[];
  96347. /**
  96348. * Uniform buffer varible names that will be set in the shader.
  96349. */
  96350. uniformBuffersNames: string[];
  96351. /**
  96352. * Sampler texture variable names that will be set in the shader.
  96353. */
  96354. samplers: string[];
  96355. /**
  96356. * Define statements that will be set in the shader.
  96357. */
  96358. defines: any;
  96359. /**
  96360. * Possible fallbacks for this effect to improve performance when needed.
  96361. */
  96362. fallbacks: Nullable<IEffectFallbacks>;
  96363. /**
  96364. * Callback that will be called when the shader is compiled.
  96365. */
  96366. onCompiled: Nullable<(effect: Effect) => void>;
  96367. /**
  96368. * Callback that will be called if an error occurs during shader compilation.
  96369. */
  96370. onError: Nullable<(effect: Effect, errors: string) => void>;
  96371. /**
  96372. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96373. */
  96374. indexParameters?: any;
  96375. /**
  96376. * Max number of lights that can be used in the shader.
  96377. */
  96378. maxSimultaneousLights?: number;
  96379. /**
  96380. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96381. */
  96382. transformFeedbackVaryings?: Nullable<string[]>;
  96383. }
  96384. /**
  96385. * Effect containing vertex and fragment shader that can be executed on an object.
  96386. */
  96387. export class Effect implements IDisposable {
  96388. /**
  96389. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96390. */
  96391. static ShadersRepository: string;
  96392. /**
  96393. * Name of the effect.
  96394. */
  96395. name: any;
  96396. /**
  96397. * String container all the define statements that should be set on the shader.
  96398. */
  96399. defines: string;
  96400. /**
  96401. * Callback that will be called when the shader is compiled.
  96402. */
  96403. onCompiled: Nullable<(effect: Effect) => void>;
  96404. /**
  96405. * Callback that will be called if an error occurs during shader compilation.
  96406. */
  96407. onError: Nullable<(effect: Effect, errors: string) => void>;
  96408. /**
  96409. * Callback that will be called when effect is bound.
  96410. */
  96411. onBind: Nullable<(effect: Effect) => void>;
  96412. /**
  96413. * Unique ID of the effect.
  96414. */
  96415. uniqueId: number;
  96416. /**
  96417. * Observable that will be called when the shader is compiled.
  96418. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96419. */
  96420. onCompileObservable: Observable<Effect>;
  96421. /**
  96422. * Observable that will be called if an error occurs during shader compilation.
  96423. */
  96424. onErrorObservable: Observable<Effect>;
  96425. /** @hidden */
  96426. _onBindObservable: Nullable<Observable<Effect>>;
  96427. /**
  96428. * Observable that will be called when effect is bound.
  96429. */
  96430. readonly onBindObservable: Observable<Effect>;
  96431. /** @hidden */
  96432. _bonesComputationForcedToCPU: boolean;
  96433. private static _uniqueIdSeed;
  96434. private _engine;
  96435. private _uniformBuffersNames;
  96436. private _uniformsNames;
  96437. private _samplerList;
  96438. private _samplers;
  96439. private _isReady;
  96440. private _compilationError;
  96441. private _allFallbacksProcessed;
  96442. private _attributesNames;
  96443. private _attributes;
  96444. private _uniforms;
  96445. /**
  96446. * Key for the effect.
  96447. * @hidden
  96448. */
  96449. _key: string;
  96450. private _indexParameters;
  96451. private _fallbacks;
  96452. private _vertexSourceCode;
  96453. private _fragmentSourceCode;
  96454. private _vertexSourceCodeOverride;
  96455. private _fragmentSourceCodeOverride;
  96456. private _transformFeedbackVaryings;
  96457. /**
  96458. * Compiled shader to webGL program.
  96459. * @hidden
  96460. */
  96461. _pipelineContext: Nullable<IPipelineContext>;
  96462. private _valueCache;
  96463. private static _baseCache;
  96464. /**
  96465. * Instantiates an effect.
  96466. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96467. * @param baseName Name of the effect.
  96468. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96469. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96470. * @param samplers List of sampler variables that will be passed to the shader.
  96471. * @param engine Engine to be used to render the effect
  96472. * @param defines Define statements to be added to the shader.
  96473. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96474. * @param onCompiled Callback that will be called when the shader is compiled.
  96475. * @param onError Callback that will be called if an error occurs during shader compilation.
  96476. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96477. */
  96478. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  96479. private _useFinalCode;
  96480. /**
  96481. * Unique key for this effect
  96482. */
  96483. readonly key: string;
  96484. /**
  96485. * If the effect has been compiled and prepared.
  96486. * @returns if the effect is compiled and prepared.
  96487. */
  96488. isReady(): boolean;
  96489. private _isReadyInternal;
  96490. /**
  96491. * The engine the effect was initialized with.
  96492. * @returns the engine.
  96493. */
  96494. getEngine(): Engine;
  96495. /**
  96496. * The pipeline context for this effect
  96497. * @returns the associated pipeline context
  96498. */
  96499. getPipelineContext(): Nullable<IPipelineContext>;
  96500. /**
  96501. * The set of names of attribute variables for the shader.
  96502. * @returns An array of attribute names.
  96503. */
  96504. getAttributesNames(): string[];
  96505. /**
  96506. * Returns the attribute at the given index.
  96507. * @param index The index of the attribute.
  96508. * @returns The location of the attribute.
  96509. */
  96510. getAttributeLocation(index: number): number;
  96511. /**
  96512. * Returns the attribute based on the name of the variable.
  96513. * @param name of the attribute to look up.
  96514. * @returns the attribute location.
  96515. */
  96516. getAttributeLocationByName(name: string): number;
  96517. /**
  96518. * The number of attributes.
  96519. * @returns the numnber of attributes.
  96520. */
  96521. getAttributesCount(): number;
  96522. /**
  96523. * Gets the index of a uniform variable.
  96524. * @param uniformName of the uniform to look up.
  96525. * @returns the index.
  96526. */
  96527. getUniformIndex(uniformName: string): number;
  96528. /**
  96529. * Returns the attribute based on the name of the variable.
  96530. * @param uniformName of the uniform to look up.
  96531. * @returns the location of the uniform.
  96532. */
  96533. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96534. /**
  96535. * Returns an array of sampler variable names
  96536. * @returns The array of sampler variable neames.
  96537. */
  96538. getSamplers(): string[];
  96539. /**
  96540. * The error from the last compilation.
  96541. * @returns the error string.
  96542. */
  96543. getCompilationError(): string;
  96544. /**
  96545. * Gets a boolean indicating that all fallbacks were used during compilation
  96546. * @returns true if all fallbacks were used
  96547. */
  96548. allFallbacksProcessed(): boolean;
  96549. /**
  96550. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96551. * @param func The callback to be used.
  96552. */
  96553. executeWhenCompiled(func: (effect: Effect) => void): void;
  96554. private _checkIsReady;
  96555. private _loadShader;
  96556. /**
  96557. * Recompiles the webGL program
  96558. * @param vertexSourceCode The source code for the vertex shader.
  96559. * @param fragmentSourceCode The source code for the fragment shader.
  96560. * @param onCompiled Callback called when completed.
  96561. * @param onError Callback called on error.
  96562. * @hidden
  96563. */
  96564. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96565. /**
  96566. * Prepares the effect
  96567. * @hidden
  96568. */
  96569. _prepareEffect(): void;
  96570. private _processCompilationErrors;
  96571. /**
  96572. * Checks if the effect is supported. (Must be called after compilation)
  96573. */
  96574. readonly isSupported: boolean;
  96575. /**
  96576. * Binds a texture to the engine to be used as output of the shader.
  96577. * @param channel Name of the output variable.
  96578. * @param texture Texture to bind.
  96579. * @hidden
  96580. */
  96581. _bindTexture(channel: string, texture: InternalTexture): void;
  96582. /**
  96583. * Sets a texture on the engine to be used in the shader.
  96584. * @param channel Name of the sampler variable.
  96585. * @param texture Texture to set.
  96586. */
  96587. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96588. /**
  96589. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96590. * @param channel Name of the sampler variable.
  96591. * @param texture Texture to set.
  96592. */
  96593. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96594. /**
  96595. * Sets an array of textures on the engine to be used in the shader.
  96596. * @param channel Name of the variable.
  96597. * @param textures Textures to set.
  96598. */
  96599. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96600. /**
  96601. * 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)
  96602. * @param channel Name of the sampler variable.
  96603. * @param postProcess Post process to get the input texture from.
  96604. */
  96605. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96606. /**
  96607. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96608. * 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)
  96609. * @param channel Name of the sampler variable.
  96610. * @param postProcess Post process to get the output texture from.
  96611. */
  96612. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96613. /** @hidden */
  96614. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96615. /** @hidden */
  96616. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96617. /** @hidden */
  96618. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96619. /** @hidden */
  96620. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96621. /**
  96622. * Binds a buffer to a uniform.
  96623. * @param buffer Buffer to bind.
  96624. * @param name Name of the uniform variable to bind to.
  96625. */
  96626. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96627. /**
  96628. * Binds block to a uniform.
  96629. * @param blockName Name of the block to bind.
  96630. * @param index Index to bind.
  96631. */
  96632. bindUniformBlock(blockName: string, index: number): void;
  96633. /**
  96634. * Sets an interger value on a uniform variable.
  96635. * @param uniformName Name of the variable.
  96636. * @param value Value to be set.
  96637. * @returns this effect.
  96638. */
  96639. setInt(uniformName: string, value: number): Effect;
  96640. /**
  96641. * Sets an int array on a uniform variable.
  96642. * @param uniformName Name of the variable.
  96643. * @param array array to be set.
  96644. * @returns this effect.
  96645. */
  96646. setIntArray(uniformName: string, array: Int32Array): Effect;
  96647. /**
  96648. * 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)
  96649. * @param uniformName Name of the variable.
  96650. * @param array array to be set.
  96651. * @returns this effect.
  96652. */
  96653. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96654. /**
  96655. * 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)
  96656. * @param uniformName Name of the variable.
  96657. * @param array array to be set.
  96658. * @returns this effect.
  96659. */
  96660. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96661. /**
  96662. * 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)
  96663. * @param uniformName Name of the variable.
  96664. * @param array array to be set.
  96665. * @returns this effect.
  96666. */
  96667. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96668. /**
  96669. * Sets an float array on a uniform variable.
  96670. * @param uniformName Name of the variable.
  96671. * @param array array to be set.
  96672. * @returns this effect.
  96673. */
  96674. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96675. /**
  96676. * 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)
  96677. * @param uniformName Name of the variable.
  96678. * @param array array to be set.
  96679. * @returns this effect.
  96680. */
  96681. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96682. /**
  96683. * 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)
  96684. * @param uniformName Name of the variable.
  96685. * @param array array to be set.
  96686. * @returns this effect.
  96687. */
  96688. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96689. /**
  96690. * 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)
  96691. * @param uniformName Name of the variable.
  96692. * @param array array to be set.
  96693. * @returns this effect.
  96694. */
  96695. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96696. /**
  96697. * Sets an array on a uniform variable.
  96698. * @param uniformName Name of the variable.
  96699. * @param array array to be set.
  96700. * @returns this effect.
  96701. */
  96702. setArray(uniformName: string, array: number[]): Effect;
  96703. /**
  96704. * 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)
  96705. * @param uniformName Name of the variable.
  96706. * @param array array to be set.
  96707. * @returns this effect.
  96708. */
  96709. setArray2(uniformName: string, array: number[]): Effect;
  96710. /**
  96711. * 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)
  96712. * @param uniformName Name of the variable.
  96713. * @param array array to be set.
  96714. * @returns this effect.
  96715. */
  96716. setArray3(uniformName: string, array: number[]): Effect;
  96717. /**
  96718. * 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)
  96719. * @param uniformName Name of the variable.
  96720. * @param array array to be set.
  96721. * @returns this effect.
  96722. */
  96723. setArray4(uniformName: string, array: number[]): Effect;
  96724. /**
  96725. * Sets matrices on a uniform variable.
  96726. * @param uniformName Name of the variable.
  96727. * @param matrices matrices to be set.
  96728. * @returns this effect.
  96729. */
  96730. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96731. /**
  96732. * Sets matrix on a uniform variable.
  96733. * @param uniformName Name of the variable.
  96734. * @param matrix matrix to be set.
  96735. * @returns this effect.
  96736. */
  96737. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96738. /**
  96739. * 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)
  96740. * @param uniformName Name of the variable.
  96741. * @param matrix matrix to be set.
  96742. * @returns this effect.
  96743. */
  96744. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96745. /**
  96746. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96747. * @param uniformName Name of the variable.
  96748. * @param matrix matrix to be set.
  96749. * @returns this effect.
  96750. */
  96751. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96752. /**
  96753. * Sets a float on a uniform variable.
  96754. * @param uniformName Name of the variable.
  96755. * @param value value to be set.
  96756. * @returns this effect.
  96757. */
  96758. setFloat(uniformName: string, value: number): Effect;
  96759. /**
  96760. * Sets a boolean on a uniform variable.
  96761. * @param uniformName Name of the variable.
  96762. * @param bool value to be set.
  96763. * @returns this effect.
  96764. */
  96765. setBool(uniformName: string, bool: boolean): Effect;
  96766. /**
  96767. * Sets a Vector2 on a uniform variable.
  96768. * @param uniformName Name of the variable.
  96769. * @param vector2 vector2 to be set.
  96770. * @returns this effect.
  96771. */
  96772. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96773. /**
  96774. * Sets a float2 on a uniform variable.
  96775. * @param uniformName Name of the variable.
  96776. * @param x First float in float2.
  96777. * @param y Second float in float2.
  96778. * @returns this effect.
  96779. */
  96780. setFloat2(uniformName: string, x: number, y: number): Effect;
  96781. /**
  96782. * Sets a Vector3 on a uniform variable.
  96783. * @param uniformName Name of the variable.
  96784. * @param vector3 Value to be set.
  96785. * @returns this effect.
  96786. */
  96787. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96788. /**
  96789. * Sets a float3 on a uniform variable.
  96790. * @param uniformName Name of the variable.
  96791. * @param x First float in float3.
  96792. * @param y Second float in float3.
  96793. * @param z Third float in float3.
  96794. * @returns this effect.
  96795. */
  96796. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96797. /**
  96798. * Sets a Vector4 on a uniform variable.
  96799. * @param uniformName Name of the variable.
  96800. * @param vector4 Value to be set.
  96801. * @returns this effect.
  96802. */
  96803. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96804. /**
  96805. * Sets a float4 on a uniform variable.
  96806. * @param uniformName Name of the variable.
  96807. * @param x First float in float4.
  96808. * @param y Second float in float4.
  96809. * @param z Third float in float4.
  96810. * @param w Fourth float in float4.
  96811. * @returns this effect.
  96812. */
  96813. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96814. /**
  96815. * Sets a Color3 on a uniform variable.
  96816. * @param uniformName Name of the variable.
  96817. * @param color3 Value to be set.
  96818. * @returns this effect.
  96819. */
  96820. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96821. /**
  96822. * Sets a Color4 on a uniform variable.
  96823. * @param uniformName Name of the variable.
  96824. * @param color3 Value to be set.
  96825. * @param alpha Alpha value to be set.
  96826. * @returns this effect.
  96827. */
  96828. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96829. /**
  96830. * Sets a Color4 on a uniform variable
  96831. * @param uniformName defines the name of the variable
  96832. * @param color4 defines the value to be set
  96833. * @returns this effect.
  96834. */
  96835. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96836. /** Release all associated resources */
  96837. dispose(): void;
  96838. /**
  96839. * This function will add a new shader to the shader store
  96840. * @param name the name of the shader
  96841. * @param pixelShader optional pixel shader content
  96842. * @param vertexShader optional vertex shader content
  96843. */
  96844. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96845. /**
  96846. * Store of each shader (The can be looked up using effect.key)
  96847. */
  96848. static ShadersStore: {
  96849. [key: string]: string;
  96850. };
  96851. /**
  96852. * Store of each included file for a shader (The can be looked up using effect.key)
  96853. */
  96854. static IncludesShadersStore: {
  96855. [key: string]: string;
  96856. };
  96857. /**
  96858. * Resets the cache of effects.
  96859. */
  96860. static ResetCache(): void;
  96861. }
  96862. }
  96863. declare module BABYLON {
  96864. /**
  96865. * Interface used to describe the capabilities of the engine relatively to the current browser
  96866. */
  96867. export interface EngineCapabilities {
  96868. /** Maximum textures units per fragment shader */
  96869. maxTexturesImageUnits: number;
  96870. /** Maximum texture units per vertex shader */
  96871. maxVertexTextureImageUnits: number;
  96872. /** Maximum textures units in the entire pipeline */
  96873. maxCombinedTexturesImageUnits: number;
  96874. /** Maximum texture size */
  96875. maxTextureSize: number;
  96876. /** Maximum cube texture size */
  96877. maxCubemapTextureSize: number;
  96878. /** Maximum render texture size */
  96879. maxRenderTextureSize: number;
  96880. /** Maximum number of vertex attributes */
  96881. maxVertexAttribs: number;
  96882. /** Maximum number of varyings */
  96883. maxVaryingVectors: number;
  96884. /** Maximum number of uniforms per vertex shader */
  96885. maxVertexUniformVectors: number;
  96886. /** Maximum number of uniforms per fragment shader */
  96887. maxFragmentUniformVectors: number;
  96888. /** Defines if standard derivates (dx/dy) are supported */
  96889. standardDerivatives: boolean;
  96890. /** Defines if s3tc texture compression is supported */
  96891. s3tc?: WEBGL_compressed_texture_s3tc;
  96892. /** Defines if pvrtc texture compression is supported */
  96893. pvrtc: any;
  96894. /** Defines if etc1 texture compression is supported */
  96895. etc1: any;
  96896. /** Defines if etc2 texture compression is supported */
  96897. etc2: any;
  96898. /** Defines if astc texture compression is supported */
  96899. astc: any;
  96900. /** Defines if float textures are supported */
  96901. textureFloat: boolean;
  96902. /** Defines if vertex array objects are supported */
  96903. vertexArrayObject: boolean;
  96904. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96905. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96906. /** Gets the maximum level of anisotropy supported */
  96907. maxAnisotropy: number;
  96908. /** Defines if instancing is supported */
  96909. instancedArrays: boolean;
  96910. /** Defines if 32 bits indices are supported */
  96911. uintIndices: boolean;
  96912. /** Defines if high precision shaders are supported */
  96913. highPrecisionShaderSupported: boolean;
  96914. /** Defines if depth reading in the fragment shader is supported */
  96915. fragmentDepthSupported: boolean;
  96916. /** Defines if float texture linear filtering is supported*/
  96917. textureFloatLinearFiltering: boolean;
  96918. /** Defines if rendering to float textures is supported */
  96919. textureFloatRender: boolean;
  96920. /** Defines if half float textures are supported*/
  96921. textureHalfFloat: boolean;
  96922. /** Defines if half float texture linear filtering is supported*/
  96923. textureHalfFloatLinearFiltering: boolean;
  96924. /** Defines if rendering to half float textures is supported */
  96925. textureHalfFloatRender: boolean;
  96926. /** Defines if textureLOD shader command is supported */
  96927. textureLOD: boolean;
  96928. /** Defines if draw buffers extension is supported */
  96929. drawBuffersExtension: boolean;
  96930. /** Defines if depth textures are supported */
  96931. depthTextureExtension: boolean;
  96932. /** Defines if float color buffer are supported */
  96933. colorBufferFloat: boolean;
  96934. /** Gets disjoint timer query extension (null if not supported) */
  96935. timerQuery?: EXT_disjoint_timer_query;
  96936. /** Defines if timestamp can be used with timer query */
  96937. canUseTimestampForTimerQuery: boolean;
  96938. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96939. multiview?: any;
  96940. /** Function used to let the system compiles shaders in background */
  96941. parallelShaderCompile?: {
  96942. COMPLETION_STATUS_KHR: number;
  96943. };
  96944. /** Max number of texture samples for MSAA */
  96945. maxMSAASamples: number;
  96946. /** Defines if the blend min max extension is supported */
  96947. blendMinMax: boolean;
  96948. }
  96949. }
  96950. declare module BABYLON {
  96951. /**
  96952. * @hidden
  96953. **/
  96954. export class DepthCullingState {
  96955. private _isDepthTestDirty;
  96956. private _isDepthMaskDirty;
  96957. private _isDepthFuncDirty;
  96958. private _isCullFaceDirty;
  96959. private _isCullDirty;
  96960. private _isZOffsetDirty;
  96961. private _isFrontFaceDirty;
  96962. private _depthTest;
  96963. private _depthMask;
  96964. private _depthFunc;
  96965. private _cull;
  96966. private _cullFace;
  96967. private _zOffset;
  96968. private _frontFace;
  96969. /**
  96970. * Initializes the state.
  96971. */
  96972. constructor();
  96973. readonly isDirty: boolean;
  96974. zOffset: number;
  96975. cullFace: Nullable<number>;
  96976. cull: Nullable<boolean>;
  96977. depthFunc: Nullable<number>;
  96978. depthMask: boolean;
  96979. depthTest: boolean;
  96980. frontFace: Nullable<number>;
  96981. reset(): void;
  96982. apply(gl: WebGLRenderingContext): void;
  96983. }
  96984. }
  96985. declare module BABYLON {
  96986. /**
  96987. * @hidden
  96988. **/
  96989. export class StencilState {
  96990. /** 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 */
  96991. static readonly ALWAYS: number;
  96992. /** Passed to stencilOperation to specify that stencil value must be kept */
  96993. static readonly KEEP: number;
  96994. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96995. static readonly REPLACE: number;
  96996. private _isStencilTestDirty;
  96997. private _isStencilMaskDirty;
  96998. private _isStencilFuncDirty;
  96999. private _isStencilOpDirty;
  97000. private _stencilTest;
  97001. private _stencilMask;
  97002. private _stencilFunc;
  97003. private _stencilFuncRef;
  97004. private _stencilFuncMask;
  97005. private _stencilOpStencilFail;
  97006. private _stencilOpDepthFail;
  97007. private _stencilOpStencilDepthPass;
  97008. readonly isDirty: boolean;
  97009. stencilFunc: number;
  97010. stencilFuncRef: number;
  97011. stencilFuncMask: number;
  97012. stencilOpStencilFail: number;
  97013. stencilOpDepthFail: number;
  97014. stencilOpStencilDepthPass: number;
  97015. stencilMask: number;
  97016. stencilTest: boolean;
  97017. constructor();
  97018. reset(): void;
  97019. apply(gl: WebGLRenderingContext): void;
  97020. }
  97021. }
  97022. declare module BABYLON {
  97023. /**
  97024. * @hidden
  97025. **/
  97026. export class AlphaState {
  97027. private _isAlphaBlendDirty;
  97028. private _isBlendFunctionParametersDirty;
  97029. private _isBlendEquationParametersDirty;
  97030. private _isBlendConstantsDirty;
  97031. private _alphaBlend;
  97032. private _blendFunctionParameters;
  97033. private _blendEquationParameters;
  97034. private _blendConstants;
  97035. /**
  97036. * Initializes the state.
  97037. */
  97038. constructor();
  97039. readonly isDirty: boolean;
  97040. alphaBlend: boolean;
  97041. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97042. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97043. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97044. reset(): void;
  97045. apply(gl: WebGLRenderingContext): void;
  97046. }
  97047. }
  97048. declare module BABYLON {
  97049. /** @hidden */
  97050. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97051. attributeProcessor(attribute: string): string;
  97052. varyingProcessor(varying: string, isFragment: boolean): string;
  97053. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97054. }
  97055. }
  97056. declare module BABYLON {
  97057. /**
  97058. * Interface for attribute information associated with buffer instanciation
  97059. */
  97060. export interface InstancingAttributeInfo {
  97061. /**
  97062. * Index/offset of the attribute in the vertex shader
  97063. */
  97064. index: number;
  97065. /**
  97066. * size of the attribute, 1, 2, 3 or 4
  97067. */
  97068. attributeSize: number;
  97069. /**
  97070. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97071. * default is FLOAT
  97072. */
  97073. attributeType: number;
  97074. /**
  97075. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97076. */
  97077. normalized: boolean;
  97078. /**
  97079. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97080. */
  97081. offset: number;
  97082. /**
  97083. * Name of the GLSL attribute, for debugging purpose only
  97084. */
  97085. attributeName: string;
  97086. }
  97087. }
  97088. declare module BABYLON {
  97089. interface ThinEngine {
  97090. /**
  97091. * Update a video texture
  97092. * @param texture defines the texture to update
  97093. * @param video defines the video element to use
  97094. * @param invertY defines if data must be stored with Y axis inverted
  97095. */
  97096. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97097. }
  97098. }
  97099. declare module BABYLON {
  97100. /**
  97101. * Settings for finer control over video usage
  97102. */
  97103. export interface VideoTextureSettings {
  97104. /**
  97105. * Applies `autoplay` to video, if specified
  97106. */
  97107. autoPlay?: boolean;
  97108. /**
  97109. * Applies `loop` to video, if specified
  97110. */
  97111. loop?: boolean;
  97112. /**
  97113. * Automatically updates internal texture from video at every frame in the render loop
  97114. */
  97115. autoUpdateTexture: boolean;
  97116. /**
  97117. * Image src displayed during the video loading or until the user interacts with the video.
  97118. */
  97119. poster?: string;
  97120. }
  97121. /**
  97122. * If you want to display a video in your scene, this is the special texture for that.
  97123. * This special texture works similar to other textures, with the exception of a few parameters.
  97124. * @see https://doc.babylonjs.com/how_to/video_texture
  97125. */
  97126. export class VideoTexture extends Texture {
  97127. /**
  97128. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97129. */
  97130. readonly autoUpdateTexture: boolean;
  97131. /**
  97132. * The video instance used by the texture internally
  97133. */
  97134. readonly video: HTMLVideoElement;
  97135. private _onUserActionRequestedObservable;
  97136. /**
  97137. * Event triggerd when a dom action is required by the user to play the video.
  97138. * This happens due to recent changes in browser policies preventing video to auto start.
  97139. */
  97140. readonly onUserActionRequestedObservable: Observable<Texture>;
  97141. private _generateMipMaps;
  97142. private _engine;
  97143. private _stillImageCaptured;
  97144. private _displayingPosterTexture;
  97145. private _settings;
  97146. private _createInternalTextureOnEvent;
  97147. private _frameId;
  97148. /**
  97149. * Creates a video texture.
  97150. * If you want to display a video in your scene, this is the special texture for that.
  97151. * This special texture works similar to other textures, with the exception of a few parameters.
  97152. * @see https://doc.babylonjs.com/how_to/video_texture
  97153. * @param name optional name, will detect from video source, if not defined
  97154. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97155. * @param scene is obviously the current scene.
  97156. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97157. * @param invertY is false by default but can be used to invert video on Y axis
  97158. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97159. * @param settings allows finer control over video usage
  97160. */
  97161. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97162. private _getName;
  97163. private _getVideo;
  97164. private _createInternalTexture;
  97165. private reset;
  97166. /**
  97167. * @hidden Internal method to initiate `update`.
  97168. */
  97169. _rebuild(): void;
  97170. /**
  97171. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97172. */
  97173. update(): void;
  97174. /**
  97175. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97176. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97177. */
  97178. updateTexture(isVisible: boolean): void;
  97179. protected _updateInternalTexture: () => void;
  97180. /**
  97181. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97182. * @param url New url.
  97183. */
  97184. updateURL(url: string): void;
  97185. /**
  97186. * Dispose the texture and release its associated resources.
  97187. */
  97188. dispose(): void;
  97189. /**
  97190. * Creates a video texture straight from a stream.
  97191. * @param scene Define the scene the texture should be created in
  97192. * @param stream Define the stream the texture should be created from
  97193. * @returns The created video texture as a promise
  97194. */
  97195. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97196. /**
  97197. * Creates a video texture straight from your WebCam video feed.
  97198. * @param scene Define the scene the texture should be created in
  97199. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97200. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97201. * @returns The created video texture as a promise
  97202. */
  97203. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97204. minWidth: number;
  97205. maxWidth: number;
  97206. minHeight: number;
  97207. maxHeight: number;
  97208. deviceId: string;
  97209. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97210. /**
  97211. * Creates a video texture straight from your WebCam video feed.
  97212. * @param scene Define the scene the texture should be created in
  97213. * @param onReady Define a callback to triggered once the texture will be ready
  97214. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97215. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97216. */
  97217. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97218. minWidth: number;
  97219. maxWidth: number;
  97220. minHeight: number;
  97221. maxHeight: number;
  97222. deviceId: string;
  97223. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97224. }
  97225. }
  97226. declare module BABYLON {
  97227. /**
  97228. * Defines the interface used by objects working like Scene
  97229. * @hidden
  97230. */
  97231. interface ISceneLike {
  97232. _addPendingData(data: any): void;
  97233. _removePendingData(data: any): void;
  97234. offlineProvider: IOfflineProvider;
  97235. }
  97236. /** Interface defining initialization parameters for Engine class */
  97237. export interface EngineOptions extends WebGLContextAttributes {
  97238. /**
  97239. * Defines if the engine should no exceed a specified device ratio
  97240. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97241. */
  97242. limitDeviceRatio?: number;
  97243. /**
  97244. * Defines if webvr should be enabled automatically
  97245. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97246. */
  97247. autoEnableWebVR?: boolean;
  97248. /**
  97249. * Defines if webgl2 should be turned off even if supported
  97250. * @see http://doc.babylonjs.com/features/webgl2
  97251. */
  97252. disableWebGL2Support?: boolean;
  97253. /**
  97254. * Defines if webaudio should be initialized as well
  97255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97256. */
  97257. audioEngine?: boolean;
  97258. /**
  97259. * Defines if animations should run using a deterministic lock step
  97260. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97261. */
  97262. deterministicLockstep?: boolean;
  97263. /** Defines the maximum steps to use with deterministic lock step mode */
  97264. lockstepMaxSteps?: number;
  97265. /**
  97266. * Defines that engine should ignore context lost events
  97267. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97268. */
  97269. doNotHandleContextLost?: boolean;
  97270. /**
  97271. * Defines that engine should ignore modifying touch action attribute and style
  97272. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97273. */
  97274. doNotHandleTouchAction?: boolean;
  97275. /**
  97276. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97277. */
  97278. useHighPrecisionFloats?: boolean;
  97279. }
  97280. /**
  97281. * The base engine class (root of all engines)
  97282. */
  97283. export class ThinEngine {
  97284. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97285. static ExceptionList: ({
  97286. key: string;
  97287. capture: string;
  97288. captureConstraint: number;
  97289. targets: string[];
  97290. } | {
  97291. key: string;
  97292. capture: null;
  97293. captureConstraint: null;
  97294. targets: string[];
  97295. })[];
  97296. /** @hidden */
  97297. static _TextureLoaders: IInternalTextureLoader[];
  97298. /**
  97299. * Returns the current npm package of the sdk
  97300. */
  97301. static readonly NpmPackage: string;
  97302. /**
  97303. * Returns the current version of the framework
  97304. */
  97305. static readonly Version: string;
  97306. /**
  97307. * Returns a string describing the current engine
  97308. */
  97309. readonly description: string;
  97310. /**
  97311. * Gets or sets the epsilon value used by collision engine
  97312. */
  97313. static CollisionsEpsilon: number;
  97314. /**
  97315. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97316. */
  97317. static ShadersRepository: string;
  97318. /** @hidden */
  97319. _shaderProcessor: IShaderProcessor;
  97320. /**
  97321. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97322. */
  97323. forcePOTTextures: boolean;
  97324. /**
  97325. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97326. */
  97327. isFullscreen: boolean;
  97328. /**
  97329. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97330. */
  97331. cullBackFaces: boolean;
  97332. /**
  97333. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97334. */
  97335. renderEvenInBackground: boolean;
  97336. /**
  97337. * Gets or sets a boolean indicating that cache can be kept between frames
  97338. */
  97339. preventCacheWipeBetweenFrames: boolean;
  97340. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97341. validateShaderPrograms: boolean;
  97342. /**
  97343. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97344. */
  97345. disableUniformBuffers: boolean;
  97346. /** @hidden */
  97347. _uniformBuffers: UniformBuffer[];
  97348. /**
  97349. * Gets a boolean indicating that the engine supports uniform buffers
  97350. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97351. */
  97352. readonly supportsUniformBuffers: boolean;
  97353. /** @hidden */
  97354. _gl: WebGLRenderingContext;
  97355. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97356. protected _windowIsBackground: boolean;
  97357. protected _webGLVersion: number;
  97358. protected _creationOptions: EngineOptions;
  97359. protected _highPrecisionShadersAllowed: boolean;
  97360. /** @hidden */
  97361. readonly _shouldUseHighPrecisionShader: boolean;
  97362. /**
  97363. * Gets a boolean indicating that only power of 2 textures are supported
  97364. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97365. */
  97366. readonly needPOTTextures: boolean;
  97367. /** @hidden */
  97368. _badOS: boolean;
  97369. /** @hidden */
  97370. _badDesktopOS: boolean;
  97371. private _hardwareScalingLevel;
  97372. /** @hidden */
  97373. _caps: EngineCapabilities;
  97374. private _isStencilEnable;
  97375. protected _colorWrite: boolean;
  97376. private _glVersion;
  97377. private _glRenderer;
  97378. private _glVendor;
  97379. /** @hidden */
  97380. _videoTextureSupported: boolean;
  97381. protected _renderingQueueLaunched: boolean;
  97382. protected _activeRenderLoops: (() => void)[];
  97383. /**
  97384. * Observable signaled when a context lost event is raised
  97385. */
  97386. onContextLostObservable: Observable<ThinEngine>;
  97387. /**
  97388. * Observable signaled when a context restored event is raised
  97389. */
  97390. onContextRestoredObservable: Observable<ThinEngine>;
  97391. private _onContextLost;
  97392. private _onContextRestored;
  97393. protected _contextWasLost: boolean;
  97394. /** @hidden */
  97395. _doNotHandleContextLost: boolean;
  97396. /**
  97397. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97399. */
  97400. doNotHandleContextLost: boolean;
  97401. /**
  97402. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97403. */
  97404. disableVertexArrayObjects: boolean;
  97405. /** @hidden */
  97406. protected _depthCullingState: DepthCullingState;
  97407. /** @hidden */
  97408. protected _stencilState: StencilState;
  97409. /** @hidden */
  97410. protected _alphaState: AlphaState;
  97411. /** @hidden */
  97412. _internalTexturesCache: InternalTexture[];
  97413. /** @hidden */
  97414. protected _activeChannel: number;
  97415. private _currentTextureChannel;
  97416. /** @hidden */
  97417. protected _boundTexturesCache: {
  97418. [key: string]: Nullable<InternalTexture>;
  97419. };
  97420. /** @hidden */
  97421. protected _currentEffect: Nullable<Effect>;
  97422. /** @hidden */
  97423. protected _currentProgram: Nullable<WebGLProgram>;
  97424. private _compiledEffects;
  97425. private _vertexAttribArraysEnabled;
  97426. /** @hidden */
  97427. protected _cachedViewport: Nullable<IViewportLike>;
  97428. private _cachedVertexArrayObject;
  97429. /** @hidden */
  97430. protected _cachedVertexBuffers: any;
  97431. /** @hidden */
  97432. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97433. /** @hidden */
  97434. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97435. /** @hidden */
  97436. _currentRenderTarget: Nullable<InternalTexture>;
  97437. private _uintIndicesCurrentlySet;
  97438. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97439. /** @hidden */
  97440. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97441. private _currentBufferPointers;
  97442. private _currentInstanceLocations;
  97443. private _currentInstanceBuffers;
  97444. private _textureUnits;
  97445. /** @hidden */
  97446. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97447. /** @hidden */
  97448. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97449. /** @hidden */
  97450. _boundRenderFunction: any;
  97451. private _vaoRecordInProgress;
  97452. private _mustWipeVertexAttributes;
  97453. private _emptyTexture;
  97454. private _emptyCubeTexture;
  97455. private _emptyTexture3D;
  97456. private _emptyTexture2DArray;
  97457. /** @hidden */
  97458. _frameHandler: number;
  97459. private _nextFreeTextureSlots;
  97460. private _maxSimultaneousTextures;
  97461. private _activeRequests;
  97462. protected _texturesSupported: string[];
  97463. /** @hidden */
  97464. _textureFormatInUse: Nullable<string>;
  97465. protected readonly _supportsHardwareTextureRescaling: boolean;
  97466. /**
  97467. * Gets the list of texture formats supported
  97468. */
  97469. readonly texturesSupported: Array<string>;
  97470. /**
  97471. * Gets the list of texture formats in use
  97472. */
  97473. readonly textureFormatInUse: Nullable<string>;
  97474. /**
  97475. * Gets the current viewport
  97476. */
  97477. readonly currentViewport: Nullable<IViewportLike>;
  97478. /**
  97479. * Gets the default empty texture
  97480. */
  97481. readonly emptyTexture: InternalTexture;
  97482. /**
  97483. * Gets the default empty 3D texture
  97484. */
  97485. readonly emptyTexture3D: InternalTexture;
  97486. /**
  97487. * Gets the default empty 2D array texture
  97488. */
  97489. readonly emptyTexture2DArray: InternalTexture;
  97490. /**
  97491. * Gets the default empty cube texture
  97492. */
  97493. readonly emptyCubeTexture: InternalTexture;
  97494. /**
  97495. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97496. */
  97497. readonly premultipliedAlpha: boolean;
  97498. /**
  97499. * Observable event triggered before each texture is initialized
  97500. */
  97501. onBeforeTextureInitObservable: Observable<Texture>;
  97502. /**
  97503. * Creates a new engine
  97504. * @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
  97505. * @param antialias defines enable antialiasing (default: false)
  97506. * @param options defines further options to be sent to the getContext() function
  97507. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97508. */
  97509. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97510. private _rebuildInternalTextures;
  97511. private _rebuildEffects;
  97512. /**
  97513. * Gets a boolean indicating if all created effects are ready
  97514. * @returns true if all effects are ready
  97515. */
  97516. areAllEffectsReady(): boolean;
  97517. protected _rebuildBuffers(): void;
  97518. private _initGLContext;
  97519. /**
  97520. * Gets version of the current webGL context
  97521. */
  97522. readonly webGLVersion: number;
  97523. /**
  97524. * Gets a string idenfifying the name of the class
  97525. * @returns "Engine" string
  97526. */
  97527. getClassName(): string;
  97528. /**
  97529. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97530. */
  97531. readonly isStencilEnable: boolean;
  97532. /** @hidden */
  97533. _prepareWorkingCanvas(): void;
  97534. /**
  97535. * Reset the texture cache to empty state
  97536. */
  97537. resetTextureCache(): void;
  97538. /**
  97539. * Gets an object containing information about the current webGL context
  97540. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97541. */
  97542. getGlInfo(): {
  97543. vendor: string;
  97544. renderer: string;
  97545. version: string;
  97546. };
  97547. /**
  97548. * Defines the hardware scaling level.
  97549. * By default the hardware scaling level is computed from the window device ratio.
  97550. * 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.
  97551. * @param level defines the level to use
  97552. */
  97553. setHardwareScalingLevel(level: number): void;
  97554. /**
  97555. * Gets the current hardware scaling level.
  97556. * By default the hardware scaling level is computed from the window device ratio.
  97557. * 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.
  97558. * @returns a number indicating the current hardware scaling level
  97559. */
  97560. getHardwareScalingLevel(): number;
  97561. /**
  97562. * Gets the list of loaded textures
  97563. * @returns an array containing all loaded textures
  97564. */
  97565. getLoadedTexturesCache(): InternalTexture[];
  97566. /**
  97567. * Gets the object containing all engine capabilities
  97568. * @returns the EngineCapabilities object
  97569. */
  97570. getCaps(): EngineCapabilities;
  97571. /**
  97572. * stop executing a render loop function and remove it from the execution array
  97573. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97574. */
  97575. stopRenderLoop(renderFunction?: () => void): void;
  97576. /** @hidden */
  97577. _renderLoop(): void;
  97578. /**
  97579. * Gets the HTML canvas attached with the current webGL context
  97580. * @returns a HTML canvas
  97581. */
  97582. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97583. /**
  97584. * Gets host window
  97585. * @returns the host window object
  97586. */
  97587. getHostWindow(): Nullable<Window>;
  97588. /**
  97589. * Gets the current render width
  97590. * @param useScreen defines if screen size must be used (or the current render target if any)
  97591. * @returns a number defining the current render width
  97592. */
  97593. getRenderWidth(useScreen?: boolean): number;
  97594. /**
  97595. * Gets the current render height
  97596. * @param useScreen defines if screen size must be used (or the current render target if any)
  97597. * @returns a number defining the current render height
  97598. */
  97599. getRenderHeight(useScreen?: boolean): number;
  97600. /**
  97601. * Can be used to override the current requestAnimationFrame requester.
  97602. * @hidden
  97603. */
  97604. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97605. /**
  97606. * Register and execute a render loop. The engine can have more than one render function
  97607. * @param renderFunction defines the function to continuously execute
  97608. */
  97609. runRenderLoop(renderFunction: () => void): void;
  97610. /**
  97611. * Clear the current render buffer or the current render target (if any is set up)
  97612. * @param color defines the color to use
  97613. * @param backBuffer defines if the back buffer must be cleared
  97614. * @param depth defines if the depth buffer must be cleared
  97615. * @param stencil defines if the stencil buffer must be cleared
  97616. */
  97617. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97618. private _viewportCached;
  97619. /** @hidden */
  97620. _viewport(x: number, y: number, width: number, height: number): void;
  97621. /**
  97622. * Set the WebGL's viewport
  97623. * @param viewport defines the viewport element to be used
  97624. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97625. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97626. */
  97627. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97628. /**
  97629. * Begin a new frame
  97630. */
  97631. beginFrame(): void;
  97632. /**
  97633. * Enf the current frame
  97634. */
  97635. endFrame(): void;
  97636. /**
  97637. * Resize the view according to the canvas' size
  97638. */
  97639. resize(): void;
  97640. /**
  97641. * Force a specific size of the canvas
  97642. * @param width defines the new canvas' width
  97643. * @param height defines the new canvas' height
  97644. */
  97645. setSize(width: number, height: number): void;
  97646. /**
  97647. * Binds the frame buffer to the specified texture.
  97648. * @param texture The texture to render to or null for the default canvas
  97649. * @param faceIndex The face of the texture to render to in case of cube texture
  97650. * @param requiredWidth The width of the target to render to
  97651. * @param requiredHeight The height of the target to render to
  97652. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97653. * @param depthStencilTexture The depth stencil texture to use to render
  97654. * @param lodLevel defines le lod level to bind to the frame buffer
  97655. */
  97656. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97657. /** @hidden */
  97658. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97659. /**
  97660. * Unbind the current render target texture from the webGL context
  97661. * @param texture defines the render target texture to unbind
  97662. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97663. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97664. */
  97665. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97666. /**
  97667. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97668. */
  97669. flushFramebuffer(): void;
  97670. /**
  97671. * Unbind the current render target and bind the default framebuffer
  97672. */
  97673. restoreDefaultFramebuffer(): void;
  97674. /** @hidden */
  97675. protected _resetVertexBufferBinding(): void;
  97676. /**
  97677. * Creates a vertex buffer
  97678. * @param data the data for the vertex buffer
  97679. * @returns the new WebGL static buffer
  97680. */
  97681. createVertexBuffer(data: DataArray): DataBuffer;
  97682. private _createVertexBuffer;
  97683. /**
  97684. * Creates a dynamic vertex buffer
  97685. * @param data the data for the dynamic vertex buffer
  97686. * @returns the new WebGL dynamic buffer
  97687. */
  97688. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97689. protected _resetIndexBufferBinding(): void;
  97690. /**
  97691. * Creates a new index buffer
  97692. * @param indices defines the content of the index buffer
  97693. * @param updatable defines if the index buffer must be updatable
  97694. * @returns a new webGL buffer
  97695. */
  97696. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97697. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97698. /**
  97699. * Bind a webGL buffer to the webGL context
  97700. * @param buffer defines the buffer to bind
  97701. */
  97702. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97703. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97704. private bindBuffer;
  97705. /**
  97706. * update the bound buffer with the given data
  97707. * @param data defines the data to update
  97708. */
  97709. updateArrayBuffer(data: Float32Array): void;
  97710. private _vertexAttribPointer;
  97711. private _bindIndexBufferWithCache;
  97712. private _bindVertexBuffersAttributes;
  97713. /**
  97714. * Records a vertex array object
  97715. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97716. * @param vertexBuffers defines the list of vertex buffers to store
  97717. * @param indexBuffer defines the index buffer to store
  97718. * @param effect defines the effect to store
  97719. * @returns the new vertex array object
  97720. */
  97721. recordVertexArrayObject(vertexBuffers: {
  97722. [key: string]: VertexBuffer;
  97723. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97724. /**
  97725. * Bind a specific vertex array object
  97726. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97727. * @param vertexArrayObject defines the vertex array object to bind
  97728. * @param indexBuffer defines the index buffer to bind
  97729. */
  97730. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97731. /**
  97732. * Bind webGl buffers directly to the webGL context
  97733. * @param vertexBuffer defines the vertex buffer to bind
  97734. * @param indexBuffer defines the index buffer to bind
  97735. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97736. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97737. * @param effect defines the effect associated with the vertex buffer
  97738. */
  97739. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97740. private _unbindVertexArrayObject;
  97741. /**
  97742. * Bind a list of vertex buffers to the webGL context
  97743. * @param vertexBuffers defines the list of vertex buffers to bind
  97744. * @param indexBuffer defines the index buffer to bind
  97745. * @param effect defines the effect associated with the vertex buffers
  97746. */
  97747. bindBuffers(vertexBuffers: {
  97748. [key: string]: Nullable<VertexBuffer>;
  97749. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97750. /**
  97751. * Unbind all instance attributes
  97752. */
  97753. unbindInstanceAttributes(): void;
  97754. /**
  97755. * Release and free the memory of a vertex array object
  97756. * @param vao defines the vertex array object to delete
  97757. */
  97758. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97759. /** @hidden */
  97760. _releaseBuffer(buffer: DataBuffer): boolean;
  97761. protected _deleteBuffer(buffer: DataBuffer): void;
  97762. /**
  97763. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97764. * @param instancesBuffer defines the webGL buffer to update and bind
  97765. * @param data defines the data to store in the buffer
  97766. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97767. */
  97768. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97769. /**
  97770. * Apply all cached states (depth, culling, stencil and alpha)
  97771. */
  97772. applyStates(): void;
  97773. /**
  97774. * Send a draw order
  97775. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97776. * @param indexStart defines the starting index
  97777. * @param indexCount defines the number of index to draw
  97778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97779. */
  97780. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97781. /**
  97782. * Draw a list of points
  97783. * @param verticesStart defines the index of first vertex to draw
  97784. * @param verticesCount defines the count of vertices to draw
  97785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97786. */
  97787. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97788. /**
  97789. * Draw a list of unindexed primitives
  97790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97791. * @param verticesStart defines the index of first vertex to draw
  97792. * @param verticesCount defines the count of vertices to draw
  97793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97794. */
  97795. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97796. /**
  97797. * Draw a list of indexed primitives
  97798. * @param fillMode defines the primitive to use
  97799. * @param indexStart defines the starting index
  97800. * @param indexCount defines the number of index to draw
  97801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97802. */
  97803. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97804. /**
  97805. * Draw a list of unindexed primitives
  97806. * @param fillMode defines the primitive to use
  97807. * @param verticesStart defines the index of first vertex to draw
  97808. * @param verticesCount defines the count of vertices to draw
  97809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97810. */
  97811. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97812. private _drawMode;
  97813. /** @hidden */
  97814. protected _reportDrawCall(): void;
  97815. /** @hidden */
  97816. _releaseEffect(effect: Effect): void;
  97817. /** @hidden */
  97818. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97819. /**
  97820. * Create a new effect (used to store vertex/fragment shaders)
  97821. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97822. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97823. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97824. * @param samplers defines an array of string used to represent textures
  97825. * @param defines defines the string containing the defines to use to compile the shaders
  97826. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97827. * @param onCompiled defines a function to call when the effect creation is successful
  97828. * @param onError defines a function to call when the effect creation has failed
  97829. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97830. * @returns the new Effect
  97831. */
  97832. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  97833. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97834. private _compileShader;
  97835. private _compileRawShader;
  97836. /**
  97837. * Directly creates a webGL program
  97838. * @param pipelineContext defines the pipeline context to attach to
  97839. * @param vertexCode defines the vertex shader code to use
  97840. * @param fragmentCode defines the fragment shader code to use
  97841. * @param context defines the webGL context to use (if not set, the current one will be used)
  97842. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97843. * @returns the new webGL program
  97844. */
  97845. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97846. /**
  97847. * Creates a webGL program
  97848. * @param pipelineContext defines the pipeline context to attach to
  97849. * @param vertexCode defines the vertex shader code to use
  97850. * @param fragmentCode defines the fragment shader code to use
  97851. * @param defines defines the string containing the defines to use to compile the shaders
  97852. * @param context defines the webGL context to use (if not set, the current one will be used)
  97853. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97854. * @returns the new webGL program
  97855. */
  97856. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97857. /**
  97858. * Creates a new pipeline context
  97859. * @returns the new pipeline
  97860. */
  97861. createPipelineContext(): IPipelineContext;
  97862. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97863. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97864. /** @hidden */
  97865. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97866. /** @hidden */
  97867. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97868. /** @hidden */
  97869. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97870. /**
  97871. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97872. * @param pipelineContext defines the pipeline context to use
  97873. * @param uniformsNames defines the list of uniform names
  97874. * @returns an array of webGL uniform locations
  97875. */
  97876. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97877. /**
  97878. * Gets the lsit of active attributes for a given webGL program
  97879. * @param pipelineContext defines the pipeline context to use
  97880. * @param attributesNames defines the list of attribute names to get
  97881. * @returns an array of indices indicating the offset of each attribute
  97882. */
  97883. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97884. /**
  97885. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97886. * @param effect defines the effect to activate
  97887. */
  97888. enableEffect(effect: Nullable<Effect>): void;
  97889. /**
  97890. * Set the value of an uniform to a number (int)
  97891. * @param uniform defines the webGL uniform location where to store the value
  97892. * @param value defines the int number to store
  97893. */
  97894. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97895. /**
  97896. * Set the value of an uniform to an array of int32
  97897. * @param uniform defines the webGL uniform location where to store the value
  97898. * @param array defines the array of int32 to store
  97899. */
  97900. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97901. /**
  97902. * Set the value of an uniform to an array of int32 (stored as vec2)
  97903. * @param uniform defines the webGL uniform location where to store the value
  97904. * @param array defines the array of int32 to store
  97905. */
  97906. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97907. /**
  97908. * Set the value of an uniform to an array of int32 (stored as vec3)
  97909. * @param uniform defines the webGL uniform location where to store the value
  97910. * @param array defines the array of int32 to store
  97911. */
  97912. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97913. /**
  97914. * Set the value of an uniform to an array of int32 (stored as vec4)
  97915. * @param uniform defines the webGL uniform location where to store the value
  97916. * @param array defines the array of int32 to store
  97917. */
  97918. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97919. /**
  97920. * Set the value of an uniform to an array of number
  97921. * @param uniform defines the webGL uniform location where to store the value
  97922. * @param array defines the array of number to store
  97923. */
  97924. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97925. /**
  97926. * Set the value of an uniform to an array of number (stored as vec2)
  97927. * @param uniform defines the webGL uniform location where to store the value
  97928. * @param array defines the array of number to store
  97929. */
  97930. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97931. /**
  97932. * Set the value of an uniform to an array of number (stored as vec3)
  97933. * @param uniform defines the webGL uniform location where to store the value
  97934. * @param array defines the array of number to store
  97935. */
  97936. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97937. /**
  97938. * Set the value of an uniform to an array of number (stored as vec4)
  97939. * @param uniform defines the webGL uniform location where to store the value
  97940. * @param array defines the array of number to store
  97941. */
  97942. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97943. /**
  97944. * Set the value of an uniform to an array of float32 (stored as matrices)
  97945. * @param uniform defines the webGL uniform location where to store the value
  97946. * @param matrices defines the array of float32 to store
  97947. */
  97948. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97949. /**
  97950. * Set the value of an uniform to a matrix (3x3)
  97951. * @param uniform defines the webGL uniform location where to store the value
  97952. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97953. */
  97954. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97955. /**
  97956. * Set the value of an uniform to a matrix (2x2)
  97957. * @param uniform defines the webGL uniform location where to store the value
  97958. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97959. */
  97960. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97961. /**
  97962. * Set the value of an uniform to a number (float)
  97963. * @param uniform defines the webGL uniform location where to store the value
  97964. * @param value defines the float number to store
  97965. */
  97966. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97967. /**
  97968. * Set the value of an uniform to a vec2
  97969. * @param uniform defines the webGL uniform location where to store the value
  97970. * @param x defines the 1st component of the value
  97971. * @param y defines the 2nd component of the value
  97972. */
  97973. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97974. /**
  97975. * Set the value of an uniform to a vec3
  97976. * @param uniform defines the webGL uniform location where to store the value
  97977. * @param x defines the 1st component of the value
  97978. * @param y defines the 2nd component of the value
  97979. * @param z defines the 3rd component of the value
  97980. */
  97981. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97982. /**
  97983. * Set the value of an uniform to a vec4
  97984. * @param uniform defines the webGL uniform location where to store the value
  97985. * @param x defines the 1st component of the value
  97986. * @param y defines the 2nd component of the value
  97987. * @param z defines the 3rd component of the value
  97988. * @param w defines the 4th component of the value
  97989. */
  97990. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97991. /**
  97992. * Gets the depth culling state manager
  97993. */
  97994. readonly depthCullingState: DepthCullingState;
  97995. /**
  97996. * Gets the alpha state manager
  97997. */
  97998. readonly alphaState: AlphaState;
  97999. /**
  98000. * Gets the stencil state manager
  98001. */
  98002. readonly stencilState: StencilState;
  98003. /**
  98004. * Clears the list of texture accessible through engine.
  98005. * This can help preventing texture load conflict due to name collision.
  98006. */
  98007. clearInternalTexturesCache(): void;
  98008. /**
  98009. * Force the entire cache to be cleared
  98010. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98011. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98012. */
  98013. wipeCaches(bruteForce?: boolean): void;
  98014. /** @hidden */
  98015. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98016. min: number;
  98017. mag: number;
  98018. };
  98019. /** @hidden */
  98020. _createTexture(): WebGLTexture;
  98021. /**
  98022. * Usually called from Texture.ts.
  98023. * Passed information to create a WebGLTexture
  98024. * @param urlArg defines a value which contains one of the following:
  98025. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98026. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98027. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98028. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98029. * @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)
  98030. * @param scene needed for loading to the correct scene
  98031. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98032. * @param onLoad optional callback to be called upon successful completion
  98033. * @param onError optional callback to be called upon failure
  98034. * @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
  98035. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98036. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98037. * @param forcedExtension defines the extension to use to pick the right loader
  98038. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98039. * @param mimeType defines an optional mime type
  98040. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98041. */
  98042. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  98043. /**
  98044. * @hidden
  98045. */
  98046. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98047. /**
  98048. * Creates a raw texture
  98049. * @param data defines the data to store in the texture
  98050. * @param width defines the width of the texture
  98051. * @param height defines the height of the texture
  98052. * @param format defines the format of the data
  98053. * @param generateMipMaps defines if the engine should generate the mip levels
  98054. * @param invertY defines if data must be stored with Y axis inverted
  98055. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98056. * @param compression defines the compression used (null by default)
  98057. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98058. * @returns the raw texture inside an InternalTexture
  98059. */
  98060. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98061. /**
  98062. * Creates a new raw cube texture
  98063. * @param data defines the array of data to use to create each face
  98064. * @param size defines the size of the textures
  98065. * @param format defines the format of the data
  98066. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98067. * @param generateMipMaps defines if the engine should generate the mip levels
  98068. * @param invertY defines if data must be stored with Y axis inverted
  98069. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98070. * @param compression defines the compression used (null by default)
  98071. * @returns the cube texture as an InternalTexture
  98072. */
  98073. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98074. /**
  98075. * Creates a new raw 3D texture
  98076. * @param data defines the data used to create the texture
  98077. * @param width defines the width of the texture
  98078. * @param height defines the height of the texture
  98079. * @param depth defines the depth of the texture
  98080. * @param format defines the format of the texture
  98081. * @param generateMipMaps defines if the engine must generate mip levels
  98082. * @param invertY defines if data must be stored with Y axis inverted
  98083. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98084. * @param compression defines the compressed used (can be null)
  98085. * @param textureType defines the compressed used (can be null)
  98086. * @returns a new raw 3D texture (stored in an InternalTexture)
  98087. */
  98088. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98089. /**
  98090. * Creates a new raw 2D array texture
  98091. * @param data defines the data used to create the texture
  98092. * @param width defines the width of the texture
  98093. * @param height defines the height of the texture
  98094. * @param depth defines the number of layers of the texture
  98095. * @param format defines the format of the texture
  98096. * @param generateMipMaps defines if the engine must generate mip levels
  98097. * @param invertY defines if data must be stored with Y axis inverted
  98098. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98099. * @param compression defines the compressed used (can be null)
  98100. * @param textureType defines the compressed used (can be null)
  98101. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98102. */
  98103. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98104. private _unpackFlipYCached;
  98105. /**
  98106. * In case you are sharing the context with other applications, it might
  98107. * be interested to not cache the unpack flip y state to ensure a consistent
  98108. * value would be set.
  98109. */
  98110. enableUnpackFlipYCached: boolean;
  98111. /** @hidden */
  98112. _unpackFlipY(value: boolean): void;
  98113. /** @hidden */
  98114. _getUnpackAlignement(): number;
  98115. /**
  98116. * Update the sampling mode of a given texture
  98117. * @param samplingMode defines the required sampling mode
  98118. * @param texture defines the texture to update
  98119. */
  98120. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98121. /** @hidden */
  98122. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98123. width: number;
  98124. height: number;
  98125. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98126. /** @hidden */
  98127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98128. /** @hidden */
  98129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98130. /** @hidden */
  98131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98132. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98133. private _prepareWebGLTexture;
  98134. /** @hidden */
  98135. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98136. /** @hidden */
  98137. _releaseFramebufferObjects(texture: InternalTexture): void;
  98138. /** @hidden */
  98139. _releaseTexture(texture: InternalTexture): void;
  98140. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98141. protected _setProgram(program: WebGLProgram): void;
  98142. protected _boundUniforms: {
  98143. [key: number]: WebGLUniformLocation;
  98144. };
  98145. /**
  98146. * Binds an effect to the webGL context
  98147. * @param effect defines the effect to bind
  98148. */
  98149. bindSamplers(effect: Effect): void;
  98150. private _activateCurrentTexture;
  98151. /** @hidden */
  98152. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98153. /** @hidden */
  98154. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98155. /**
  98156. * Unbind all textures from the webGL context
  98157. */
  98158. unbindAllTextures(): void;
  98159. /**
  98160. * Sets a texture to the according uniform.
  98161. * @param channel The texture channel
  98162. * @param uniform The uniform to set
  98163. * @param texture The texture to apply
  98164. */
  98165. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98166. private _bindSamplerUniformToChannel;
  98167. private _getTextureWrapMode;
  98168. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98169. /**
  98170. * Sets an array of texture to the webGL context
  98171. * @param channel defines the channel where the texture array must be set
  98172. * @param uniform defines the associated uniform location
  98173. * @param textures defines the array of textures to bind
  98174. */
  98175. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98176. /** @hidden */
  98177. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98178. private _setTextureParameterFloat;
  98179. private _setTextureParameterInteger;
  98180. /**
  98181. * Unbind all vertex attributes from the webGL context
  98182. */
  98183. unbindAllAttributes(): void;
  98184. /**
  98185. * 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
  98186. */
  98187. releaseEffects(): void;
  98188. /**
  98189. * Dispose and release all associated resources
  98190. */
  98191. dispose(): void;
  98192. /**
  98193. * Attach a new callback raised when context lost event is fired
  98194. * @param callback defines the callback to call
  98195. */
  98196. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98197. /**
  98198. * Attach a new callback raised when context restored event is fired
  98199. * @param callback defines the callback to call
  98200. */
  98201. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98202. /**
  98203. * Get the current error code of the webGL context
  98204. * @returns the error code
  98205. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98206. */
  98207. getError(): number;
  98208. private _canRenderToFloatFramebuffer;
  98209. private _canRenderToHalfFloatFramebuffer;
  98210. private _canRenderToFramebuffer;
  98211. /** @hidden */
  98212. _getWebGLTextureType(type: number): number;
  98213. /** @hidden */
  98214. _getInternalFormat(format: number): number;
  98215. /** @hidden */
  98216. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98217. /** @hidden */
  98218. _getRGBAMultiSampleBufferFormat(type: number): number;
  98219. /** @hidden */
  98220. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  98221. /**
  98222. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98223. * @returns true if the engine can be created
  98224. * @ignorenaming
  98225. */
  98226. static isSupported(): boolean;
  98227. /**
  98228. * Find the next highest power of two.
  98229. * @param x Number to start search from.
  98230. * @return Next highest power of two.
  98231. */
  98232. static CeilingPOT(x: number): number;
  98233. /**
  98234. * Find the next lowest power of two.
  98235. * @param x Number to start search from.
  98236. * @return Next lowest power of two.
  98237. */
  98238. static FloorPOT(x: number): number;
  98239. /**
  98240. * Find the nearest power of two.
  98241. * @param x Number to start search from.
  98242. * @return Next nearest power of two.
  98243. */
  98244. static NearestPOT(x: number): number;
  98245. /**
  98246. * Get the closest exponent of two
  98247. * @param value defines the value to approximate
  98248. * @param max defines the maximum value to return
  98249. * @param mode defines how to define the closest value
  98250. * @returns closest exponent of two of the given value
  98251. */
  98252. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98253. /**
  98254. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98255. * @param func - the function to be called
  98256. * @param requester - the object that will request the next frame. Falls back to window.
  98257. * @returns frame number
  98258. */
  98259. static QueueNewFrame(func: () => void, requester?: any): number;
  98260. }
  98261. }
  98262. declare module BABYLON {
  98263. /**
  98264. * Class representing spherical harmonics coefficients to the 3rd degree
  98265. */
  98266. export class SphericalHarmonics {
  98267. /**
  98268. * Defines whether or not the harmonics have been prescaled for rendering.
  98269. */
  98270. preScaled: boolean;
  98271. /**
  98272. * The l0,0 coefficients of the spherical harmonics
  98273. */
  98274. l00: Vector3;
  98275. /**
  98276. * The l1,-1 coefficients of the spherical harmonics
  98277. */
  98278. l1_1: Vector3;
  98279. /**
  98280. * The l1,0 coefficients of the spherical harmonics
  98281. */
  98282. l10: Vector3;
  98283. /**
  98284. * The l1,1 coefficients of the spherical harmonics
  98285. */
  98286. l11: Vector3;
  98287. /**
  98288. * The l2,-2 coefficients of the spherical harmonics
  98289. */
  98290. l2_2: Vector3;
  98291. /**
  98292. * The l2,-1 coefficients of the spherical harmonics
  98293. */
  98294. l2_1: Vector3;
  98295. /**
  98296. * The l2,0 coefficients of the spherical harmonics
  98297. */
  98298. l20: Vector3;
  98299. /**
  98300. * The l2,1 coefficients of the spherical harmonics
  98301. */
  98302. l21: Vector3;
  98303. /**
  98304. * The l2,2 coefficients of the spherical harmonics
  98305. */
  98306. l22: Vector3;
  98307. /**
  98308. * Adds a light to the spherical harmonics
  98309. * @param direction the direction of the light
  98310. * @param color the color of the light
  98311. * @param deltaSolidAngle the delta solid angle of the light
  98312. */
  98313. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98314. /**
  98315. * Scales the spherical harmonics by the given amount
  98316. * @param scale the amount to scale
  98317. */
  98318. scaleInPlace(scale: number): void;
  98319. /**
  98320. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98321. *
  98322. * ```
  98323. * E_lm = A_l * L_lm
  98324. * ```
  98325. *
  98326. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98327. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98328. * the scaling factors are given in equation 9.
  98329. */
  98330. convertIncidentRadianceToIrradiance(): void;
  98331. /**
  98332. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98333. *
  98334. * ```
  98335. * L = (1/pi) * E * rho
  98336. * ```
  98337. *
  98338. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98339. */
  98340. convertIrradianceToLambertianRadiance(): void;
  98341. /**
  98342. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98343. * required operations at run time.
  98344. *
  98345. * This is simply done by scaling back the SH with Ylm constants parameter.
  98346. * The trigonometric part being applied by the shader at run time.
  98347. */
  98348. preScaleForRendering(): void;
  98349. /**
  98350. * Constructs a spherical harmonics from an array.
  98351. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98352. * @returns the spherical harmonics
  98353. */
  98354. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98355. /**
  98356. * Gets the spherical harmonics from polynomial
  98357. * @param polynomial the spherical polynomial
  98358. * @returns the spherical harmonics
  98359. */
  98360. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98361. }
  98362. /**
  98363. * Class representing spherical polynomial coefficients to the 3rd degree
  98364. */
  98365. export class SphericalPolynomial {
  98366. private _harmonics;
  98367. /**
  98368. * The spherical harmonics used to create the polynomials.
  98369. */
  98370. readonly preScaledHarmonics: SphericalHarmonics;
  98371. /**
  98372. * The x coefficients of the spherical polynomial
  98373. */
  98374. x: Vector3;
  98375. /**
  98376. * The y coefficients of the spherical polynomial
  98377. */
  98378. y: Vector3;
  98379. /**
  98380. * The z coefficients of the spherical polynomial
  98381. */
  98382. z: Vector3;
  98383. /**
  98384. * The xx coefficients of the spherical polynomial
  98385. */
  98386. xx: Vector3;
  98387. /**
  98388. * The yy coefficients of the spherical polynomial
  98389. */
  98390. yy: Vector3;
  98391. /**
  98392. * The zz coefficients of the spherical polynomial
  98393. */
  98394. zz: Vector3;
  98395. /**
  98396. * The xy coefficients of the spherical polynomial
  98397. */
  98398. xy: Vector3;
  98399. /**
  98400. * The yz coefficients of the spherical polynomial
  98401. */
  98402. yz: Vector3;
  98403. /**
  98404. * The zx coefficients of the spherical polynomial
  98405. */
  98406. zx: Vector3;
  98407. /**
  98408. * Adds an ambient color to the spherical polynomial
  98409. * @param color the color to add
  98410. */
  98411. addAmbient(color: Color3): void;
  98412. /**
  98413. * Scales the spherical polynomial by the given amount
  98414. * @param scale the amount to scale
  98415. */
  98416. scaleInPlace(scale: number): void;
  98417. /**
  98418. * Gets the spherical polynomial from harmonics
  98419. * @param harmonics the spherical harmonics
  98420. * @returns the spherical polynomial
  98421. */
  98422. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98423. /**
  98424. * Constructs a spherical polynomial from an array.
  98425. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98426. * @returns the spherical polynomial
  98427. */
  98428. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98429. }
  98430. }
  98431. declare module BABYLON {
  98432. /**
  98433. * Defines the source of the internal texture
  98434. */
  98435. export enum InternalTextureSource {
  98436. /**
  98437. * The source of the texture data is unknown
  98438. */
  98439. Unknown = 0,
  98440. /**
  98441. * Texture data comes from an URL
  98442. */
  98443. Url = 1,
  98444. /**
  98445. * Texture data is only used for temporary storage
  98446. */
  98447. Temp = 2,
  98448. /**
  98449. * Texture data comes from raw data (ArrayBuffer)
  98450. */
  98451. Raw = 3,
  98452. /**
  98453. * Texture content is dynamic (video or dynamic texture)
  98454. */
  98455. Dynamic = 4,
  98456. /**
  98457. * Texture content is generated by rendering to it
  98458. */
  98459. RenderTarget = 5,
  98460. /**
  98461. * Texture content is part of a multi render target process
  98462. */
  98463. MultiRenderTarget = 6,
  98464. /**
  98465. * Texture data comes from a cube data file
  98466. */
  98467. Cube = 7,
  98468. /**
  98469. * Texture data comes from a raw cube data
  98470. */
  98471. CubeRaw = 8,
  98472. /**
  98473. * Texture data come from a prefiltered cube data file
  98474. */
  98475. CubePrefiltered = 9,
  98476. /**
  98477. * Texture content is raw 3D data
  98478. */
  98479. Raw3D = 10,
  98480. /**
  98481. * Texture content is raw 2D array data
  98482. */
  98483. Raw2DArray = 11,
  98484. /**
  98485. * Texture content is a depth texture
  98486. */
  98487. Depth = 12,
  98488. /**
  98489. * Texture data comes from a raw cube data encoded with RGBD
  98490. */
  98491. CubeRawRGBD = 13
  98492. }
  98493. /**
  98494. * Class used to store data associated with WebGL texture data for the engine
  98495. * This class should not be used directly
  98496. */
  98497. export class InternalTexture {
  98498. /** @hidden */
  98499. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98500. /**
  98501. * Defines if the texture is ready
  98502. */
  98503. isReady: boolean;
  98504. /**
  98505. * Defines if the texture is a cube texture
  98506. */
  98507. isCube: boolean;
  98508. /**
  98509. * Defines if the texture contains 3D data
  98510. */
  98511. is3D: boolean;
  98512. /**
  98513. * Defines if the texture contains 2D array data
  98514. */
  98515. is2DArray: boolean;
  98516. /**
  98517. * Defines if the texture contains multiview data
  98518. */
  98519. isMultiview: boolean;
  98520. /**
  98521. * Gets the URL used to load this texture
  98522. */
  98523. url: string;
  98524. /**
  98525. * Gets the sampling mode of the texture
  98526. */
  98527. samplingMode: number;
  98528. /**
  98529. * Gets a boolean indicating if the texture needs mipmaps generation
  98530. */
  98531. generateMipMaps: boolean;
  98532. /**
  98533. * Gets the number of samples used by the texture (WebGL2+ only)
  98534. */
  98535. samples: number;
  98536. /**
  98537. * Gets the type of the texture (int, float...)
  98538. */
  98539. type: number;
  98540. /**
  98541. * Gets the format of the texture (RGB, RGBA...)
  98542. */
  98543. format: number;
  98544. /**
  98545. * Observable called when the texture is loaded
  98546. */
  98547. onLoadedObservable: Observable<InternalTexture>;
  98548. /**
  98549. * Gets the width of the texture
  98550. */
  98551. width: number;
  98552. /**
  98553. * Gets the height of the texture
  98554. */
  98555. height: number;
  98556. /**
  98557. * Gets the depth of the texture
  98558. */
  98559. depth: number;
  98560. /**
  98561. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98562. */
  98563. baseWidth: number;
  98564. /**
  98565. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98566. */
  98567. baseHeight: number;
  98568. /**
  98569. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98570. */
  98571. baseDepth: number;
  98572. /**
  98573. * Gets a boolean indicating if the texture is inverted on Y axis
  98574. */
  98575. invertY: boolean;
  98576. /** @hidden */
  98577. _invertVScale: boolean;
  98578. /** @hidden */
  98579. _associatedChannel: number;
  98580. /** @hidden */
  98581. _source: InternalTextureSource;
  98582. /** @hidden */
  98583. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98584. /** @hidden */
  98585. _bufferView: Nullable<ArrayBufferView>;
  98586. /** @hidden */
  98587. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98588. /** @hidden */
  98589. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98590. /** @hidden */
  98591. _size: number;
  98592. /** @hidden */
  98593. _extension: string;
  98594. /** @hidden */
  98595. _files: Nullable<string[]>;
  98596. /** @hidden */
  98597. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98598. /** @hidden */
  98599. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98600. /** @hidden */
  98601. _framebuffer: Nullable<WebGLFramebuffer>;
  98602. /** @hidden */
  98603. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98604. /** @hidden */
  98605. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98606. /** @hidden */
  98607. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98608. /** @hidden */
  98609. _attachments: Nullable<number[]>;
  98610. /** @hidden */
  98611. _cachedCoordinatesMode: Nullable<number>;
  98612. /** @hidden */
  98613. _cachedWrapU: Nullable<number>;
  98614. /** @hidden */
  98615. _cachedWrapV: Nullable<number>;
  98616. /** @hidden */
  98617. _cachedWrapR: Nullable<number>;
  98618. /** @hidden */
  98619. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98620. /** @hidden */
  98621. _isDisabled: boolean;
  98622. /** @hidden */
  98623. _compression: Nullable<string>;
  98624. /** @hidden */
  98625. _generateStencilBuffer: boolean;
  98626. /** @hidden */
  98627. _generateDepthBuffer: boolean;
  98628. /** @hidden */
  98629. _comparisonFunction: number;
  98630. /** @hidden */
  98631. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98632. /** @hidden */
  98633. _lodGenerationScale: number;
  98634. /** @hidden */
  98635. _lodGenerationOffset: number;
  98636. /** @hidden */
  98637. _colorTextureArray: Nullable<WebGLTexture>;
  98638. /** @hidden */
  98639. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98640. /** @hidden */
  98641. _lodTextureHigh: Nullable<BaseTexture>;
  98642. /** @hidden */
  98643. _lodTextureMid: Nullable<BaseTexture>;
  98644. /** @hidden */
  98645. _lodTextureLow: Nullable<BaseTexture>;
  98646. /** @hidden */
  98647. _isRGBD: boolean;
  98648. /** @hidden */
  98649. _linearSpecularLOD: boolean;
  98650. /** @hidden */
  98651. _irradianceTexture: Nullable<BaseTexture>;
  98652. /** @hidden */
  98653. _webGLTexture: Nullable<WebGLTexture>;
  98654. /** @hidden */
  98655. _references: number;
  98656. private _engine;
  98657. /**
  98658. * Gets the Engine the texture belongs to.
  98659. * @returns The babylon engine
  98660. */
  98661. getEngine(): ThinEngine;
  98662. /**
  98663. * Gets the data source type of the texture
  98664. */
  98665. readonly source: InternalTextureSource;
  98666. /**
  98667. * Creates a new InternalTexture
  98668. * @param engine defines the engine to use
  98669. * @param source defines the type of data that will be used
  98670. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98671. */
  98672. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98673. /**
  98674. * Increments the number of references (ie. the number of Texture that point to it)
  98675. */
  98676. incrementReferences(): void;
  98677. /**
  98678. * Change the size of the texture (not the size of the content)
  98679. * @param width defines the new width
  98680. * @param height defines the new height
  98681. * @param depth defines the new depth (1 by default)
  98682. */
  98683. updateSize(width: int, height: int, depth?: int): void;
  98684. /** @hidden */
  98685. _rebuild(): void;
  98686. /** @hidden */
  98687. _swapAndDie(target: InternalTexture): void;
  98688. /**
  98689. * Dispose the current allocated resources
  98690. */
  98691. dispose(): void;
  98692. }
  98693. }
  98694. declare module BABYLON {
  98695. /**
  98696. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98698. */
  98699. export class Analyser {
  98700. /**
  98701. * Gets or sets the smoothing
  98702. * @ignorenaming
  98703. */
  98704. SMOOTHING: number;
  98705. /**
  98706. * Gets or sets the FFT table size
  98707. * @ignorenaming
  98708. */
  98709. FFT_SIZE: number;
  98710. /**
  98711. * Gets or sets the bar graph amplitude
  98712. * @ignorenaming
  98713. */
  98714. BARGRAPHAMPLITUDE: number;
  98715. /**
  98716. * Gets or sets the position of the debug canvas
  98717. * @ignorenaming
  98718. */
  98719. DEBUGCANVASPOS: {
  98720. x: number;
  98721. y: number;
  98722. };
  98723. /**
  98724. * Gets or sets the debug canvas size
  98725. * @ignorenaming
  98726. */
  98727. DEBUGCANVASSIZE: {
  98728. width: number;
  98729. height: number;
  98730. };
  98731. private _byteFreqs;
  98732. private _byteTime;
  98733. private _floatFreqs;
  98734. private _webAudioAnalyser;
  98735. private _debugCanvas;
  98736. private _debugCanvasContext;
  98737. private _scene;
  98738. private _registerFunc;
  98739. private _audioEngine;
  98740. /**
  98741. * Creates a new analyser
  98742. * @param scene defines hosting scene
  98743. */
  98744. constructor(scene: Scene);
  98745. /**
  98746. * Get the number of data values you will have to play with for the visualization
  98747. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98748. * @returns a number
  98749. */
  98750. getFrequencyBinCount(): number;
  98751. /**
  98752. * Gets the current frequency data as a byte array
  98753. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98754. * @returns a Uint8Array
  98755. */
  98756. getByteFrequencyData(): Uint8Array;
  98757. /**
  98758. * Gets the current waveform as a byte array
  98759. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98760. * @returns a Uint8Array
  98761. */
  98762. getByteTimeDomainData(): Uint8Array;
  98763. /**
  98764. * Gets the current frequency data as a float array
  98765. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98766. * @returns a Float32Array
  98767. */
  98768. getFloatFrequencyData(): Float32Array;
  98769. /**
  98770. * Renders the debug canvas
  98771. */
  98772. drawDebugCanvas(): void;
  98773. /**
  98774. * Stops rendering the debug canvas and removes it
  98775. */
  98776. stopDebugCanvas(): void;
  98777. /**
  98778. * Connects two audio nodes
  98779. * @param inputAudioNode defines first node to connect
  98780. * @param outputAudioNode defines second node to connect
  98781. */
  98782. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98783. /**
  98784. * Releases all associated resources
  98785. */
  98786. dispose(): void;
  98787. }
  98788. }
  98789. declare module BABYLON {
  98790. /**
  98791. * This represents an audio engine and it is responsible
  98792. * to play, synchronize and analyse sounds throughout the application.
  98793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98794. */
  98795. export interface IAudioEngine extends IDisposable {
  98796. /**
  98797. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98798. */
  98799. readonly canUseWebAudio: boolean;
  98800. /**
  98801. * Gets the current AudioContext if available.
  98802. */
  98803. readonly audioContext: Nullable<AudioContext>;
  98804. /**
  98805. * The master gain node defines the global audio volume of your audio engine.
  98806. */
  98807. readonly masterGain: GainNode;
  98808. /**
  98809. * Gets whether or not mp3 are supported by your browser.
  98810. */
  98811. readonly isMP3supported: boolean;
  98812. /**
  98813. * Gets whether or not ogg are supported by your browser.
  98814. */
  98815. readonly isOGGsupported: boolean;
  98816. /**
  98817. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98818. * @ignoreNaming
  98819. */
  98820. WarnedWebAudioUnsupported: boolean;
  98821. /**
  98822. * Defines if the audio engine relies on a custom unlocked button.
  98823. * In this case, the embedded button will not be displayed.
  98824. */
  98825. useCustomUnlockedButton: boolean;
  98826. /**
  98827. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98828. */
  98829. readonly unlocked: boolean;
  98830. /**
  98831. * Event raised when audio has been unlocked on the browser.
  98832. */
  98833. onAudioUnlockedObservable: Observable<AudioEngine>;
  98834. /**
  98835. * Event raised when audio has been locked on the browser.
  98836. */
  98837. onAudioLockedObservable: Observable<AudioEngine>;
  98838. /**
  98839. * Flags the audio engine in Locked state.
  98840. * This happens due to new browser policies preventing audio to autoplay.
  98841. */
  98842. lock(): void;
  98843. /**
  98844. * Unlocks the audio engine once a user action has been done on the dom.
  98845. * This is helpful to resume play once browser policies have been satisfied.
  98846. */
  98847. unlock(): void;
  98848. }
  98849. /**
  98850. * This represents the default audio engine used in babylon.
  98851. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98853. */
  98854. export class AudioEngine implements IAudioEngine {
  98855. private _audioContext;
  98856. private _audioContextInitialized;
  98857. private _muteButton;
  98858. private _hostElement;
  98859. /**
  98860. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98861. */
  98862. canUseWebAudio: boolean;
  98863. /**
  98864. * The master gain node defines the global audio volume of your audio engine.
  98865. */
  98866. masterGain: GainNode;
  98867. /**
  98868. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98869. * @ignoreNaming
  98870. */
  98871. WarnedWebAudioUnsupported: boolean;
  98872. /**
  98873. * Gets whether or not mp3 are supported by your browser.
  98874. */
  98875. isMP3supported: boolean;
  98876. /**
  98877. * Gets whether or not ogg are supported by your browser.
  98878. */
  98879. isOGGsupported: boolean;
  98880. /**
  98881. * Gets whether audio has been unlocked on the device.
  98882. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98883. * a user interaction has happened.
  98884. */
  98885. unlocked: boolean;
  98886. /**
  98887. * Defines if the audio engine relies on a custom unlocked button.
  98888. * In this case, the embedded button will not be displayed.
  98889. */
  98890. useCustomUnlockedButton: boolean;
  98891. /**
  98892. * Event raised when audio has been unlocked on the browser.
  98893. */
  98894. onAudioUnlockedObservable: Observable<AudioEngine>;
  98895. /**
  98896. * Event raised when audio has been locked on the browser.
  98897. */
  98898. onAudioLockedObservable: Observable<AudioEngine>;
  98899. /**
  98900. * Gets the current AudioContext if available.
  98901. */
  98902. readonly audioContext: Nullable<AudioContext>;
  98903. private _connectedAnalyser;
  98904. /**
  98905. * Instantiates a new audio engine.
  98906. *
  98907. * There should be only one per page as some browsers restrict the number
  98908. * of audio contexts you can create.
  98909. * @param hostElement defines the host element where to display the mute icon if necessary
  98910. */
  98911. constructor(hostElement?: Nullable<HTMLElement>);
  98912. /**
  98913. * Flags the audio engine in Locked state.
  98914. * This happens due to new browser policies preventing audio to autoplay.
  98915. */
  98916. lock(): void;
  98917. /**
  98918. * Unlocks the audio engine once a user action has been done on the dom.
  98919. * This is helpful to resume play once browser policies have been satisfied.
  98920. */
  98921. unlock(): void;
  98922. private _resumeAudioContext;
  98923. private _initializeAudioContext;
  98924. private _tryToRun;
  98925. private _triggerRunningState;
  98926. private _triggerSuspendedState;
  98927. private _displayMuteButton;
  98928. private _moveButtonToTopLeft;
  98929. private _onResize;
  98930. private _hideMuteButton;
  98931. /**
  98932. * Destroy and release the resources associated with the audio ccontext.
  98933. */
  98934. dispose(): void;
  98935. /**
  98936. * Gets the global volume sets on the master gain.
  98937. * @returns the global volume if set or -1 otherwise
  98938. */
  98939. getGlobalVolume(): number;
  98940. /**
  98941. * Sets the global volume of your experience (sets on the master gain).
  98942. * @param newVolume Defines the new global volume of the application
  98943. */
  98944. setGlobalVolume(newVolume: number): void;
  98945. /**
  98946. * Connect the audio engine to an audio analyser allowing some amazing
  98947. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98949. * @param analyser The analyser to connect to the engine
  98950. */
  98951. connectToAnalyser(analyser: Analyser): void;
  98952. }
  98953. }
  98954. declare module BABYLON {
  98955. /**
  98956. * Interface used to present a loading screen while loading a scene
  98957. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98958. */
  98959. export interface ILoadingScreen {
  98960. /**
  98961. * Function called to display the loading screen
  98962. */
  98963. displayLoadingUI: () => void;
  98964. /**
  98965. * Function called to hide the loading screen
  98966. */
  98967. hideLoadingUI: () => void;
  98968. /**
  98969. * Gets or sets the color to use for the background
  98970. */
  98971. loadingUIBackgroundColor: string;
  98972. /**
  98973. * Gets or sets the text to display while loading
  98974. */
  98975. loadingUIText: string;
  98976. }
  98977. /**
  98978. * Class used for the default loading screen
  98979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98980. */
  98981. export class DefaultLoadingScreen implements ILoadingScreen {
  98982. private _renderingCanvas;
  98983. private _loadingText;
  98984. private _loadingDivBackgroundColor;
  98985. private _loadingDiv;
  98986. private _loadingTextDiv;
  98987. /** Gets or sets the logo url to use for the default loading screen */
  98988. static DefaultLogoUrl: string;
  98989. /** Gets or sets the spinner url to use for the default loading screen */
  98990. static DefaultSpinnerUrl: string;
  98991. /**
  98992. * Creates a new default loading screen
  98993. * @param _renderingCanvas defines the canvas used to render the scene
  98994. * @param _loadingText defines the default text to display
  98995. * @param _loadingDivBackgroundColor defines the default background color
  98996. */
  98997. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98998. /**
  98999. * Function called to display the loading screen
  99000. */
  99001. displayLoadingUI(): void;
  99002. /**
  99003. * Function called to hide the loading screen
  99004. */
  99005. hideLoadingUI(): void;
  99006. /**
  99007. * Gets or sets the text to display while loading
  99008. */
  99009. loadingUIText: string;
  99010. /**
  99011. * Gets or sets the color to use for the background
  99012. */
  99013. loadingUIBackgroundColor: string;
  99014. private _resizeLoadingUI;
  99015. }
  99016. }
  99017. declare module BABYLON {
  99018. /**
  99019. * Interface for any object that can request an animation frame
  99020. */
  99021. export interface ICustomAnimationFrameRequester {
  99022. /**
  99023. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99024. */
  99025. renderFunction?: Function;
  99026. /**
  99027. * Called to request the next frame to render to
  99028. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99029. */
  99030. requestAnimationFrame: Function;
  99031. /**
  99032. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99033. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99034. */
  99035. requestID?: number;
  99036. }
  99037. }
  99038. declare module BABYLON {
  99039. /**
  99040. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99041. */
  99042. export class PerformanceMonitor {
  99043. private _enabled;
  99044. private _rollingFrameTime;
  99045. private _lastFrameTimeMs;
  99046. /**
  99047. * constructor
  99048. * @param frameSampleSize The number of samples required to saturate the sliding window
  99049. */
  99050. constructor(frameSampleSize?: number);
  99051. /**
  99052. * Samples current frame
  99053. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99054. */
  99055. sampleFrame(timeMs?: number): void;
  99056. /**
  99057. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99058. */
  99059. readonly averageFrameTime: number;
  99060. /**
  99061. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99062. */
  99063. readonly averageFrameTimeVariance: number;
  99064. /**
  99065. * Returns the frame time of the most recent frame
  99066. */
  99067. readonly instantaneousFrameTime: number;
  99068. /**
  99069. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99070. */
  99071. readonly averageFPS: number;
  99072. /**
  99073. * Returns the average framerate in frames per second using the most recent frame time
  99074. */
  99075. readonly instantaneousFPS: number;
  99076. /**
  99077. * Returns true if enough samples have been taken to completely fill the sliding window
  99078. */
  99079. readonly isSaturated: boolean;
  99080. /**
  99081. * Enables contributions to the sliding window sample set
  99082. */
  99083. enable(): void;
  99084. /**
  99085. * Disables contributions to the sliding window sample set
  99086. * Samples will not be interpolated over the disabled period
  99087. */
  99088. disable(): void;
  99089. /**
  99090. * Returns true if sampling is enabled
  99091. */
  99092. readonly isEnabled: boolean;
  99093. /**
  99094. * Resets performance monitor
  99095. */
  99096. reset(): void;
  99097. }
  99098. /**
  99099. * RollingAverage
  99100. *
  99101. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99102. */
  99103. export class RollingAverage {
  99104. /**
  99105. * Current average
  99106. */
  99107. average: number;
  99108. /**
  99109. * Current variance
  99110. */
  99111. variance: number;
  99112. protected _samples: Array<number>;
  99113. protected _sampleCount: number;
  99114. protected _pos: number;
  99115. protected _m2: number;
  99116. /**
  99117. * constructor
  99118. * @param length The number of samples required to saturate the sliding window
  99119. */
  99120. constructor(length: number);
  99121. /**
  99122. * Adds a sample to the sample set
  99123. * @param v The sample value
  99124. */
  99125. add(v: number): void;
  99126. /**
  99127. * Returns previously added values or null if outside of history or outside the sliding window domain
  99128. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99129. * @return Value previously recorded with add() or null if outside of range
  99130. */
  99131. history(i: number): number;
  99132. /**
  99133. * Returns true if enough samples have been taken to completely fill the sliding window
  99134. * @return true if sample-set saturated
  99135. */
  99136. isSaturated(): boolean;
  99137. /**
  99138. * Resets the rolling average (equivalent to 0 samples taken so far)
  99139. */
  99140. reset(): void;
  99141. /**
  99142. * Wraps a value around the sample range boundaries
  99143. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99144. * @return Wrapped position in sample range
  99145. */
  99146. protected _wrapPosition(i: number): number;
  99147. }
  99148. }
  99149. declare module BABYLON {
  99150. /**
  99151. * This class is used to track a performance counter which is number based.
  99152. * The user has access to many properties which give statistics of different nature.
  99153. *
  99154. * The implementer can track two kinds of Performance Counter: time and count.
  99155. * 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.
  99156. * 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.
  99157. */
  99158. export class PerfCounter {
  99159. /**
  99160. * Gets or sets a global boolean to turn on and off all the counters
  99161. */
  99162. static Enabled: boolean;
  99163. /**
  99164. * Returns the smallest value ever
  99165. */
  99166. readonly min: number;
  99167. /**
  99168. * Returns the biggest value ever
  99169. */
  99170. readonly max: number;
  99171. /**
  99172. * Returns the average value since the performance counter is running
  99173. */
  99174. readonly average: number;
  99175. /**
  99176. * Returns the average value of the last second the counter was monitored
  99177. */
  99178. readonly lastSecAverage: number;
  99179. /**
  99180. * Returns the current value
  99181. */
  99182. readonly current: number;
  99183. /**
  99184. * Gets the accumulated total
  99185. */
  99186. readonly total: number;
  99187. /**
  99188. * Gets the total value count
  99189. */
  99190. readonly count: number;
  99191. /**
  99192. * Creates a new counter
  99193. */
  99194. constructor();
  99195. /**
  99196. * Call this method to start monitoring a new frame.
  99197. * 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.
  99198. */
  99199. fetchNewFrame(): void;
  99200. /**
  99201. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99202. * @param newCount the count value to add to the monitored count
  99203. * @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.
  99204. */
  99205. addCount(newCount: number, fetchResult: boolean): void;
  99206. /**
  99207. * Start monitoring this performance counter
  99208. */
  99209. beginMonitoring(): void;
  99210. /**
  99211. * Compute the time lapsed since the previous beginMonitoring() call.
  99212. * @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
  99213. */
  99214. endMonitoring(newFrame?: boolean): void;
  99215. private _fetchResult;
  99216. private _startMonitoringTime;
  99217. private _min;
  99218. private _max;
  99219. private _average;
  99220. private _current;
  99221. private _totalValueCount;
  99222. private _totalAccumulated;
  99223. private _lastSecAverage;
  99224. private _lastSecAccumulated;
  99225. private _lastSecTime;
  99226. private _lastSecValueCount;
  99227. }
  99228. }
  99229. declare module BABYLON {
  99230. /**
  99231. * Defines the interface used by display changed events
  99232. */
  99233. export interface IDisplayChangedEventArgs {
  99234. /** Gets the vrDisplay object (if any) */
  99235. vrDisplay: Nullable<any>;
  99236. /** Gets a boolean indicating if webVR is supported */
  99237. vrSupported: boolean;
  99238. }
  99239. /**
  99240. * Defines the interface used by objects containing a viewport (like a camera)
  99241. */
  99242. interface IViewportOwnerLike {
  99243. /**
  99244. * Gets or sets the viewport
  99245. */
  99246. viewport: IViewportLike;
  99247. }
  99248. /**
  99249. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99250. */
  99251. export class Engine extends ThinEngine {
  99252. /** Defines that alpha blending is disabled */
  99253. static readonly ALPHA_DISABLE: number;
  99254. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99255. static readonly ALPHA_ADD: number;
  99256. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99257. static readonly ALPHA_COMBINE: number;
  99258. /** Defines that alpha blending to DEST - SRC * DEST */
  99259. static readonly ALPHA_SUBTRACT: number;
  99260. /** Defines that alpha blending to SRC * DEST */
  99261. static readonly ALPHA_MULTIPLY: number;
  99262. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99263. static readonly ALPHA_MAXIMIZED: number;
  99264. /** Defines that alpha blending to SRC + DEST */
  99265. static readonly ALPHA_ONEONE: number;
  99266. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99267. static readonly ALPHA_PREMULTIPLIED: number;
  99268. /**
  99269. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99270. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99271. */
  99272. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99273. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99274. static readonly ALPHA_INTERPOLATE: number;
  99275. /**
  99276. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99277. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99278. */
  99279. static readonly ALPHA_SCREENMODE: number;
  99280. /** Defines that the ressource is not delayed*/
  99281. static readonly DELAYLOADSTATE_NONE: number;
  99282. /** Defines that the ressource was successfully delay loaded */
  99283. static readonly DELAYLOADSTATE_LOADED: number;
  99284. /** Defines that the ressource is currently delay loading */
  99285. static readonly DELAYLOADSTATE_LOADING: number;
  99286. /** Defines that the ressource is delayed and has not started loading */
  99287. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99288. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99289. static readonly NEVER: number;
  99290. /** 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 */
  99291. static readonly ALWAYS: number;
  99292. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99293. static readonly LESS: number;
  99294. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99295. static readonly EQUAL: number;
  99296. /** 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 */
  99297. static readonly LEQUAL: number;
  99298. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99299. static readonly GREATER: number;
  99300. /** 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 */
  99301. static readonly GEQUAL: number;
  99302. /** 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 */
  99303. static readonly NOTEQUAL: number;
  99304. /** Passed to stencilOperation to specify that stencil value must be kept */
  99305. static readonly KEEP: number;
  99306. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99307. static readonly REPLACE: number;
  99308. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99309. static readonly INCR: number;
  99310. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99311. static readonly DECR: number;
  99312. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99313. static readonly INVERT: number;
  99314. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99315. static readonly INCR_WRAP: number;
  99316. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99317. static readonly DECR_WRAP: number;
  99318. /** Texture is not repeating outside of 0..1 UVs */
  99319. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99320. /** Texture is repeating outside of 0..1 UVs */
  99321. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99322. /** Texture is repeating and mirrored */
  99323. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99324. /** ALPHA */
  99325. static readonly TEXTUREFORMAT_ALPHA: number;
  99326. /** LUMINANCE */
  99327. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99328. /** LUMINANCE_ALPHA */
  99329. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99330. /** RGB */
  99331. static readonly TEXTUREFORMAT_RGB: number;
  99332. /** RGBA */
  99333. static readonly TEXTUREFORMAT_RGBA: number;
  99334. /** RED */
  99335. static readonly TEXTUREFORMAT_RED: number;
  99336. /** RED (2nd reference) */
  99337. static readonly TEXTUREFORMAT_R: number;
  99338. /** RG */
  99339. static readonly TEXTUREFORMAT_RG: number;
  99340. /** RED_INTEGER */
  99341. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99342. /** RED_INTEGER (2nd reference) */
  99343. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99344. /** RG_INTEGER */
  99345. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99346. /** RGB_INTEGER */
  99347. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99348. /** RGBA_INTEGER */
  99349. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99350. /** UNSIGNED_BYTE */
  99351. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99352. /** UNSIGNED_BYTE (2nd reference) */
  99353. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99354. /** FLOAT */
  99355. static readonly TEXTURETYPE_FLOAT: number;
  99356. /** HALF_FLOAT */
  99357. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99358. /** BYTE */
  99359. static readonly TEXTURETYPE_BYTE: number;
  99360. /** SHORT */
  99361. static readonly TEXTURETYPE_SHORT: number;
  99362. /** UNSIGNED_SHORT */
  99363. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99364. /** INT */
  99365. static readonly TEXTURETYPE_INT: number;
  99366. /** UNSIGNED_INT */
  99367. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99368. /** UNSIGNED_SHORT_4_4_4_4 */
  99369. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99370. /** UNSIGNED_SHORT_5_5_5_1 */
  99371. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99372. /** UNSIGNED_SHORT_5_6_5 */
  99373. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99374. /** UNSIGNED_INT_2_10_10_10_REV */
  99375. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99376. /** UNSIGNED_INT_24_8 */
  99377. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99378. /** UNSIGNED_INT_10F_11F_11F_REV */
  99379. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99380. /** UNSIGNED_INT_5_9_9_9_REV */
  99381. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99382. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99383. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99384. /** nearest is mag = nearest and min = nearest and mip = linear */
  99385. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99386. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99387. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99388. /** Trilinear is mag = linear and min = linear and mip = linear */
  99389. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99390. /** nearest is mag = nearest and min = nearest and mip = linear */
  99391. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99392. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99393. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99394. /** Trilinear is mag = linear and min = linear and mip = linear */
  99395. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99396. /** mag = nearest and min = nearest and mip = nearest */
  99397. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99398. /** mag = nearest and min = linear and mip = nearest */
  99399. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99400. /** mag = nearest and min = linear and mip = linear */
  99401. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99402. /** mag = nearest and min = linear and mip = none */
  99403. static readonly TEXTURE_NEAREST_LINEAR: number;
  99404. /** mag = nearest and min = nearest and mip = none */
  99405. static readonly TEXTURE_NEAREST_NEAREST: number;
  99406. /** mag = linear and min = nearest and mip = nearest */
  99407. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99408. /** mag = linear and min = nearest and mip = linear */
  99409. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99410. /** mag = linear and min = linear and mip = none */
  99411. static readonly TEXTURE_LINEAR_LINEAR: number;
  99412. /** mag = linear and min = nearest and mip = none */
  99413. static readonly TEXTURE_LINEAR_NEAREST: number;
  99414. /** Explicit coordinates mode */
  99415. static readonly TEXTURE_EXPLICIT_MODE: number;
  99416. /** Spherical coordinates mode */
  99417. static readonly TEXTURE_SPHERICAL_MODE: number;
  99418. /** Planar coordinates mode */
  99419. static readonly TEXTURE_PLANAR_MODE: number;
  99420. /** Cubic coordinates mode */
  99421. static readonly TEXTURE_CUBIC_MODE: number;
  99422. /** Projection coordinates mode */
  99423. static readonly TEXTURE_PROJECTION_MODE: number;
  99424. /** Skybox coordinates mode */
  99425. static readonly TEXTURE_SKYBOX_MODE: number;
  99426. /** Inverse Cubic coordinates mode */
  99427. static readonly TEXTURE_INVCUBIC_MODE: number;
  99428. /** Equirectangular coordinates mode */
  99429. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99430. /** Equirectangular Fixed coordinates mode */
  99431. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99432. /** Equirectangular Fixed Mirrored coordinates mode */
  99433. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99434. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99435. static readonly SCALEMODE_FLOOR: number;
  99436. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99437. static readonly SCALEMODE_NEAREST: number;
  99438. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99439. static readonly SCALEMODE_CEILING: number;
  99440. /**
  99441. * Returns the current npm package of the sdk
  99442. */
  99443. static readonly NpmPackage: string;
  99444. /**
  99445. * Returns the current version of the framework
  99446. */
  99447. static readonly Version: string;
  99448. /** Gets the list of created engines */
  99449. static readonly Instances: Engine[];
  99450. /**
  99451. * Gets the latest created engine
  99452. */
  99453. static readonly LastCreatedEngine: Nullable<Engine>;
  99454. /**
  99455. * Gets the latest created scene
  99456. */
  99457. static readonly LastCreatedScene: Nullable<Scene>;
  99458. /**
  99459. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99460. * @param flag defines which part of the materials must be marked as dirty
  99461. * @param predicate defines a predicate used to filter which materials should be affected
  99462. */
  99463. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99464. /**
  99465. * Method called to create the default loading screen.
  99466. * This can be overriden in your own app.
  99467. * @param canvas The rendering canvas element
  99468. * @returns The loading screen
  99469. */
  99470. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99471. /**
  99472. * Method called to create the default rescale post process on each engine.
  99473. */
  99474. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99475. /**
  99476. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99477. **/
  99478. enableOfflineSupport: boolean;
  99479. /**
  99480. * 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)
  99481. **/
  99482. disableManifestCheck: boolean;
  99483. /**
  99484. * Gets the list of created scenes
  99485. */
  99486. scenes: Scene[];
  99487. /**
  99488. * Event raised when a new scene is created
  99489. */
  99490. onNewSceneAddedObservable: Observable<Scene>;
  99491. /**
  99492. * Gets the list of created postprocesses
  99493. */
  99494. postProcesses: PostProcess[];
  99495. /**
  99496. * Gets a boolean indicating if the pointer is currently locked
  99497. */
  99498. isPointerLock: boolean;
  99499. /**
  99500. * Observable event triggered each time the rendering canvas is resized
  99501. */
  99502. onResizeObservable: Observable<Engine>;
  99503. /**
  99504. * Observable event triggered each time the canvas loses focus
  99505. */
  99506. onCanvasBlurObservable: Observable<Engine>;
  99507. /**
  99508. * Observable event triggered each time the canvas gains focus
  99509. */
  99510. onCanvasFocusObservable: Observable<Engine>;
  99511. /**
  99512. * Observable event triggered each time the canvas receives pointerout event
  99513. */
  99514. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99515. /**
  99516. * Observable raised when the engine begins a new frame
  99517. */
  99518. onBeginFrameObservable: Observable<Engine>;
  99519. /**
  99520. * If set, will be used to request the next animation frame for the render loop
  99521. */
  99522. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99523. /**
  99524. * Observable raised when the engine ends the current frame
  99525. */
  99526. onEndFrameObservable: Observable<Engine>;
  99527. /**
  99528. * Observable raised when the engine is about to compile a shader
  99529. */
  99530. onBeforeShaderCompilationObservable: Observable<Engine>;
  99531. /**
  99532. * Observable raised when the engine has jsut compiled a shader
  99533. */
  99534. onAfterShaderCompilationObservable: Observable<Engine>;
  99535. /**
  99536. * Gets the audio engine
  99537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99538. * @ignorenaming
  99539. */
  99540. static audioEngine: IAudioEngine;
  99541. /**
  99542. * Default AudioEngine factory responsible of creating the Audio Engine.
  99543. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99544. */
  99545. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99546. /**
  99547. * Default offline support factory responsible of creating a tool used to store data locally.
  99548. * By default, this will create a Database object if the workload has been embedded.
  99549. */
  99550. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99551. private _loadingScreen;
  99552. private _pointerLockRequested;
  99553. private _dummyFramebuffer;
  99554. private _rescalePostProcess;
  99555. /** @hidden */
  99556. protected _alphaMode: number;
  99557. /** @hidden */
  99558. protected _alphaEquation: number;
  99559. private _deterministicLockstep;
  99560. private _lockstepMaxSteps;
  99561. protected readonly _supportsHardwareTextureRescaling: boolean;
  99562. private _fps;
  99563. private _deltaTime;
  99564. /** @hidden */
  99565. _drawCalls: PerfCounter;
  99566. /**
  99567. * Turn this value on if you want to pause FPS computation when in background
  99568. */
  99569. disablePerformanceMonitorInBackground: boolean;
  99570. private _performanceMonitor;
  99571. /**
  99572. * Gets the performance monitor attached to this engine
  99573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99574. */
  99575. readonly performanceMonitor: PerformanceMonitor;
  99576. private _onFocus;
  99577. private _onBlur;
  99578. private _onCanvasPointerOut;
  99579. private _onCanvasBlur;
  99580. private _onCanvasFocus;
  99581. private _onFullscreenChange;
  99582. private _onPointerLockChange;
  99583. /**
  99584. * Gets the HTML element used to attach event listeners
  99585. * @returns a HTML element
  99586. */
  99587. getInputElement(): Nullable<HTMLElement>;
  99588. /**
  99589. * Creates a new engine
  99590. * @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
  99591. * @param antialias defines enable antialiasing (default: false)
  99592. * @param options defines further options to be sent to the getContext() function
  99593. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99594. */
  99595. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99596. /**
  99597. * Gets current aspect ratio
  99598. * @param viewportOwner defines the camera to use to get the aspect ratio
  99599. * @param useScreen defines if screen size must be used (or the current render target if any)
  99600. * @returns a number defining the aspect ratio
  99601. */
  99602. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99603. /**
  99604. * Gets current screen aspect ratio
  99605. * @returns a number defining the aspect ratio
  99606. */
  99607. getScreenAspectRatio(): number;
  99608. /**
  99609. * Gets host document
  99610. * @returns the host document object
  99611. */
  99612. getHostDocument(): Document;
  99613. /**
  99614. * Gets the client rect of the HTML canvas attached with the current webGL context
  99615. * @returns a client rectanglee
  99616. */
  99617. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99618. /**
  99619. * Gets the client rect of the HTML element used for events
  99620. * @returns a client rectanglee
  99621. */
  99622. getInputElementClientRect(): Nullable<ClientRect>;
  99623. /**
  99624. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99626. * @returns true if engine is in deterministic lock step mode
  99627. */
  99628. isDeterministicLockStep(): boolean;
  99629. /**
  99630. * Gets the max steps when engine is running in deterministic lock step
  99631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99632. * @returns the max steps
  99633. */
  99634. getLockstepMaxSteps(): number;
  99635. /**
  99636. * Force the mipmap generation for the given render target texture
  99637. * @param texture defines the render target texture to use
  99638. */
  99639. generateMipMapsForCubemap(texture: InternalTexture): void;
  99640. /** States */
  99641. /**
  99642. * Set various states to the webGL context
  99643. * @param culling defines backface culling state
  99644. * @param zOffset defines the value to apply to zOffset (0 by default)
  99645. * @param force defines if states must be applied even if cache is up to date
  99646. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99647. */
  99648. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99649. /**
  99650. * Set the z offset to apply to current rendering
  99651. * @param value defines the offset to apply
  99652. */
  99653. setZOffset(value: number): void;
  99654. /**
  99655. * Gets the current value of the zOffset
  99656. * @returns the current zOffset state
  99657. */
  99658. getZOffset(): number;
  99659. /**
  99660. * Enable or disable depth buffering
  99661. * @param enable defines the state to set
  99662. */
  99663. setDepthBuffer(enable: boolean): void;
  99664. /**
  99665. * Gets a boolean indicating if depth writing is enabled
  99666. * @returns the current depth writing state
  99667. */
  99668. getDepthWrite(): boolean;
  99669. /**
  99670. * Enable or disable depth writing
  99671. * @param enable defines the state to set
  99672. */
  99673. setDepthWrite(enable: boolean): void;
  99674. /**
  99675. * Enable or disable color writing
  99676. * @param enable defines the state to set
  99677. */
  99678. setColorWrite(enable: boolean): void;
  99679. /**
  99680. * Gets a boolean indicating if color writing is enabled
  99681. * @returns the current color writing state
  99682. */
  99683. getColorWrite(): boolean;
  99684. /**
  99685. * Sets alpha constants used by some alpha blending modes
  99686. * @param r defines the red component
  99687. * @param g defines the green component
  99688. * @param b defines the blue component
  99689. * @param a defines the alpha component
  99690. */
  99691. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99692. /**
  99693. * Sets the current alpha mode
  99694. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99695. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99696. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99697. */
  99698. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99699. /**
  99700. * Gets the current alpha mode
  99701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99702. * @returns the current alpha mode
  99703. */
  99704. getAlphaMode(): number;
  99705. /**
  99706. * Sets the current alpha equation
  99707. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99708. */
  99709. setAlphaEquation(equation: number): void;
  99710. /**
  99711. * Gets the current alpha equation.
  99712. * @returns the current alpha equation
  99713. */
  99714. getAlphaEquation(): number;
  99715. /**
  99716. * Gets a boolean indicating if stencil buffer is enabled
  99717. * @returns the current stencil buffer state
  99718. */
  99719. getStencilBuffer(): boolean;
  99720. /**
  99721. * Enable or disable the stencil buffer
  99722. * @param enable defines if the stencil buffer must be enabled or disabled
  99723. */
  99724. setStencilBuffer(enable: boolean): void;
  99725. /**
  99726. * Gets the current stencil mask
  99727. * @returns a number defining the new stencil mask to use
  99728. */
  99729. getStencilMask(): number;
  99730. /**
  99731. * Sets the current stencil mask
  99732. * @param mask defines the new stencil mask to use
  99733. */
  99734. setStencilMask(mask: number): void;
  99735. /**
  99736. * Gets the current stencil function
  99737. * @returns a number defining the stencil function to use
  99738. */
  99739. getStencilFunction(): number;
  99740. /**
  99741. * Gets the current stencil reference value
  99742. * @returns a number defining the stencil reference value to use
  99743. */
  99744. getStencilFunctionReference(): number;
  99745. /**
  99746. * Gets the current stencil mask
  99747. * @returns a number defining the stencil mask to use
  99748. */
  99749. getStencilFunctionMask(): number;
  99750. /**
  99751. * Sets the current stencil function
  99752. * @param stencilFunc defines the new stencil function to use
  99753. */
  99754. setStencilFunction(stencilFunc: number): void;
  99755. /**
  99756. * Sets the current stencil reference
  99757. * @param reference defines the new stencil reference to use
  99758. */
  99759. setStencilFunctionReference(reference: number): void;
  99760. /**
  99761. * Sets the current stencil mask
  99762. * @param mask defines the new stencil mask to use
  99763. */
  99764. setStencilFunctionMask(mask: number): void;
  99765. /**
  99766. * Gets the current stencil operation when stencil fails
  99767. * @returns a number defining stencil operation to use when stencil fails
  99768. */
  99769. getStencilOperationFail(): number;
  99770. /**
  99771. * Gets the current stencil operation when depth fails
  99772. * @returns a number defining stencil operation to use when depth fails
  99773. */
  99774. getStencilOperationDepthFail(): number;
  99775. /**
  99776. * Gets the current stencil operation when stencil passes
  99777. * @returns a number defining stencil operation to use when stencil passes
  99778. */
  99779. getStencilOperationPass(): number;
  99780. /**
  99781. * Sets the stencil operation to use when stencil fails
  99782. * @param operation defines the stencil operation to use when stencil fails
  99783. */
  99784. setStencilOperationFail(operation: number): void;
  99785. /**
  99786. * Sets the stencil operation to use when depth fails
  99787. * @param operation defines the stencil operation to use when depth fails
  99788. */
  99789. setStencilOperationDepthFail(operation: number): void;
  99790. /**
  99791. * Sets the stencil operation to use when stencil passes
  99792. * @param operation defines the stencil operation to use when stencil passes
  99793. */
  99794. setStencilOperationPass(operation: number): void;
  99795. /**
  99796. * Sets a boolean indicating if the dithering state is enabled or disabled
  99797. * @param value defines the dithering state
  99798. */
  99799. setDitheringState(value: boolean): void;
  99800. /**
  99801. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99802. * @param value defines the rasterizer state
  99803. */
  99804. setRasterizerState(value: boolean): void;
  99805. /**
  99806. * Gets the current depth function
  99807. * @returns a number defining the depth function
  99808. */
  99809. getDepthFunction(): Nullable<number>;
  99810. /**
  99811. * Sets the current depth function
  99812. * @param depthFunc defines the function to use
  99813. */
  99814. setDepthFunction(depthFunc: number): void;
  99815. /**
  99816. * Sets the current depth function to GREATER
  99817. */
  99818. setDepthFunctionToGreater(): void;
  99819. /**
  99820. * Sets the current depth function to GEQUAL
  99821. */
  99822. setDepthFunctionToGreaterOrEqual(): void;
  99823. /**
  99824. * Sets the current depth function to LESS
  99825. */
  99826. setDepthFunctionToLess(): void;
  99827. /**
  99828. * Sets the current depth function to LEQUAL
  99829. */
  99830. setDepthFunctionToLessOrEqual(): void;
  99831. private _cachedStencilBuffer;
  99832. private _cachedStencilFunction;
  99833. private _cachedStencilMask;
  99834. private _cachedStencilOperationPass;
  99835. private _cachedStencilOperationFail;
  99836. private _cachedStencilOperationDepthFail;
  99837. private _cachedStencilReference;
  99838. /**
  99839. * Caches the the state of the stencil buffer
  99840. */
  99841. cacheStencilState(): void;
  99842. /**
  99843. * Restores the state of the stencil buffer
  99844. */
  99845. restoreStencilState(): void;
  99846. /**
  99847. * Directly set the WebGL Viewport
  99848. * @param x defines the x coordinate of the viewport (in screen space)
  99849. * @param y defines the y coordinate of the viewport (in screen space)
  99850. * @param width defines the width of the viewport (in screen space)
  99851. * @param height defines the height of the viewport (in screen space)
  99852. * @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
  99853. */
  99854. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99855. /**
  99856. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99857. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99858. * @param y defines the y-coordinate of the corner of the clear rectangle
  99859. * @param width defines the width of the clear rectangle
  99860. * @param height defines the height of the clear rectangle
  99861. * @param clearColor defines the clear color
  99862. */
  99863. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99864. /**
  99865. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99866. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99867. * @param y defines the y-coordinate of the corner of the clear rectangle
  99868. * @param width defines the width of the clear rectangle
  99869. * @param height defines the height of the clear rectangle
  99870. */
  99871. enableScissor(x: number, y: number, width: number, height: number): void;
  99872. /**
  99873. * Disable previously set scissor test rectangle
  99874. */
  99875. disableScissor(): void;
  99876. protected _reportDrawCall(): void;
  99877. /**
  99878. * Initializes a webVR display and starts listening to display change events
  99879. * The onVRDisplayChangedObservable will be notified upon these changes
  99880. * @returns The onVRDisplayChangedObservable
  99881. */
  99882. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99883. /** @hidden */
  99884. _prepareVRComponent(): void;
  99885. /** @hidden */
  99886. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99887. /** @hidden */
  99888. _submitVRFrame(): void;
  99889. /**
  99890. * Call this function to leave webVR mode
  99891. * Will do nothing if webVR is not supported or if there is no webVR device
  99892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99893. */
  99894. disableVR(): void;
  99895. /**
  99896. * Gets a boolean indicating that the system is in VR mode and is presenting
  99897. * @returns true if VR mode is engaged
  99898. */
  99899. isVRPresenting(): boolean;
  99900. /** @hidden */
  99901. _requestVRFrame(): void;
  99902. /** @hidden */
  99903. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99904. /**
  99905. * Gets the source code of the vertex shader associated with a specific webGL program
  99906. * @param program defines the program to use
  99907. * @returns a string containing the source code of the vertex shader associated with the program
  99908. */
  99909. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99910. /**
  99911. * Gets the source code of the fragment shader associated with a specific webGL program
  99912. * @param program defines the program to use
  99913. * @returns a string containing the source code of the fragment shader associated with the program
  99914. */
  99915. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99916. /**
  99917. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99918. * @param x defines the x coordinate of the rectangle where pixels must be read
  99919. * @param y defines the y coordinate of the rectangle where pixels must be read
  99920. * @param width defines the width of the rectangle where pixels must be read
  99921. * @param height defines the height of the rectangle where pixels must be read
  99922. * @returns a Uint8Array containing RGBA colors
  99923. */
  99924. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99925. /**
  99926. * Sets a depth stencil texture from a render target to the according uniform.
  99927. * @param channel The texture channel
  99928. * @param uniform The uniform to set
  99929. * @param texture The render target texture containing the depth stencil texture to apply
  99930. */
  99931. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99932. /**
  99933. * Sets a texture to the webGL context from a postprocess
  99934. * @param channel defines the channel to use
  99935. * @param postProcess defines the source postprocess
  99936. */
  99937. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99938. /**
  99939. * Binds the output of the passed in post process to the texture channel specified
  99940. * @param channel The channel the texture should be bound to
  99941. * @param postProcess The post process which's output should be bound
  99942. */
  99943. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99944. /** @hidden */
  99945. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99946. protected _rebuildBuffers(): void;
  99947. /** @hidden */
  99948. _renderFrame(): void;
  99949. _renderLoop(): void;
  99950. /** @hidden */
  99951. _renderViews(): boolean;
  99952. /**
  99953. * Toggle full screen mode
  99954. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99955. */
  99956. switchFullscreen(requestPointerLock: boolean): void;
  99957. /**
  99958. * Enters full screen mode
  99959. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99960. */
  99961. enterFullscreen(requestPointerLock: boolean): void;
  99962. /**
  99963. * Exits full screen mode
  99964. */
  99965. exitFullscreen(): void;
  99966. /**
  99967. * Enters Pointerlock mode
  99968. */
  99969. enterPointerlock(): void;
  99970. /**
  99971. * Exits Pointerlock mode
  99972. */
  99973. exitPointerlock(): void;
  99974. /**
  99975. * Begin a new frame
  99976. */
  99977. beginFrame(): void;
  99978. /**
  99979. * Enf the current frame
  99980. */
  99981. endFrame(): void;
  99982. resize(): void;
  99983. /**
  99984. * Set the compressed texture format to use, based on the formats you have, and the formats
  99985. * supported by the hardware / browser.
  99986. *
  99987. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99988. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99989. * to API arguments needed to compressed textures. This puts the burden on the container
  99990. * generator to house the arcane code for determining these for current & future formats.
  99991. *
  99992. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99993. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99994. *
  99995. * Note: The result of this call is not taken into account when a texture is base64.
  99996. *
  99997. * @param formatsAvailable defines the list of those format families you have created
  99998. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99999. *
  100000. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100001. * @returns The extension selected.
  100002. */
  100003. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100004. /**
  100005. * Force a specific size of the canvas
  100006. * @param width defines the new canvas' width
  100007. * @param height defines the new canvas' height
  100008. */
  100009. setSize(width: number, height: number): void;
  100010. /**
  100011. * Updates a dynamic vertex buffer.
  100012. * @param vertexBuffer the vertex buffer to update
  100013. * @param data the data used to update the vertex buffer
  100014. * @param byteOffset the byte offset of the data
  100015. * @param byteLength the byte length of the data
  100016. */
  100017. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100018. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100019. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100020. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100021. _releaseTexture(texture: InternalTexture): void;
  100022. /**
  100023. * @hidden
  100024. * Rescales a texture
  100025. * @param source input texutre
  100026. * @param destination destination texture
  100027. * @param scene scene to use to render the resize
  100028. * @param internalFormat format to use when resizing
  100029. * @param onComplete callback to be called when resize has completed
  100030. */
  100031. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100032. /**
  100033. * Gets the current framerate
  100034. * @returns a number representing the framerate
  100035. */
  100036. getFps(): number;
  100037. /**
  100038. * Gets the time spent between current and previous frame
  100039. * @returns a number representing the delta time in ms
  100040. */
  100041. getDeltaTime(): number;
  100042. private _measureFps;
  100043. /** @hidden */
  100044. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100045. /**
  100046. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100047. * @param renderTarget The render target to set the frame buffer for
  100048. */
  100049. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100050. /**
  100051. * Update a dynamic index buffer
  100052. * @param indexBuffer defines the target index buffer
  100053. * @param indices defines the data to update
  100054. * @param offset defines the offset in the target index buffer where update should start
  100055. */
  100056. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100057. /**
  100058. * Updates the sample count of a render target texture
  100059. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100060. * @param texture defines the texture to update
  100061. * @param samples defines the sample count to set
  100062. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100063. */
  100064. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100065. /**
  100066. * Updates a depth texture Comparison Mode and Function.
  100067. * If the comparison Function is equal to 0, the mode will be set to none.
  100068. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100069. * @param texture The texture to set the comparison function for
  100070. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100071. */
  100072. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100073. /**
  100074. * Creates a webGL buffer to use with instanciation
  100075. * @param capacity defines the size of the buffer
  100076. * @returns the webGL buffer
  100077. */
  100078. createInstancesBuffer(capacity: number): DataBuffer;
  100079. /**
  100080. * Delete a webGL buffer used with instanciation
  100081. * @param buffer defines the webGL buffer to delete
  100082. */
  100083. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100084. /** @hidden */
  100085. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100086. dispose(): void;
  100087. private _disableTouchAction;
  100088. /**
  100089. * Display the loading screen
  100090. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100091. */
  100092. displayLoadingUI(): void;
  100093. /**
  100094. * Hide the loading screen
  100095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100096. */
  100097. hideLoadingUI(): void;
  100098. /**
  100099. * Gets the current loading screen object
  100100. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100101. */
  100102. /**
  100103. * Sets the current loading screen object
  100104. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100105. */
  100106. loadingScreen: ILoadingScreen;
  100107. /**
  100108. * Sets the current loading screen text
  100109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100110. */
  100111. loadingUIText: string;
  100112. /**
  100113. * Sets the current loading screen background color
  100114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100115. */
  100116. loadingUIBackgroundColor: string;
  100117. /** Pointerlock and fullscreen */
  100118. /**
  100119. * Ask the browser to promote the current element to pointerlock mode
  100120. * @param element defines the DOM element to promote
  100121. */
  100122. static _RequestPointerlock(element: HTMLElement): void;
  100123. /**
  100124. * Asks the browser to exit pointerlock mode
  100125. */
  100126. static _ExitPointerlock(): void;
  100127. /**
  100128. * Ask the browser to promote the current element to fullscreen rendering mode
  100129. * @param element defines the DOM element to promote
  100130. */
  100131. static _RequestFullscreen(element: HTMLElement): void;
  100132. /**
  100133. * Asks the browser to exit fullscreen mode
  100134. */
  100135. static _ExitFullscreen(): void;
  100136. }
  100137. }
  100138. declare module BABYLON {
  100139. /**
  100140. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100141. * during the life time of the application.
  100142. */
  100143. export class EngineStore {
  100144. /** Gets the list of created engines */
  100145. static Instances: Engine[];
  100146. /** @hidden */
  100147. static _LastCreatedScene: Nullable<Scene>;
  100148. /**
  100149. * Gets the latest created engine
  100150. */
  100151. static readonly LastCreatedEngine: Nullable<Engine>;
  100152. /**
  100153. * Gets the latest created scene
  100154. */
  100155. static readonly LastCreatedScene: Nullable<Scene>;
  100156. /**
  100157. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100158. * @ignorenaming
  100159. */
  100160. static UseFallbackTexture: boolean;
  100161. /**
  100162. * Texture content used if a texture cannot loaded
  100163. * @ignorenaming
  100164. */
  100165. static FallbackTexture: string;
  100166. }
  100167. }
  100168. declare module BABYLON {
  100169. /**
  100170. * Helper class that provides a small promise polyfill
  100171. */
  100172. export class PromisePolyfill {
  100173. /**
  100174. * Static function used to check if the polyfill is required
  100175. * If this is the case then the function will inject the polyfill to window.Promise
  100176. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100177. */
  100178. static Apply(force?: boolean): void;
  100179. }
  100180. }
  100181. declare module BABYLON {
  100182. /**
  100183. * Interface for screenshot methods with describe argument called `size` as object with options
  100184. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100185. */
  100186. export interface IScreenshotSize {
  100187. /**
  100188. * number in pixels for canvas height
  100189. */
  100190. height?: number;
  100191. /**
  100192. * multiplier allowing render at a higher or lower resolution
  100193. * If value is defined then height and width will be ignored and taken from camera
  100194. */
  100195. precision?: number;
  100196. /**
  100197. * number in pixels for canvas width
  100198. */
  100199. width?: number;
  100200. }
  100201. }
  100202. declare module BABYLON {
  100203. interface IColor4Like {
  100204. r: float;
  100205. g: float;
  100206. b: float;
  100207. a: float;
  100208. }
  100209. /**
  100210. * Class containing a set of static utilities functions
  100211. */
  100212. export class Tools {
  100213. /**
  100214. * Gets or sets the base URL to use to load assets
  100215. */
  100216. static BaseUrl: string;
  100217. /**
  100218. * Enable/Disable Custom HTTP Request Headers globally.
  100219. * default = false
  100220. * @see CustomRequestHeaders
  100221. */
  100222. static UseCustomRequestHeaders: boolean;
  100223. /**
  100224. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100225. * i.e. when loading files, where the server/service expects an Authorization header
  100226. */
  100227. static CustomRequestHeaders: {
  100228. [key: string]: string;
  100229. };
  100230. /**
  100231. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100232. */
  100233. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100234. /**
  100235. * Default behaviour for cors in the application.
  100236. * It can be a string if the expected behavior is identical in the entire app.
  100237. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100238. */
  100239. static CorsBehavior: string | ((url: string | string[]) => string);
  100240. /**
  100241. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100242. * @ignorenaming
  100243. */
  100244. static UseFallbackTexture: boolean;
  100245. /**
  100246. * Use this object to register external classes like custom textures or material
  100247. * to allow the laoders to instantiate them
  100248. */
  100249. static RegisteredExternalClasses: {
  100250. [key: string]: Object;
  100251. };
  100252. /**
  100253. * Texture content used if a texture cannot loaded
  100254. * @ignorenaming
  100255. */
  100256. static fallbackTexture: string;
  100257. /**
  100258. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100259. * @param u defines the coordinate on X axis
  100260. * @param v defines the coordinate on Y axis
  100261. * @param width defines the width of the source data
  100262. * @param height defines the height of the source data
  100263. * @param pixels defines the source byte array
  100264. * @param color defines the output color
  100265. */
  100266. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100267. /**
  100268. * Interpolates between a and b via alpha
  100269. * @param a The lower value (returned when alpha = 0)
  100270. * @param b The upper value (returned when alpha = 1)
  100271. * @param alpha The interpolation-factor
  100272. * @return The mixed value
  100273. */
  100274. static Mix(a: number, b: number, alpha: number): number;
  100275. /**
  100276. * Tries to instantiate a new object from a given class name
  100277. * @param className defines the class name to instantiate
  100278. * @returns the new object or null if the system was not able to do the instantiation
  100279. */
  100280. static Instantiate(className: string): any;
  100281. /**
  100282. * Provides a slice function that will work even on IE
  100283. * @param data defines the array to slice
  100284. * @param start defines the start of the data (optional)
  100285. * @param end defines the end of the data (optional)
  100286. * @returns the new sliced array
  100287. */
  100288. static Slice<T>(data: T, start?: number, end?: number): T;
  100289. /**
  100290. * Polyfill for setImmediate
  100291. * @param action defines the action to execute after the current execution block
  100292. */
  100293. static SetImmediate(action: () => void): void;
  100294. /**
  100295. * Function indicating if a number is an exponent of 2
  100296. * @param value defines the value to test
  100297. * @returns true if the value is an exponent of 2
  100298. */
  100299. static IsExponentOfTwo(value: number): boolean;
  100300. private static _tmpFloatArray;
  100301. /**
  100302. * Returns the nearest 32-bit single precision float representation of a Number
  100303. * @param value A Number. If the parameter is of a different type, it will get converted
  100304. * to a number or to NaN if it cannot be converted
  100305. * @returns number
  100306. */
  100307. static FloatRound(value: number): number;
  100308. /**
  100309. * Extracts the filename from a path
  100310. * @param path defines the path to use
  100311. * @returns the filename
  100312. */
  100313. static GetFilename(path: string): string;
  100314. /**
  100315. * Extracts the "folder" part of a path (everything before the filename).
  100316. * @param uri The URI to extract the info from
  100317. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100318. * @returns The "folder" part of the path
  100319. */
  100320. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100321. /**
  100322. * Extracts text content from a DOM element hierarchy
  100323. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100324. */
  100325. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100326. /**
  100327. * Convert an angle in radians to degrees
  100328. * @param angle defines the angle to convert
  100329. * @returns the angle in degrees
  100330. */
  100331. static ToDegrees(angle: number): number;
  100332. /**
  100333. * Convert an angle in degrees to radians
  100334. * @param angle defines the angle to convert
  100335. * @returns the angle in radians
  100336. */
  100337. static ToRadians(angle: number): number;
  100338. /**
  100339. * Returns an array if obj is not an array
  100340. * @param obj defines the object to evaluate as an array
  100341. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100342. * @returns either obj directly if obj is an array or a new array containing obj
  100343. */
  100344. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100345. /**
  100346. * Gets the pointer prefix to use
  100347. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100348. */
  100349. static GetPointerPrefix(): string;
  100350. /**
  100351. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100352. * @param url define the url we are trying
  100353. * @param element define the dom element where to configure the cors policy
  100354. */
  100355. static SetCorsBehavior(url: string | string[], element: {
  100356. crossOrigin: string | null;
  100357. }): void;
  100358. /**
  100359. * Removes unwanted characters from an url
  100360. * @param url defines the url to clean
  100361. * @returns the cleaned url
  100362. */
  100363. static CleanUrl(url: string): string;
  100364. /**
  100365. * Gets or sets a function used to pre-process url before using them to load assets
  100366. */
  100367. static PreprocessUrl: (url: string) => string;
  100368. /**
  100369. * Loads an image as an HTMLImageElement.
  100370. * @param input url string, ArrayBuffer, or Blob to load
  100371. * @param onLoad callback called when the image successfully loads
  100372. * @param onError callback called when the image fails to load
  100373. * @param offlineProvider offline provider for caching
  100374. * @param mimeType optional mime type
  100375. * @returns the HTMLImageElement of the loaded image
  100376. */
  100377. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100378. /**
  100379. * Loads a file from a url
  100380. * @param url url string, ArrayBuffer, or Blob to load
  100381. * @param onSuccess callback called when the file successfully loads
  100382. * @param onProgress callback called while file is loading (if the server supports this mode)
  100383. * @param offlineProvider defines the offline provider for caching
  100384. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100385. * @param onError callback called when the file fails to load
  100386. * @returns a file request object
  100387. */
  100388. 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;
  100389. /**
  100390. * Loads a file from a url
  100391. * @param url the file url to load
  100392. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100393. */
  100394. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100395. /**
  100396. * Load a script (identified by an url). When the url returns, the
  100397. * content of this file is added into a new script element, attached to the DOM (body element)
  100398. * @param scriptUrl defines the url of the script to laod
  100399. * @param onSuccess defines the callback called when the script is loaded
  100400. * @param onError defines the callback to call if an error occurs
  100401. * @param scriptId defines the id of the script element
  100402. */
  100403. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100404. /**
  100405. * Load an asynchronous script (identified by an url). When the url returns, the
  100406. * content of this file is added into a new script element, attached to the DOM (body element)
  100407. * @param scriptUrl defines the url of the script to laod
  100408. * @param scriptId defines the id of the script element
  100409. * @returns a promise request object
  100410. */
  100411. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100412. /**
  100413. * Loads a file from a blob
  100414. * @param fileToLoad defines the blob to use
  100415. * @param callback defines the callback to call when data is loaded
  100416. * @param progressCallback defines the callback to call during loading process
  100417. * @returns a file request object
  100418. */
  100419. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100420. /**
  100421. * Reads a file from a File object
  100422. * @param file defines the file to load
  100423. * @param onSuccess defines the callback to call when data is loaded
  100424. * @param onProgress defines the callback to call during loading process
  100425. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100426. * @param onError defines the callback to call when an error occurs
  100427. * @returns a file request object
  100428. */
  100429. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100430. /**
  100431. * Creates a data url from a given string content
  100432. * @param content defines the content to convert
  100433. * @returns the new data url link
  100434. */
  100435. static FileAsURL(content: string): string;
  100436. /**
  100437. * Format the given number to a specific decimal format
  100438. * @param value defines the number to format
  100439. * @param decimals defines the number of decimals to use
  100440. * @returns the formatted string
  100441. */
  100442. static Format(value: number, decimals?: number): string;
  100443. /**
  100444. * Tries to copy an object by duplicating every property
  100445. * @param source defines the source object
  100446. * @param destination defines the target object
  100447. * @param doNotCopyList defines a list of properties to avoid
  100448. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100449. */
  100450. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100451. /**
  100452. * Gets a boolean indicating if the given object has no own property
  100453. * @param obj defines the object to test
  100454. * @returns true if object has no own property
  100455. */
  100456. static IsEmpty(obj: any): boolean;
  100457. /**
  100458. * Function used to register events at window level
  100459. * @param windowElement defines the Window object to use
  100460. * @param events defines the events to register
  100461. */
  100462. static RegisterTopRootEvents(windowElement: Window, events: {
  100463. name: string;
  100464. handler: Nullable<(e: FocusEvent) => any>;
  100465. }[]): void;
  100466. /**
  100467. * Function used to unregister events from window level
  100468. * @param windowElement defines the Window object to use
  100469. * @param events defines the events to unregister
  100470. */
  100471. static UnregisterTopRootEvents(windowElement: Window, events: {
  100472. name: string;
  100473. handler: Nullable<(e: FocusEvent) => any>;
  100474. }[]): void;
  100475. /**
  100476. * @ignore
  100477. */
  100478. static _ScreenshotCanvas: HTMLCanvasElement;
  100479. /**
  100480. * Dumps the current bound framebuffer
  100481. * @param width defines the rendering width
  100482. * @param height defines the rendering height
  100483. * @param engine defines the hosting engine
  100484. * @param successCallback defines the callback triggered once the data are available
  100485. * @param mimeType defines the mime type of the result
  100486. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100487. */
  100488. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100489. /**
  100490. * Converts the canvas data to blob.
  100491. * This acts as a polyfill for browsers not supporting the to blob function.
  100492. * @param canvas Defines the canvas to extract the data from
  100493. * @param successCallback Defines the callback triggered once the data are available
  100494. * @param mimeType Defines the mime type of the result
  100495. */
  100496. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100497. /**
  100498. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100499. * @param successCallback defines the callback triggered once the data are available
  100500. * @param mimeType defines the mime type of the result
  100501. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100502. */
  100503. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100504. /**
  100505. * Downloads a blob in the browser
  100506. * @param blob defines the blob to download
  100507. * @param fileName defines the name of the downloaded file
  100508. */
  100509. static Download(blob: Blob, fileName: string): void;
  100510. /**
  100511. * Captures a screenshot of the current rendering
  100512. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100513. * @param engine defines the rendering engine
  100514. * @param camera defines the source camera
  100515. * @param size This parameter can be set to a single number or to an object with the
  100516. * following (optional) properties: precision, width, height. If a single number is passed,
  100517. * it will be used for both width and height. If an object is passed, the screenshot size
  100518. * will be derived from the parameters. The precision property is a multiplier allowing
  100519. * rendering at a higher or lower resolution
  100520. * @param successCallback defines the callback receives a single parameter which contains the
  100521. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100522. * src parameter of an <img> to display it
  100523. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100524. * Check your browser for supported MIME types
  100525. */
  100526. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100527. /**
  100528. * Captures a screenshot of the current rendering
  100529. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100530. * @param engine defines the rendering engine
  100531. * @param camera defines the source camera
  100532. * @param size This parameter can be set to a single number or to an object with the
  100533. * following (optional) properties: precision, width, height. If a single number is passed,
  100534. * it will be used for both width and height. If an object is passed, the screenshot size
  100535. * will be derived from the parameters. The precision property is a multiplier allowing
  100536. * rendering at a higher or lower resolution
  100537. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100538. * Check your browser for supported MIME types
  100539. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100540. * to the src parameter of an <img> to display it
  100541. */
  100542. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100543. /**
  100544. * Generates an image screenshot from the specified camera.
  100545. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100546. * @param engine The engine to use for rendering
  100547. * @param camera The camera to use for rendering
  100548. * @param size This parameter can be set to a single number or to an object with the
  100549. * following (optional) properties: precision, width, height. If a single number is passed,
  100550. * it will be used for both width and height. If an object is passed, the screenshot size
  100551. * will be derived from the parameters. The precision property is a multiplier allowing
  100552. * rendering at a higher or lower resolution
  100553. * @param successCallback The callback receives a single parameter which contains the
  100554. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100555. * src parameter of an <img> to display it
  100556. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100557. * Check your browser for supported MIME types
  100558. * @param samples Texture samples (default: 1)
  100559. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100560. * @param fileName A name for for the downloaded file.
  100561. */
  100562. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100563. /**
  100564. * Generates an image screenshot from the specified camera.
  100565. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100566. * @param engine The engine to use for rendering
  100567. * @param camera The camera to use for rendering
  100568. * @param size This parameter can be set to a single number or to an object with the
  100569. * following (optional) properties: precision, width, height. If a single number is passed,
  100570. * it will be used for both width and height. If an object is passed, the screenshot size
  100571. * will be derived from the parameters. The precision property is a multiplier allowing
  100572. * rendering at a higher or lower resolution
  100573. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100574. * Check your browser for supported MIME types
  100575. * @param samples Texture samples (default: 1)
  100576. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100577. * @param fileName A name for for the downloaded file.
  100578. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100579. * to the src parameter of an <img> to display it
  100580. */
  100581. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100582. /**
  100583. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100584. * Be aware Math.random() could cause collisions, but:
  100585. * "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"
  100586. * @returns a pseudo random id
  100587. */
  100588. static RandomId(): string;
  100589. /**
  100590. * Test if the given uri is a base64 string
  100591. * @param uri The uri to test
  100592. * @return True if the uri is a base64 string or false otherwise
  100593. */
  100594. static IsBase64(uri: string): boolean;
  100595. /**
  100596. * Decode the given base64 uri.
  100597. * @param uri The uri to decode
  100598. * @return The decoded base64 data.
  100599. */
  100600. static DecodeBase64(uri: string): ArrayBuffer;
  100601. /**
  100602. * Gets the absolute url.
  100603. * @param url the input url
  100604. * @return the absolute url
  100605. */
  100606. static GetAbsoluteUrl(url: string): string;
  100607. /**
  100608. * No log
  100609. */
  100610. static readonly NoneLogLevel: number;
  100611. /**
  100612. * Only message logs
  100613. */
  100614. static readonly MessageLogLevel: number;
  100615. /**
  100616. * Only warning logs
  100617. */
  100618. static readonly WarningLogLevel: number;
  100619. /**
  100620. * Only error logs
  100621. */
  100622. static readonly ErrorLogLevel: number;
  100623. /**
  100624. * All logs
  100625. */
  100626. static readonly AllLogLevel: number;
  100627. /**
  100628. * Gets a value indicating the number of loading errors
  100629. * @ignorenaming
  100630. */
  100631. static readonly errorsCount: number;
  100632. /**
  100633. * Callback called when a new log is added
  100634. */
  100635. static OnNewCacheEntry: (entry: string) => void;
  100636. /**
  100637. * Log a message to the console
  100638. * @param message defines the message to log
  100639. */
  100640. static Log(message: string): void;
  100641. /**
  100642. * Write a warning message to the console
  100643. * @param message defines the message to log
  100644. */
  100645. static Warn(message: string): void;
  100646. /**
  100647. * Write an error message to the console
  100648. * @param message defines the message to log
  100649. */
  100650. static Error(message: string): void;
  100651. /**
  100652. * Gets current log cache (list of logs)
  100653. */
  100654. static readonly LogCache: string;
  100655. /**
  100656. * Clears the log cache
  100657. */
  100658. static ClearLogCache(): void;
  100659. /**
  100660. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100661. */
  100662. static LogLevels: number;
  100663. /**
  100664. * Checks if the window object exists
  100665. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100666. */
  100667. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100668. /**
  100669. * No performance log
  100670. */
  100671. static readonly PerformanceNoneLogLevel: number;
  100672. /**
  100673. * Use user marks to log performance
  100674. */
  100675. static readonly PerformanceUserMarkLogLevel: number;
  100676. /**
  100677. * Log performance to the console
  100678. */
  100679. static readonly PerformanceConsoleLogLevel: number;
  100680. private static _performance;
  100681. /**
  100682. * Sets the current performance log level
  100683. */
  100684. static PerformanceLogLevel: number;
  100685. private static _StartPerformanceCounterDisabled;
  100686. private static _EndPerformanceCounterDisabled;
  100687. private static _StartUserMark;
  100688. private static _EndUserMark;
  100689. private static _StartPerformanceConsole;
  100690. private static _EndPerformanceConsole;
  100691. /**
  100692. * Starts a performance counter
  100693. */
  100694. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100695. /**
  100696. * Ends a specific performance coutner
  100697. */
  100698. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100699. /**
  100700. * Gets either window.performance.now() if supported or Date.now() else
  100701. */
  100702. static readonly Now: number;
  100703. /**
  100704. * This method will return the name of the class used to create the instance of the given object.
  100705. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100706. * @param object the object to get the class name from
  100707. * @param isType defines if the object is actually a type
  100708. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100709. */
  100710. static GetClassName(object: any, isType?: boolean): string;
  100711. /**
  100712. * Gets the first element of an array satisfying a given predicate
  100713. * @param array defines the array to browse
  100714. * @param predicate defines the predicate to use
  100715. * @returns null if not found or the element
  100716. */
  100717. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100718. /**
  100719. * This method will return the name of the full name of the class, including its owning module (if any).
  100720. * 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).
  100721. * @param object the object to get the class name from
  100722. * @param isType defines if the object is actually a type
  100723. * @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.
  100724. * @ignorenaming
  100725. */
  100726. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100727. /**
  100728. * Returns a promise that resolves after the given amount of time.
  100729. * @param delay Number of milliseconds to delay
  100730. * @returns Promise that resolves after the given amount of time
  100731. */
  100732. static DelayAsync(delay: number): Promise<void>;
  100733. }
  100734. /**
  100735. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100736. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100737. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100738. * @param name The name of the class, case should be preserved
  100739. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100740. */
  100741. export function className(name: string, module?: string): (target: Object) => void;
  100742. /**
  100743. * An implementation of a loop for asynchronous functions.
  100744. */
  100745. export class AsyncLoop {
  100746. /**
  100747. * Defines the number of iterations for the loop
  100748. */
  100749. iterations: number;
  100750. /**
  100751. * Defines the current index of the loop.
  100752. */
  100753. index: number;
  100754. private _done;
  100755. private _fn;
  100756. private _successCallback;
  100757. /**
  100758. * Constructor.
  100759. * @param iterations the number of iterations.
  100760. * @param func the function to run each iteration
  100761. * @param successCallback the callback that will be called upon succesful execution
  100762. * @param offset starting offset.
  100763. */
  100764. constructor(
  100765. /**
  100766. * Defines the number of iterations for the loop
  100767. */
  100768. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100769. /**
  100770. * Execute the next iteration. Must be called after the last iteration was finished.
  100771. */
  100772. executeNext(): void;
  100773. /**
  100774. * Break the loop and run the success callback.
  100775. */
  100776. breakLoop(): void;
  100777. /**
  100778. * Create and run an async loop.
  100779. * @param iterations the number of iterations.
  100780. * @param fn the function to run each iteration
  100781. * @param successCallback the callback that will be called upon succesful execution
  100782. * @param offset starting offset.
  100783. * @returns the created async loop object
  100784. */
  100785. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100786. /**
  100787. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100788. * @param iterations total number of iterations
  100789. * @param syncedIterations number of synchronous iterations in each async iteration.
  100790. * @param fn the function to call each iteration.
  100791. * @param callback a success call back that will be called when iterating stops.
  100792. * @param breakFunction a break condition (optional)
  100793. * @param timeout timeout settings for the setTimeout function. default - 0.
  100794. * @returns the created async loop object
  100795. */
  100796. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100797. }
  100798. }
  100799. declare module BABYLON {
  100800. /**
  100801. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100802. * The underlying implementation relies on an associative array to ensure the best performances.
  100803. * The value can be anything including 'null' but except 'undefined'
  100804. */
  100805. export class StringDictionary<T> {
  100806. /**
  100807. * This will clear this dictionary and copy the content from the 'source' one.
  100808. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100809. * @param source the dictionary to take the content from and copy to this dictionary
  100810. */
  100811. copyFrom(source: StringDictionary<T>): void;
  100812. /**
  100813. * Get a value based from its key
  100814. * @param key the given key to get the matching value from
  100815. * @return the value if found, otherwise undefined is returned
  100816. */
  100817. get(key: string): T | undefined;
  100818. /**
  100819. * Get a value from its key or add it if it doesn't exist.
  100820. * This method will ensure you that a given key/data will be present in the dictionary.
  100821. * @param key the given key to get the matching value from
  100822. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100823. * The factory will only be invoked if there's no data for the given key.
  100824. * @return the value corresponding to the key.
  100825. */
  100826. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100827. /**
  100828. * Get a value from its key if present in the dictionary otherwise add it
  100829. * @param key the key to get the value from
  100830. * @param val if there's no such key/value pair in the dictionary add it with this value
  100831. * @return the value corresponding to the key
  100832. */
  100833. getOrAdd(key: string, val: T): T;
  100834. /**
  100835. * Check if there's a given key in the dictionary
  100836. * @param key the key to check for
  100837. * @return true if the key is present, false otherwise
  100838. */
  100839. contains(key: string): boolean;
  100840. /**
  100841. * Add a new key and its corresponding value
  100842. * @param key the key to add
  100843. * @param value the value corresponding to the key
  100844. * @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
  100845. */
  100846. add(key: string, value: T): boolean;
  100847. /**
  100848. * Update a specific value associated to a key
  100849. * @param key defines the key to use
  100850. * @param value defines the value to store
  100851. * @returns true if the value was updated (or false if the key was not found)
  100852. */
  100853. set(key: string, value: T): boolean;
  100854. /**
  100855. * Get the element of the given key and remove it from the dictionary
  100856. * @param key defines the key to search
  100857. * @returns the value associated with the key or null if not found
  100858. */
  100859. getAndRemove(key: string): Nullable<T>;
  100860. /**
  100861. * Remove a key/value from the dictionary.
  100862. * @param key the key to remove
  100863. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100864. */
  100865. remove(key: string): boolean;
  100866. /**
  100867. * Clear the whole content of the dictionary
  100868. */
  100869. clear(): void;
  100870. /**
  100871. * Gets the current count
  100872. */
  100873. readonly count: number;
  100874. /**
  100875. * Execute a callback on each key/val of the dictionary.
  100876. * Note that you can remove any element in this dictionary in the callback implementation
  100877. * @param callback the callback to execute on a given key/value pair
  100878. */
  100879. forEach(callback: (key: string, val: T) => void): void;
  100880. /**
  100881. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100882. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100883. * Note that you can remove any element in this dictionary in the callback implementation
  100884. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100885. * @returns the first item
  100886. */
  100887. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100888. private _count;
  100889. private _data;
  100890. }
  100891. }
  100892. declare module BABYLON {
  100893. /** @hidden */
  100894. export interface ICollisionCoordinator {
  100895. createCollider(): Collider;
  100896. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100897. init(scene: Scene): void;
  100898. }
  100899. /** @hidden */
  100900. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100901. private _scene;
  100902. private _scaledPosition;
  100903. private _scaledVelocity;
  100904. private _finalPosition;
  100905. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100906. createCollider(): Collider;
  100907. init(scene: Scene): void;
  100908. private _collideWithWorld;
  100909. }
  100910. }
  100911. declare module BABYLON {
  100912. /**
  100913. * Class used to manage all inputs for the scene.
  100914. */
  100915. export class InputManager {
  100916. /** The distance in pixel that you have to move to prevent some events */
  100917. static DragMovementThreshold: number;
  100918. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100919. static LongPressDelay: number;
  100920. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100921. static DoubleClickDelay: number;
  100922. /** If you need to check double click without raising a single click at first click, enable this flag */
  100923. static ExclusiveDoubleClickMode: boolean;
  100924. private _wheelEventName;
  100925. private _onPointerMove;
  100926. private _onPointerDown;
  100927. private _onPointerUp;
  100928. private _initClickEvent;
  100929. private _initActionManager;
  100930. private _delayedSimpleClick;
  100931. private _delayedSimpleClickTimeout;
  100932. private _previousDelayedSimpleClickTimeout;
  100933. private _meshPickProceed;
  100934. private _previousButtonPressed;
  100935. private _currentPickResult;
  100936. private _previousPickResult;
  100937. private _totalPointersPressed;
  100938. private _doubleClickOccured;
  100939. private _pointerOverMesh;
  100940. private _pickedDownMesh;
  100941. private _pickedUpMesh;
  100942. private _pointerX;
  100943. private _pointerY;
  100944. private _unTranslatedPointerX;
  100945. private _unTranslatedPointerY;
  100946. private _startingPointerPosition;
  100947. private _previousStartingPointerPosition;
  100948. private _startingPointerTime;
  100949. private _previousStartingPointerTime;
  100950. private _pointerCaptures;
  100951. private _onKeyDown;
  100952. private _onKeyUp;
  100953. private _onCanvasFocusObserver;
  100954. private _onCanvasBlurObserver;
  100955. private _scene;
  100956. /**
  100957. * Creates a new InputManager
  100958. * @param scene defines the hosting scene
  100959. */
  100960. constructor(scene: Scene);
  100961. /**
  100962. * Gets the mesh that is currently under the pointer
  100963. */
  100964. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100965. /**
  100966. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100967. */
  100968. readonly unTranslatedPointer: Vector2;
  100969. /**
  100970. * Gets or sets the current on-screen X position of the pointer
  100971. */
  100972. pointerX: number;
  100973. /**
  100974. * Gets or sets the current on-screen Y position of the pointer
  100975. */
  100976. pointerY: number;
  100977. private _updatePointerPosition;
  100978. private _processPointerMove;
  100979. private _setRayOnPointerInfo;
  100980. private _checkPrePointerObservable;
  100981. /**
  100982. * Use this method to simulate a pointer move on a mesh
  100983. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100984. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100985. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100986. */
  100987. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100988. /**
  100989. * Use this method to simulate a pointer down on a mesh
  100990. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100991. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100992. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100993. */
  100994. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100995. private _processPointerDown;
  100996. /** @hidden */
  100997. _isPointerSwiping(): boolean;
  100998. /**
  100999. * Use this method to simulate a pointer up on a mesh
  101000. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101001. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101002. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101003. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101004. */
  101005. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101006. private _processPointerUp;
  101007. /**
  101008. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101009. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101010. * @returns true if the pointer was captured
  101011. */
  101012. isPointerCaptured(pointerId?: number): boolean;
  101013. /**
  101014. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101015. * @param attachUp defines if you want to attach events to pointerup
  101016. * @param attachDown defines if you want to attach events to pointerdown
  101017. * @param attachMove defines if you want to attach events to pointermove
  101018. */
  101019. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101020. /**
  101021. * Detaches all event handlers
  101022. */
  101023. detachControl(): void;
  101024. /**
  101025. * Force the value of meshUnderPointer
  101026. * @param mesh defines the mesh to use
  101027. */
  101028. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101029. /**
  101030. * Gets the mesh under the pointer
  101031. * @returns a Mesh or null if no mesh is under the pointer
  101032. */
  101033. getPointerOverMesh(): Nullable<AbstractMesh>;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * Helper class used to generate session unique ID
  101039. */
  101040. export class UniqueIdGenerator {
  101041. private static _UniqueIdCounter;
  101042. /**
  101043. * Gets an unique (relatively to the current scene) Id
  101044. */
  101045. static readonly UniqueId: number;
  101046. }
  101047. }
  101048. declare module BABYLON {
  101049. /**
  101050. * This class defines the direct association between an animation and a target
  101051. */
  101052. export class TargetedAnimation {
  101053. /**
  101054. * Animation to perform
  101055. */
  101056. animation: Animation;
  101057. /**
  101058. * Target to animate
  101059. */
  101060. target: any;
  101061. /**
  101062. * Serialize the object
  101063. * @returns the JSON object representing the current entity
  101064. */
  101065. serialize(): any;
  101066. }
  101067. /**
  101068. * Use this class to create coordinated animations on multiple targets
  101069. */
  101070. export class AnimationGroup implements IDisposable {
  101071. /** The name of the animation group */
  101072. name: string;
  101073. private _scene;
  101074. private _targetedAnimations;
  101075. private _animatables;
  101076. private _from;
  101077. private _to;
  101078. private _isStarted;
  101079. private _isPaused;
  101080. private _speedRatio;
  101081. private _loopAnimation;
  101082. /**
  101083. * Gets or sets the unique id of the node
  101084. */
  101085. uniqueId: number;
  101086. /**
  101087. * This observable will notify when one animation have ended
  101088. */
  101089. onAnimationEndObservable: Observable<TargetedAnimation>;
  101090. /**
  101091. * Observer raised when one animation loops
  101092. */
  101093. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101094. /**
  101095. * Observer raised when all animations have looped
  101096. */
  101097. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101098. /**
  101099. * This observable will notify when all animations have ended.
  101100. */
  101101. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101102. /**
  101103. * This observable will notify when all animations have paused.
  101104. */
  101105. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101106. /**
  101107. * This observable will notify when all animations are playing.
  101108. */
  101109. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101110. /**
  101111. * Gets the first frame
  101112. */
  101113. readonly from: number;
  101114. /**
  101115. * Gets the last frame
  101116. */
  101117. readonly to: number;
  101118. /**
  101119. * Define if the animations are started
  101120. */
  101121. readonly isStarted: boolean;
  101122. /**
  101123. * Gets a value indicating that the current group is playing
  101124. */
  101125. readonly isPlaying: boolean;
  101126. /**
  101127. * Gets or sets the speed ratio to use for all animations
  101128. */
  101129. /**
  101130. * Gets or sets the speed ratio to use for all animations
  101131. */
  101132. speedRatio: number;
  101133. /**
  101134. * Gets or sets if all animations should loop or not
  101135. */
  101136. loopAnimation: boolean;
  101137. /**
  101138. * Gets the targeted animations for this animation group
  101139. */
  101140. readonly targetedAnimations: Array<TargetedAnimation>;
  101141. /**
  101142. * returning the list of animatables controlled by this animation group.
  101143. */
  101144. readonly animatables: Array<Animatable>;
  101145. /**
  101146. * Instantiates a new Animation Group.
  101147. * This helps managing several animations at once.
  101148. * @see http://doc.babylonjs.com/how_to/group
  101149. * @param name Defines the name of the group
  101150. * @param scene Defines the scene the group belongs to
  101151. */
  101152. constructor(
  101153. /** The name of the animation group */
  101154. name: string, scene?: Nullable<Scene>);
  101155. /**
  101156. * Add an animation (with its target) in the group
  101157. * @param animation defines the animation we want to add
  101158. * @param target defines the target of the animation
  101159. * @returns the TargetedAnimation object
  101160. */
  101161. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101162. /**
  101163. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101164. * It can add constant keys at begin or end
  101165. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101166. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101167. * @returns the animation group
  101168. */
  101169. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101170. private _animationLoopCount;
  101171. private _animationLoopFlags;
  101172. private _processLoop;
  101173. /**
  101174. * Start all animations on given targets
  101175. * @param loop defines if animations must loop
  101176. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101177. * @param from defines the from key (optional)
  101178. * @param to defines the to key (optional)
  101179. * @returns the current animation group
  101180. */
  101181. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101182. /**
  101183. * Pause all animations
  101184. * @returns the animation group
  101185. */
  101186. pause(): AnimationGroup;
  101187. /**
  101188. * Play all animations to initial state
  101189. * This function will start() the animations if they were not started or will restart() them if they were paused
  101190. * @param loop defines if animations must loop
  101191. * @returns the animation group
  101192. */
  101193. play(loop?: boolean): AnimationGroup;
  101194. /**
  101195. * Reset all animations to initial state
  101196. * @returns the animation group
  101197. */
  101198. reset(): AnimationGroup;
  101199. /**
  101200. * Restart animations from key 0
  101201. * @returns the animation group
  101202. */
  101203. restart(): AnimationGroup;
  101204. /**
  101205. * Stop all animations
  101206. * @returns the animation group
  101207. */
  101208. stop(): AnimationGroup;
  101209. /**
  101210. * Set animation weight for all animatables
  101211. * @param weight defines the weight to use
  101212. * @return the animationGroup
  101213. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101214. */
  101215. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101216. /**
  101217. * Synchronize and normalize all animatables with a source animatable
  101218. * @param root defines the root animatable to synchronize with
  101219. * @return the animationGroup
  101220. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101221. */
  101222. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101223. /**
  101224. * Goes to a specific frame in this animation group
  101225. * @param frame the frame number to go to
  101226. * @return the animationGroup
  101227. */
  101228. goToFrame(frame: number): AnimationGroup;
  101229. /**
  101230. * Dispose all associated resources
  101231. */
  101232. dispose(): void;
  101233. private _checkAnimationGroupEnded;
  101234. /**
  101235. * Clone the current animation group and returns a copy
  101236. * @param newName defines the name of the new group
  101237. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101238. * @returns the new aniamtion group
  101239. */
  101240. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101241. /**
  101242. * Serializes the animationGroup to an object
  101243. * @returns Serialized object
  101244. */
  101245. serialize(): any;
  101246. /**
  101247. * Returns a new AnimationGroup object parsed from the source provided.
  101248. * @param parsedAnimationGroup defines the source
  101249. * @param scene defines the scene that will receive the animationGroup
  101250. * @returns a new AnimationGroup
  101251. */
  101252. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101253. /**
  101254. * Returns the string "AnimationGroup"
  101255. * @returns "AnimationGroup"
  101256. */
  101257. getClassName(): string;
  101258. /**
  101259. * Creates a detailled string about the object
  101260. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101261. * @returns a string representing the object
  101262. */
  101263. toString(fullDetails?: boolean): string;
  101264. }
  101265. }
  101266. declare module BABYLON {
  101267. /**
  101268. * Define an interface for all classes that will hold resources
  101269. */
  101270. export interface IDisposable {
  101271. /**
  101272. * Releases all held resources
  101273. */
  101274. dispose(): void;
  101275. }
  101276. /** Interface defining initialization parameters for Scene class */
  101277. export interface SceneOptions {
  101278. /**
  101279. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101280. * It will improve performance when the number of geometries becomes important.
  101281. */
  101282. useGeometryUniqueIdsMap?: boolean;
  101283. /**
  101284. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101285. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101286. */
  101287. useMaterialMeshMap?: boolean;
  101288. /**
  101289. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101290. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101291. */
  101292. useClonedMeshhMap?: boolean;
  101293. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101294. virtual?: boolean;
  101295. }
  101296. /**
  101297. * Represents a scene to be rendered by the engine.
  101298. * @see http://doc.babylonjs.com/features/scene
  101299. */
  101300. export class Scene extends AbstractScene implements IAnimatable {
  101301. /** The fog is deactivated */
  101302. static readonly FOGMODE_NONE: number;
  101303. /** The fog density is following an exponential function */
  101304. static readonly FOGMODE_EXP: number;
  101305. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101306. static readonly FOGMODE_EXP2: number;
  101307. /** The fog density is following a linear function. */
  101308. static readonly FOGMODE_LINEAR: number;
  101309. /**
  101310. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101312. */
  101313. static MinDeltaTime: number;
  101314. /**
  101315. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101317. */
  101318. static MaxDeltaTime: number;
  101319. /**
  101320. * Factory used to create the default material.
  101321. * @param name The name of the material to create
  101322. * @param scene The scene to create the material for
  101323. * @returns The default material
  101324. */
  101325. static DefaultMaterialFactory(scene: Scene): Material;
  101326. /**
  101327. * Factory used to create the a collision coordinator.
  101328. * @returns The collision coordinator
  101329. */
  101330. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101331. /** @hidden */
  101332. _inputManager: InputManager;
  101333. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101334. cameraToUseForPointers: Nullable<Camera>;
  101335. /** @hidden */
  101336. readonly _isScene: boolean;
  101337. /**
  101338. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101339. */
  101340. autoClear: boolean;
  101341. /**
  101342. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101343. */
  101344. autoClearDepthAndStencil: boolean;
  101345. /**
  101346. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101347. */
  101348. clearColor: Color4;
  101349. /**
  101350. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101351. */
  101352. ambientColor: Color3;
  101353. /**
  101354. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101355. * It should only be one of the following (if not the default embedded one):
  101356. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101357. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101358. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101359. * The material properties need to be setup according to the type of texture in use.
  101360. */
  101361. environmentBRDFTexture: BaseTexture;
  101362. /** @hidden */
  101363. protected _environmentTexture: Nullable<BaseTexture>;
  101364. /**
  101365. * Texture used in all pbr material as the reflection texture.
  101366. * As in the majority of the scene they are the same (exception for multi room and so on),
  101367. * this is easier to reference from here than from all the materials.
  101368. */
  101369. /**
  101370. * Texture used in all pbr material as the reflection texture.
  101371. * As in the majority of the scene they are the same (exception for multi room and so on),
  101372. * this is easier to set here than in all the materials.
  101373. */
  101374. environmentTexture: Nullable<BaseTexture>;
  101375. /** @hidden */
  101376. protected _environmentIntensity: number;
  101377. /**
  101378. * Intensity of the environment in all pbr material.
  101379. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101380. * As in the majority of the scene they are the same (exception for multi room and so on),
  101381. * this is easier to reference from here than from all the materials.
  101382. */
  101383. /**
  101384. * Intensity of the environment in all pbr material.
  101385. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101386. * As in the majority of the scene they are the same (exception for multi room and so on),
  101387. * this is easier to set here than in all the materials.
  101388. */
  101389. environmentIntensity: number;
  101390. /** @hidden */
  101391. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101392. /**
  101393. * Default image processing configuration used either in the rendering
  101394. * Forward main pass or through the imageProcessingPostProcess if present.
  101395. * As in the majority of the scene they are the same (exception for multi camera),
  101396. * this is easier to reference from here than from all the materials and post process.
  101397. *
  101398. * No setter as we it is a shared configuration, you can set the values instead.
  101399. */
  101400. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101401. private _forceWireframe;
  101402. /**
  101403. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101404. */
  101405. forceWireframe: boolean;
  101406. private _forcePointsCloud;
  101407. /**
  101408. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101409. */
  101410. forcePointsCloud: boolean;
  101411. /**
  101412. * Gets or sets the active clipplane 1
  101413. */
  101414. clipPlane: Nullable<Plane>;
  101415. /**
  101416. * Gets or sets the active clipplane 2
  101417. */
  101418. clipPlane2: Nullable<Plane>;
  101419. /**
  101420. * Gets or sets the active clipplane 3
  101421. */
  101422. clipPlane3: Nullable<Plane>;
  101423. /**
  101424. * Gets or sets the active clipplane 4
  101425. */
  101426. clipPlane4: Nullable<Plane>;
  101427. /**
  101428. * Gets or sets a boolean indicating if animations are enabled
  101429. */
  101430. animationsEnabled: boolean;
  101431. private _animationPropertiesOverride;
  101432. /**
  101433. * Gets or sets the animation properties override
  101434. */
  101435. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101436. /**
  101437. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101438. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101439. */
  101440. useConstantAnimationDeltaTime: boolean;
  101441. /**
  101442. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101443. * Please note that it requires to run a ray cast through the scene on every frame
  101444. */
  101445. constantlyUpdateMeshUnderPointer: boolean;
  101446. /**
  101447. * Defines the HTML cursor to use when hovering over interactive elements
  101448. */
  101449. hoverCursor: string;
  101450. /**
  101451. * Defines the HTML default cursor to use (empty by default)
  101452. */
  101453. defaultCursor: string;
  101454. /**
  101455. * Defines wether cursors are handled by the scene.
  101456. */
  101457. doNotHandleCursors: boolean;
  101458. /**
  101459. * This is used to call preventDefault() on pointer down
  101460. * in order to block unwanted artifacts like system double clicks
  101461. */
  101462. preventDefaultOnPointerDown: boolean;
  101463. /**
  101464. * This is used to call preventDefault() on pointer up
  101465. * in order to block unwanted artifacts like system double clicks
  101466. */
  101467. preventDefaultOnPointerUp: boolean;
  101468. /**
  101469. * Gets or sets user defined metadata
  101470. */
  101471. metadata: any;
  101472. /**
  101473. * For internal use only. Please do not use.
  101474. */
  101475. reservedDataStore: any;
  101476. /**
  101477. * Gets the name of the plugin used to load this scene (null by default)
  101478. */
  101479. loadingPluginName: string;
  101480. /**
  101481. * Use this array to add regular expressions used to disable offline support for specific urls
  101482. */
  101483. disableOfflineSupportExceptionRules: RegExp[];
  101484. /**
  101485. * An event triggered when the scene is disposed.
  101486. */
  101487. onDisposeObservable: Observable<Scene>;
  101488. private _onDisposeObserver;
  101489. /** Sets a function to be executed when this scene is disposed. */
  101490. onDispose: () => void;
  101491. /**
  101492. * An event triggered before rendering the scene (right after animations and physics)
  101493. */
  101494. onBeforeRenderObservable: Observable<Scene>;
  101495. private _onBeforeRenderObserver;
  101496. /** Sets a function to be executed before rendering this scene */
  101497. beforeRender: Nullable<() => void>;
  101498. /**
  101499. * An event triggered after rendering the scene
  101500. */
  101501. onAfterRenderObservable: Observable<Scene>;
  101502. /**
  101503. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101504. */
  101505. onAfterRenderCameraObservable: Observable<Camera>;
  101506. private _onAfterRenderObserver;
  101507. /** Sets a function to be executed after rendering this scene */
  101508. afterRender: Nullable<() => void>;
  101509. /**
  101510. * An event triggered before animating the scene
  101511. */
  101512. onBeforeAnimationsObservable: Observable<Scene>;
  101513. /**
  101514. * An event triggered after animations processing
  101515. */
  101516. onAfterAnimationsObservable: Observable<Scene>;
  101517. /**
  101518. * An event triggered before draw calls are ready to be sent
  101519. */
  101520. onBeforeDrawPhaseObservable: Observable<Scene>;
  101521. /**
  101522. * An event triggered after draw calls have been sent
  101523. */
  101524. onAfterDrawPhaseObservable: Observable<Scene>;
  101525. /**
  101526. * An event triggered when the scene is ready
  101527. */
  101528. onReadyObservable: Observable<Scene>;
  101529. /**
  101530. * An event triggered before rendering a camera
  101531. */
  101532. onBeforeCameraRenderObservable: Observable<Camera>;
  101533. private _onBeforeCameraRenderObserver;
  101534. /** Sets a function to be executed before rendering a camera*/
  101535. beforeCameraRender: () => void;
  101536. /**
  101537. * An event triggered after rendering a camera
  101538. */
  101539. onAfterCameraRenderObservable: Observable<Camera>;
  101540. private _onAfterCameraRenderObserver;
  101541. /** Sets a function to be executed after rendering a camera*/
  101542. afterCameraRender: () => void;
  101543. /**
  101544. * An event triggered when active meshes evaluation is about to start
  101545. */
  101546. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101547. /**
  101548. * An event triggered when active meshes evaluation is done
  101549. */
  101550. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101551. /**
  101552. * An event triggered when particles rendering is about to start
  101553. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101554. */
  101555. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101556. /**
  101557. * An event triggered when particles rendering is done
  101558. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101559. */
  101560. onAfterParticlesRenderingObservable: Observable<Scene>;
  101561. /**
  101562. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101563. */
  101564. onDataLoadedObservable: Observable<Scene>;
  101565. /**
  101566. * An event triggered when a camera is created
  101567. */
  101568. onNewCameraAddedObservable: Observable<Camera>;
  101569. /**
  101570. * An event triggered when a camera is removed
  101571. */
  101572. onCameraRemovedObservable: Observable<Camera>;
  101573. /**
  101574. * An event triggered when a light is created
  101575. */
  101576. onNewLightAddedObservable: Observable<Light>;
  101577. /**
  101578. * An event triggered when a light is removed
  101579. */
  101580. onLightRemovedObservable: Observable<Light>;
  101581. /**
  101582. * An event triggered when a geometry is created
  101583. */
  101584. onNewGeometryAddedObservable: Observable<Geometry>;
  101585. /**
  101586. * An event triggered when a geometry is removed
  101587. */
  101588. onGeometryRemovedObservable: Observable<Geometry>;
  101589. /**
  101590. * An event triggered when a transform node is created
  101591. */
  101592. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101593. /**
  101594. * An event triggered when a transform node is removed
  101595. */
  101596. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101597. /**
  101598. * An event triggered when a mesh is created
  101599. */
  101600. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101601. /**
  101602. * An event triggered when a mesh is removed
  101603. */
  101604. onMeshRemovedObservable: Observable<AbstractMesh>;
  101605. /**
  101606. * An event triggered when a skeleton is created
  101607. */
  101608. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101609. /**
  101610. * An event triggered when a skeleton is removed
  101611. */
  101612. onSkeletonRemovedObservable: Observable<Skeleton>;
  101613. /**
  101614. * An event triggered when a material is created
  101615. */
  101616. onNewMaterialAddedObservable: Observable<Material>;
  101617. /**
  101618. * An event triggered when a material is removed
  101619. */
  101620. onMaterialRemovedObservable: Observable<Material>;
  101621. /**
  101622. * An event triggered when a texture is created
  101623. */
  101624. onNewTextureAddedObservable: Observable<BaseTexture>;
  101625. /**
  101626. * An event triggered when a texture is removed
  101627. */
  101628. onTextureRemovedObservable: Observable<BaseTexture>;
  101629. /**
  101630. * An event triggered when render targets are about to be rendered
  101631. * Can happen multiple times per frame.
  101632. */
  101633. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101634. /**
  101635. * An event triggered when render targets were rendered.
  101636. * Can happen multiple times per frame.
  101637. */
  101638. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101639. /**
  101640. * An event triggered before calculating deterministic simulation step
  101641. */
  101642. onBeforeStepObservable: Observable<Scene>;
  101643. /**
  101644. * An event triggered after calculating deterministic simulation step
  101645. */
  101646. onAfterStepObservable: Observable<Scene>;
  101647. /**
  101648. * An event triggered when the activeCamera property is updated
  101649. */
  101650. onActiveCameraChanged: Observable<Scene>;
  101651. /**
  101652. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101653. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101654. * 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)
  101655. */
  101656. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101657. /**
  101658. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101659. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101660. * 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)
  101661. */
  101662. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101663. /**
  101664. * This Observable will when a mesh has been imported into the scene.
  101665. */
  101666. onMeshImportedObservable: Observable<AbstractMesh>;
  101667. /**
  101668. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101669. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101670. */
  101671. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101672. /** @hidden */
  101673. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101674. /**
  101675. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101676. */
  101677. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101678. /**
  101679. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101680. */
  101681. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101682. /**
  101683. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101684. */
  101685. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101686. /** Callback called when a pointer move is detected */
  101687. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101688. /** Callback called when a pointer down is detected */
  101689. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101690. /** Callback called when a pointer up is detected */
  101691. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101692. /** Callback called when a pointer pick is detected */
  101693. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101694. /**
  101695. * 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).
  101696. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101697. */
  101698. onPrePointerObservable: Observable<PointerInfoPre>;
  101699. /**
  101700. * Observable event triggered each time an input event is received from the rendering canvas
  101701. */
  101702. onPointerObservable: Observable<PointerInfo>;
  101703. /**
  101704. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101705. */
  101706. readonly unTranslatedPointer: Vector2;
  101707. /**
  101708. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101709. */
  101710. static DragMovementThreshold: number;
  101711. /**
  101712. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101713. */
  101714. static LongPressDelay: number;
  101715. /**
  101716. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101717. */
  101718. static DoubleClickDelay: number;
  101719. /** If you need to check double click without raising a single click at first click, enable this flag */
  101720. static ExclusiveDoubleClickMode: boolean;
  101721. /** @hidden */
  101722. _mirroredCameraPosition: Nullable<Vector3>;
  101723. /**
  101724. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101725. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101726. */
  101727. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101728. /**
  101729. * Observable event triggered each time an keyboard event is received from the hosting window
  101730. */
  101731. onKeyboardObservable: Observable<KeyboardInfo>;
  101732. private _useRightHandedSystem;
  101733. /**
  101734. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101735. */
  101736. useRightHandedSystem: boolean;
  101737. private _timeAccumulator;
  101738. private _currentStepId;
  101739. private _currentInternalStep;
  101740. /**
  101741. * Sets the step Id used by deterministic lock step
  101742. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101743. * @param newStepId defines the step Id
  101744. */
  101745. setStepId(newStepId: number): void;
  101746. /**
  101747. * Gets the step Id used by deterministic lock step
  101748. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101749. * @returns the step Id
  101750. */
  101751. getStepId(): number;
  101752. /**
  101753. * Gets the internal step used by deterministic lock step
  101754. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101755. * @returns the internal step
  101756. */
  101757. getInternalStep(): number;
  101758. private _fogEnabled;
  101759. /**
  101760. * Gets or sets a boolean indicating if fog is enabled on this scene
  101761. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101762. * (Default is true)
  101763. */
  101764. fogEnabled: boolean;
  101765. private _fogMode;
  101766. /**
  101767. * Gets or sets the fog mode to use
  101768. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101769. * | mode | value |
  101770. * | --- | --- |
  101771. * | FOGMODE_NONE | 0 |
  101772. * | FOGMODE_EXP | 1 |
  101773. * | FOGMODE_EXP2 | 2 |
  101774. * | FOGMODE_LINEAR | 3 |
  101775. */
  101776. fogMode: number;
  101777. /**
  101778. * Gets or sets the fog color to use
  101779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101780. * (Default is Color3(0.2, 0.2, 0.3))
  101781. */
  101782. fogColor: Color3;
  101783. /**
  101784. * Gets or sets the fog density to use
  101785. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101786. * (Default is 0.1)
  101787. */
  101788. fogDensity: number;
  101789. /**
  101790. * Gets or sets the fog start distance to use
  101791. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101792. * (Default is 0)
  101793. */
  101794. fogStart: number;
  101795. /**
  101796. * Gets or sets the fog end distance to use
  101797. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101798. * (Default is 1000)
  101799. */
  101800. fogEnd: number;
  101801. private _shadowsEnabled;
  101802. /**
  101803. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101804. */
  101805. shadowsEnabled: boolean;
  101806. private _lightsEnabled;
  101807. /**
  101808. * Gets or sets a boolean indicating if lights are enabled on this scene
  101809. */
  101810. lightsEnabled: boolean;
  101811. /** All of the active cameras added to this scene. */
  101812. activeCameras: Camera[];
  101813. /** @hidden */
  101814. _activeCamera: Nullable<Camera>;
  101815. /** Gets or sets the current active camera */
  101816. activeCamera: Nullable<Camera>;
  101817. private _defaultMaterial;
  101818. /** The default material used on meshes when no material is affected */
  101819. /** The default material used on meshes when no material is affected */
  101820. defaultMaterial: Material;
  101821. private _texturesEnabled;
  101822. /**
  101823. * Gets or sets a boolean indicating if textures are enabled on this scene
  101824. */
  101825. texturesEnabled: boolean;
  101826. /**
  101827. * Gets or sets a boolean indicating if particles are enabled on this scene
  101828. */
  101829. particlesEnabled: boolean;
  101830. /**
  101831. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101832. */
  101833. spritesEnabled: boolean;
  101834. private _skeletonsEnabled;
  101835. /**
  101836. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101837. */
  101838. skeletonsEnabled: boolean;
  101839. /**
  101840. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101841. */
  101842. lensFlaresEnabled: boolean;
  101843. /**
  101844. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101846. */
  101847. collisionsEnabled: boolean;
  101848. private _collisionCoordinator;
  101849. /** @hidden */
  101850. readonly collisionCoordinator: ICollisionCoordinator;
  101851. /**
  101852. * Defines the gravity applied to this scene (used only for collisions)
  101853. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101854. */
  101855. gravity: Vector3;
  101856. /**
  101857. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101858. */
  101859. postProcessesEnabled: boolean;
  101860. /**
  101861. * The list of postprocesses added to the scene
  101862. */
  101863. postProcesses: PostProcess[];
  101864. /**
  101865. * Gets the current postprocess manager
  101866. */
  101867. postProcessManager: PostProcessManager;
  101868. /**
  101869. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101870. */
  101871. renderTargetsEnabled: boolean;
  101872. /**
  101873. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101874. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101875. */
  101876. dumpNextRenderTargets: boolean;
  101877. /**
  101878. * The list of user defined render targets added to the scene
  101879. */
  101880. customRenderTargets: RenderTargetTexture[];
  101881. /**
  101882. * Defines if texture loading must be delayed
  101883. * If true, textures will only be loaded when they need to be rendered
  101884. */
  101885. useDelayedTextureLoading: boolean;
  101886. /**
  101887. * Gets the list of meshes imported to the scene through SceneLoader
  101888. */
  101889. importedMeshesFiles: String[];
  101890. /**
  101891. * Gets or sets a boolean indicating if probes are enabled on this scene
  101892. */
  101893. probesEnabled: boolean;
  101894. /**
  101895. * Gets or sets the current offline provider to use to store scene data
  101896. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101897. */
  101898. offlineProvider: IOfflineProvider;
  101899. /**
  101900. * Gets or sets the action manager associated with the scene
  101901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101902. */
  101903. actionManager: AbstractActionManager;
  101904. private _meshesForIntersections;
  101905. /**
  101906. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101907. */
  101908. proceduralTexturesEnabled: boolean;
  101909. private _engine;
  101910. private _totalVertices;
  101911. /** @hidden */
  101912. _activeIndices: PerfCounter;
  101913. /** @hidden */
  101914. _activeParticles: PerfCounter;
  101915. /** @hidden */
  101916. _activeBones: PerfCounter;
  101917. private _animationRatio;
  101918. /** @hidden */
  101919. _animationTimeLast: number;
  101920. /** @hidden */
  101921. _animationTime: number;
  101922. /**
  101923. * Gets or sets a general scale for animation speed
  101924. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101925. */
  101926. animationTimeScale: number;
  101927. /** @hidden */
  101928. _cachedMaterial: Nullable<Material>;
  101929. /** @hidden */
  101930. _cachedEffect: Nullable<Effect>;
  101931. /** @hidden */
  101932. _cachedVisibility: Nullable<number>;
  101933. private _renderId;
  101934. private _frameId;
  101935. private _executeWhenReadyTimeoutId;
  101936. private _intermediateRendering;
  101937. private _viewUpdateFlag;
  101938. private _projectionUpdateFlag;
  101939. /** @hidden */
  101940. _toBeDisposed: Nullable<IDisposable>[];
  101941. private _activeRequests;
  101942. /** @hidden */
  101943. _pendingData: any[];
  101944. private _isDisposed;
  101945. /**
  101946. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101947. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101948. */
  101949. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101950. private _activeMeshes;
  101951. private _processedMaterials;
  101952. private _renderTargets;
  101953. /** @hidden */
  101954. _activeParticleSystems: SmartArray<IParticleSystem>;
  101955. private _activeSkeletons;
  101956. private _softwareSkinnedMeshes;
  101957. private _renderingManager;
  101958. /** @hidden */
  101959. _activeAnimatables: Animatable[];
  101960. private _transformMatrix;
  101961. private _sceneUbo;
  101962. /** @hidden */
  101963. _viewMatrix: Matrix;
  101964. private _projectionMatrix;
  101965. /** @hidden */
  101966. _forcedViewPosition: Nullable<Vector3>;
  101967. /** @hidden */
  101968. _frustumPlanes: Plane[];
  101969. /**
  101970. * Gets the list of frustum planes (built from the active camera)
  101971. */
  101972. readonly frustumPlanes: Plane[];
  101973. /**
  101974. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101975. * This is useful if there are more lights that the maximum simulteanous authorized
  101976. */
  101977. requireLightSorting: boolean;
  101978. /** @hidden */
  101979. readonly useMaterialMeshMap: boolean;
  101980. /** @hidden */
  101981. readonly useClonedMeshhMap: boolean;
  101982. private _externalData;
  101983. private _uid;
  101984. /**
  101985. * @hidden
  101986. * Backing store of defined scene components.
  101987. */
  101988. _components: ISceneComponent[];
  101989. /**
  101990. * @hidden
  101991. * Backing store of defined scene components.
  101992. */
  101993. _serializableComponents: ISceneSerializableComponent[];
  101994. /**
  101995. * List of components to register on the next registration step.
  101996. */
  101997. private _transientComponents;
  101998. /**
  101999. * Registers the transient components if needed.
  102000. */
  102001. private _registerTransientComponents;
  102002. /**
  102003. * @hidden
  102004. * Add a component to the scene.
  102005. * Note that the ccomponent could be registered on th next frame if this is called after
  102006. * the register component stage.
  102007. * @param component Defines the component to add to the scene
  102008. */
  102009. _addComponent(component: ISceneComponent): void;
  102010. /**
  102011. * @hidden
  102012. * Gets a component from the scene.
  102013. * @param name defines the name of the component to retrieve
  102014. * @returns the component or null if not present
  102015. */
  102016. _getComponent(name: string): Nullable<ISceneComponent>;
  102017. /**
  102018. * @hidden
  102019. * Defines the actions happening before camera updates.
  102020. */
  102021. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102022. /**
  102023. * @hidden
  102024. * Defines the actions happening before clear the canvas.
  102025. */
  102026. _beforeClearStage: Stage<SimpleStageAction>;
  102027. /**
  102028. * @hidden
  102029. * Defines the actions when collecting render targets for the frame.
  102030. */
  102031. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102032. /**
  102033. * @hidden
  102034. * Defines the actions happening for one camera in the frame.
  102035. */
  102036. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102037. /**
  102038. * @hidden
  102039. * Defines the actions happening during the per mesh ready checks.
  102040. */
  102041. _isReadyForMeshStage: Stage<MeshStageAction>;
  102042. /**
  102043. * @hidden
  102044. * Defines the actions happening before evaluate active mesh checks.
  102045. */
  102046. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102047. /**
  102048. * @hidden
  102049. * Defines the actions happening during the evaluate sub mesh checks.
  102050. */
  102051. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102052. /**
  102053. * @hidden
  102054. * Defines the actions happening during the active mesh stage.
  102055. */
  102056. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102057. /**
  102058. * @hidden
  102059. * Defines the actions happening during the per camera render target step.
  102060. */
  102061. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102062. /**
  102063. * @hidden
  102064. * Defines the actions happening just before the active camera is drawing.
  102065. */
  102066. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102067. /**
  102068. * @hidden
  102069. * Defines the actions happening just before a render target is drawing.
  102070. */
  102071. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102072. /**
  102073. * @hidden
  102074. * Defines the actions happening just before a rendering group is drawing.
  102075. */
  102076. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102077. /**
  102078. * @hidden
  102079. * Defines the actions happening just before a mesh is drawing.
  102080. */
  102081. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102082. /**
  102083. * @hidden
  102084. * Defines the actions happening just after a mesh has been drawn.
  102085. */
  102086. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102087. /**
  102088. * @hidden
  102089. * Defines the actions happening just after a rendering group has been drawn.
  102090. */
  102091. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102092. /**
  102093. * @hidden
  102094. * Defines the actions happening just after the active camera has been drawn.
  102095. */
  102096. _afterCameraDrawStage: Stage<CameraStageAction>;
  102097. /**
  102098. * @hidden
  102099. * Defines the actions happening just after a render target has been drawn.
  102100. */
  102101. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102102. /**
  102103. * @hidden
  102104. * Defines the actions happening just after rendering all cameras and computing intersections.
  102105. */
  102106. _afterRenderStage: Stage<SimpleStageAction>;
  102107. /**
  102108. * @hidden
  102109. * Defines the actions happening when a pointer move event happens.
  102110. */
  102111. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102112. /**
  102113. * @hidden
  102114. * Defines the actions happening when a pointer down event happens.
  102115. */
  102116. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102117. /**
  102118. * @hidden
  102119. * Defines the actions happening when a pointer up event happens.
  102120. */
  102121. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102122. /**
  102123. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102124. */
  102125. private geometriesByUniqueId;
  102126. /**
  102127. * Creates a new Scene
  102128. * @param engine defines the engine to use to render this scene
  102129. * @param options defines the scene options
  102130. */
  102131. constructor(engine: Engine, options?: SceneOptions);
  102132. /**
  102133. * Gets a string idenfifying the name of the class
  102134. * @returns "Scene" string
  102135. */
  102136. getClassName(): string;
  102137. private _defaultMeshCandidates;
  102138. /**
  102139. * @hidden
  102140. */
  102141. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102142. private _defaultSubMeshCandidates;
  102143. /**
  102144. * @hidden
  102145. */
  102146. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102147. /**
  102148. * Sets the default candidate providers for the scene.
  102149. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102150. * and getCollidingSubMeshCandidates to their default function
  102151. */
  102152. setDefaultCandidateProviders(): void;
  102153. /**
  102154. * Gets the mesh that is currently under the pointer
  102155. */
  102156. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102157. /**
  102158. * Gets or sets the current on-screen X position of the pointer
  102159. */
  102160. pointerX: number;
  102161. /**
  102162. * Gets or sets the current on-screen Y position of the pointer
  102163. */
  102164. pointerY: number;
  102165. /**
  102166. * Gets the cached material (ie. the latest rendered one)
  102167. * @returns the cached material
  102168. */
  102169. getCachedMaterial(): Nullable<Material>;
  102170. /**
  102171. * Gets the cached effect (ie. the latest rendered one)
  102172. * @returns the cached effect
  102173. */
  102174. getCachedEffect(): Nullable<Effect>;
  102175. /**
  102176. * Gets the cached visibility state (ie. the latest rendered one)
  102177. * @returns the cached visibility state
  102178. */
  102179. getCachedVisibility(): Nullable<number>;
  102180. /**
  102181. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102182. * @param material defines the current material
  102183. * @param effect defines the current effect
  102184. * @param visibility defines the current visibility state
  102185. * @returns true if one parameter is not cached
  102186. */
  102187. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102188. /**
  102189. * Gets the engine associated with the scene
  102190. * @returns an Engine
  102191. */
  102192. getEngine(): Engine;
  102193. /**
  102194. * Gets the total number of vertices rendered per frame
  102195. * @returns the total number of vertices rendered per frame
  102196. */
  102197. getTotalVertices(): number;
  102198. /**
  102199. * Gets the performance counter for total vertices
  102200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102201. */
  102202. readonly totalVerticesPerfCounter: PerfCounter;
  102203. /**
  102204. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102205. * @returns the total number of active indices rendered per frame
  102206. */
  102207. getActiveIndices(): number;
  102208. /**
  102209. * Gets the performance counter for active indices
  102210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102211. */
  102212. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102213. /**
  102214. * Gets the total number of active particles rendered per frame
  102215. * @returns the total number of active particles rendered per frame
  102216. */
  102217. getActiveParticles(): number;
  102218. /**
  102219. * Gets the performance counter for active particles
  102220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102221. */
  102222. readonly activeParticlesPerfCounter: PerfCounter;
  102223. /**
  102224. * Gets the total number of active bones rendered per frame
  102225. * @returns the total number of active bones rendered per frame
  102226. */
  102227. getActiveBones(): number;
  102228. /**
  102229. * Gets the performance counter for active bones
  102230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102231. */
  102232. readonly activeBonesPerfCounter: PerfCounter;
  102233. /**
  102234. * Gets the array of active meshes
  102235. * @returns an array of AbstractMesh
  102236. */
  102237. getActiveMeshes(): SmartArray<AbstractMesh>;
  102238. /**
  102239. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102240. * @returns a number
  102241. */
  102242. getAnimationRatio(): number;
  102243. /**
  102244. * Gets an unique Id for the current render phase
  102245. * @returns a number
  102246. */
  102247. getRenderId(): number;
  102248. /**
  102249. * Gets an unique Id for the current frame
  102250. * @returns a number
  102251. */
  102252. getFrameId(): number;
  102253. /** Call this function if you want to manually increment the render Id*/
  102254. incrementRenderId(): void;
  102255. private _createUbo;
  102256. /**
  102257. * Use this method to simulate a pointer move on a mesh
  102258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102261. * @returns the current scene
  102262. */
  102263. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102264. /**
  102265. * Use this method to simulate a pointer down on a mesh
  102266. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102267. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102268. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102269. * @returns the current scene
  102270. */
  102271. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102272. /**
  102273. * Use this method to simulate a pointer up on a mesh
  102274. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102275. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102276. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102277. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102278. * @returns the current scene
  102279. */
  102280. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102281. /**
  102282. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102283. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102284. * @returns true if the pointer was captured
  102285. */
  102286. isPointerCaptured(pointerId?: number): boolean;
  102287. /**
  102288. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102289. * @param attachUp defines if you want to attach events to pointerup
  102290. * @param attachDown defines if you want to attach events to pointerdown
  102291. * @param attachMove defines if you want to attach events to pointermove
  102292. */
  102293. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102294. /** Detaches all event handlers*/
  102295. detachControl(): void;
  102296. /**
  102297. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102298. * Delay loaded resources are not taking in account
  102299. * @return true if all required resources are ready
  102300. */
  102301. isReady(): boolean;
  102302. /** Resets all cached information relative to material (including effect and visibility) */
  102303. resetCachedMaterial(): void;
  102304. /**
  102305. * Registers a function to be called before every frame render
  102306. * @param func defines the function to register
  102307. */
  102308. registerBeforeRender(func: () => void): void;
  102309. /**
  102310. * Unregisters a function called before every frame render
  102311. * @param func defines the function to unregister
  102312. */
  102313. unregisterBeforeRender(func: () => void): void;
  102314. /**
  102315. * Registers a function to be called after every frame render
  102316. * @param func defines the function to register
  102317. */
  102318. registerAfterRender(func: () => void): void;
  102319. /**
  102320. * Unregisters a function called after every frame render
  102321. * @param func defines the function to unregister
  102322. */
  102323. unregisterAfterRender(func: () => void): void;
  102324. private _executeOnceBeforeRender;
  102325. /**
  102326. * The provided function will run before render once and will be disposed afterwards.
  102327. * A timeout delay can be provided so that the function will be executed in N ms.
  102328. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102329. * @param func The function to be executed.
  102330. * @param timeout optional delay in ms
  102331. */
  102332. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102333. /** @hidden */
  102334. _addPendingData(data: any): void;
  102335. /** @hidden */
  102336. _removePendingData(data: any): void;
  102337. /**
  102338. * Returns the number of items waiting to be loaded
  102339. * @returns the number of items waiting to be loaded
  102340. */
  102341. getWaitingItemsCount(): number;
  102342. /**
  102343. * Returns a boolean indicating if the scene is still loading data
  102344. */
  102345. readonly isLoading: boolean;
  102346. /**
  102347. * Registers a function to be executed when the scene is ready
  102348. * @param {Function} func - the function to be executed
  102349. */
  102350. executeWhenReady(func: () => void): void;
  102351. /**
  102352. * Returns a promise that resolves when the scene is ready
  102353. * @returns A promise that resolves when the scene is ready
  102354. */
  102355. whenReadyAsync(): Promise<void>;
  102356. /** @hidden */
  102357. _checkIsReady(): void;
  102358. /**
  102359. * Gets all animatable attached to the scene
  102360. */
  102361. readonly animatables: Animatable[];
  102362. /**
  102363. * Resets the last animation time frame.
  102364. * Useful to override when animations start running when loading a scene for the first time.
  102365. */
  102366. resetLastAnimationTimeFrame(): void;
  102367. /**
  102368. * Gets the current view matrix
  102369. * @returns a Matrix
  102370. */
  102371. getViewMatrix(): Matrix;
  102372. /**
  102373. * Gets the current projection matrix
  102374. * @returns a Matrix
  102375. */
  102376. getProjectionMatrix(): Matrix;
  102377. /**
  102378. * Gets the current transform matrix
  102379. * @returns a Matrix made of View * Projection
  102380. */
  102381. getTransformMatrix(): Matrix;
  102382. /**
  102383. * Sets the current transform matrix
  102384. * @param viewL defines the View matrix to use
  102385. * @param projectionL defines the Projection matrix to use
  102386. * @param viewR defines the right View matrix to use (if provided)
  102387. * @param projectionR defines the right Projection matrix to use (if provided)
  102388. */
  102389. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102390. /**
  102391. * Gets the uniform buffer used to store scene data
  102392. * @returns a UniformBuffer
  102393. */
  102394. getSceneUniformBuffer(): UniformBuffer;
  102395. /**
  102396. * Gets an unique (relatively to the current scene) Id
  102397. * @returns an unique number for the scene
  102398. */
  102399. getUniqueId(): number;
  102400. /**
  102401. * Add a mesh to the list of scene's meshes
  102402. * @param newMesh defines the mesh to add
  102403. * @param recursive if all child meshes should also be added to the scene
  102404. */
  102405. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102406. /**
  102407. * Remove a mesh for the list of scene's meshes
  102408. * @param toRemove defines the mesh to remove
  102409. * @param recursive if all child meshes should also be removed from the scene
  102410. * @returns the index where the mesh was in the mesh list
  102411. */
  102412. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102413. /**
  102414. * Add a transform node to the list of scene's transform nodes
  102415. * @param newTransformNode defines the transform node to add
  102416. */
  102417. addTransformNode(newTransformNode: TransformNode): void;
  102418. /**
  102419. * Remove a transform node for the list of scene's transform nodes
  102420. * @param toRemove defines the transform node to remove
  102421. * @returns the index where the transform node was in the transform node list
  102422. */
  102423. removeTransformNode(toRemove: TransformNode): number;
  102424. /**
  102425. * Remove a skeleton for the list of scene's skeletons
  102426. * @param toRemove defines the skeleton to remove
  102427. * @returns the index where the skeleton was in the skeleton list
  102428. */
  102429. removeSkeleton(toRemove: Skeleton): number;
  102430. /**
  102431. * Remove a morph target for the list of scene's morph targets
  102432. * @param toRemove defines the morph target to remove
  102433. * @returns the index where the morph target was in the morph target list
  102434. */
  102435. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102436. /**
  102437. * Remove a light for the list of scene's lights
  102438. * @param toRemove defines the light to remove
  102439. * @returns the index where the light was in the light list
  102440. */
  102441. removeLight(toRemove: Light): number;
  102442. /**
  102443. * Remove a camera for the list of scene's cameras
  102444. * @param toRemove defines the camera to remove
  102445. * @returns the index where the camera was in the camera list
  102446. */
  102447. removeCamera(toRemove: Camera): number;
  102448. /**
  102449. * Remove a particle system for the list of scene's particle systems
  102450. * @param toRemove defines the particle system to remove
  102451. * @returns the index where the particle system was in the particle system list
  102452. */
  102453. removeParticleSystem(toRemove: IParticleSystem): number;
  102454. /**
  102455. * Remove a animation for the list of scene's animations
  102456. * @param toRemove defines the animation to remove
  102457. * @returns the index where the animation was in the animation list
  102458. */
  102459. removeAnimation(toRemove: Animation): number;
  102460. /**
  102461. * Will stop the animation of the given target
  102462. * @param target - the target
  102463. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102464. * @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)
  102465. */
  102466. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102467. /**
  102468. * Removes the given animation group from this scene.
  102469. * @param toRemove The animation group to remove
  102470. * @returns The index of the removed animation group
  102471. */
  102472. removeAnimationGroup(toRemove: AnimationGroup): number;
  102473. /**
  102474. * Removes the given multi-material from this scene.
  102475. * @param toRemove The multi-material to remove
  102476. * @returns The index of the removed multi-material
  102477. */
  102478. removeMultiMaterial(toRemove: MultiMaterial): number;
  102479. /**
  102480. * Removes the given material from this scene.
  102481. * @param toRemove The material to remove
  102482. * @returns The index of the removed material
  102483. */
  102484. removeMaterial(toRemove: Material): number;
  102485. /**
  102486. * Removes the given action manager from this scene.
  102487. * @param toRemove The action manager to remove
  102488. * @returns The index of the removed action manager
  102489. */
  102490. removeActionManager(toRemove: AbstractActionManager): number;
  102491. /**
  102492. * Removes the given texture from this scene.
  102493. * @param toRemove The texture to remove
  102494. * @returns The index of the removed texture
  102495. */
  102496. removeTexture(toRemove: BaseTexture): number;
  102497. /**
  102498. * Adds the given light to this scene
  102499. * @param newLight The light to add
  102500. */
  102501. addLight(newLight: Light): void;
  102502. /**
  102503. * Sorts the list list based on light priorities
  102504. */
  102505. sortLightsByPriority(): void;
  102506. /**
  102507. * Adds the given camera to this scene
  102508. * @param newCamera The camera to add
  102509. */
  102510. addCamera(newCamera: Camera): void;
  102511. /**
  102512. * Adds the given skeleton to this scene
  102513. * @param newSkeleton The skeleton to add
  102514. */
  102515. addSkeleton(newSkeleton: Skeleton): void;
  102516. /**
  102517. * Adds the given particle system to this scene
  102518. * @param newParticleSystem The particle system to add
  102519. */
  102520. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102521. /**
  102522. * Adds the given animation to this scene
  102523. * @param newAnimation The animation to add
  102524. */
  102525. addAnimation(newAnimation: Animation): void;
  102526. /**
  102527. * Adds the given animation group to this scene.
  102528. * @param newAnimationGroup The animation group to add
  102529. */
  102530. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102531. /**
  102532. * Adds the given multi-material to this scene
  102533. * @param newMultiMaterial The multi-material to add
  102534. */
  102535. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102536. /**
  102537. * Adds the given material to this scene
  102538. * @param newMaterial The material to add
  102539. */
  102540. addMaterial(newMaterial: Material): void;
  102541. /**
  102542. * Adds the given morph target to this scene
  102543. * @param newMorphTargetManager The morph target to add
  102544. */
  102545. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102546. /**
  102547. * Adds the given geometry to this scene
  102548. * @param newGeometry The geometry to add
  102549. */
  102550. addGeometry(newGeometry: Geometry): void;
  102551. /**
  102552. * Adds the given action manager to this scene
  102553. * @param newActionManager The action manager to add
  102554. */
  102555. addActionManager(newActionManager: AbstractActionManager): void;
  102556. /**
  102557. * Adds the given texture to this scene.
  102558. * @param newTexture The texture to add
  102559. */
  102560. addTexture(newTexture: BaseTexture): void;
  102561. /**
  102562. * Switch active camera
  102563. * @param newCamera defines the new active camera
  102564. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102565. */
  102566. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102567. /**
  102568. * sets the active camera of the scene using its ID
  102569. * @param id defines the camera's ID
  102570. * @return the new active camera or null if none found.
  102571. */
  102572. setActiveCameraByID(id: string): Nullable<Camera>;
  102573. /**
  102574. * sets the active camera of the scene using its name
  102575. * @param name defines the camera's name
  102576. * @returns the new active camera or null if none found.
  102577. */
  102578. setActiveCameraByName(name: string): Nullable<Camera>;
  102579. /**
  102580. * get an animation group using its name
  102581. * @param name defines the material's name
  102582. * @return the animation group or null if none found.
  102583. */
  102584. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102585. /**
  102586. * Get a material using its unique id
  102587. * @param uniqueId defines the material's unique id
  102588. * @return the material or null if none found.
  102589. */
  102590. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102591. /**
  102592. * get a material using its id
  102593. * @param id defines the material's ID
  102594. * @return the material or null if none found.
  102595. */
  102596. getMaterialByID(id: string): Nullable<Material>;
  102597. /**
  102598. * Gets a the last added material using a given id
  102599. * @param id defines the material's ID
  102600. * @return the last material with the given id or null if none found.
  102601. */
  102602. getLastMaterialByID(id: string): Nullable<Material>;
  102603. /**
  102604. * Gets a material using its name
  102605. * @param name defines the material's name
  102606. * @return the material or null if none found.
  102607. */
  102608. getMaterialByName(name: string): Nullable<Material>;
  102609. /**
  102610. * Get a texture using its unique id
  102611. * @param uniqueId defines the texture's unique id
  102612. * @return the texture or null if none found.
  102613. */
  102614. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102615. /**
  102616. * Gets a camera using its id
  102617. * @param id defines the id to look for
  102618. * @returns the camera or null if not found
  102619. */
  102620. getCameraByID(id: string): Nullable<Camera>;
  102621. /**
  102622. * Gets a camera using its unique id
  102623. * @param uniqueId defines the unique id to look for
  102624. * @returns the camera or null if not found
  102625. */
  102626. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102627. /**
  102628. * Gets a camera using its name
  102629. * @param name defines the camera's name
  102630. * @return the camera or null if none found.
  102631. */
  102632. getCameraByName(name: string): Nullable<Camera>;
  102633. /**
  102634. * Gets a bone using its id
  102635. * @param id defines the bone's id
  102636. * @return the bone or null if not found
  102637. */
  102638. getBoneByID(id: string): Nullable<Bone>;
  102639. /**
  102640. * Gets a bone using its id
  102641. * @param name defines the bone's name
  102642. * @return the bone or null if not found
  102643. */
  102644. getBoneByName(name: string): Nullable<Bone>;
  102645. /**
  102646. * Gets a light node using its name
  102647. * @param name defines the the light's name
  102648. * @return the light or null if none found.
  102649. */
  102650. getLightByName(name: string): Nullable<Light>;
  102651. /**
  102652. * Gets a light node using its id
  102653. * @param id defines the light's id
  102654. * @return the light or null if none found.
  102655. */
  102656. getLightByID(id: string): Nullable<Light>;
  102657. /**
  102658. * Gets a light node using its scene-generated unique ID
  102659. * @param uniqueId defines the light's unique id
  102660. * @return the light or null if none found.
  102661. */
  102662. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102663. /**
  102664. * Gets a particle system by id
  102665. * @param id defines the particle system id
  102666. * @return the corresponding system or null if none found
  102667. */
  102668. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102669. /**
  102670. * Gets a geometry using its ID
  102671. * @param id defines the geometry's id
  102672. * @return the geometry or null if none found.
  102673. */
  102674. getGeometryByID(id: string): Nullable<Geometry>;
  102675. private _getGeometryByUniqueID;
  102676. /**
  102677. * Add a new geometry to this scene
  102678. * @param geometry defines the geometry to be added to the scene.
  102679. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102680. * @return a boolean defining if the geometry was added or not
  102681. */
  102682. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102683. /**
  102684. * Removes an existing geometry
  102685. * @param geometry defines the geometry to be removed from the scene
  102686. * @return a boolean defining if the geometry was removed or not
  102687. */
  102688. removeGeometry(geometry: Geometry): boolean;
  102689. /**
  102690. * Gets the list of geometries attached to the scene
  102691. * @returns an array of Geometry
  102692. */
  102693. getGeometries(): Geometry[];
  102694. /**
  102695. * Gets the first added mesh found of a given ID
  102696. * @param id defines the id to search for
  102697. * @return the mesh found or null if not found at all
  102698. */
  102699. getMeshByID(id: string): Nullable<AbstractMesh>;
  102700. /**
  102701. * Gets a list of meshes using their id
  102702. * @param id defines the id to search for
  102703. * @returns a list of meshes
  102704. */
  102705. getMeshesByID(id: string): Array<AbstractMesh>;
  102706. /**
  102707. * Gets the first added transform node found of a given ID
  102708. * @param id defines the id to search for
  102709. * @return the found transform node or null if not found at all.
  102710. */
  102711. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102712. /**
  102713. * Gets a transform node with its auto-generated unique id
  102714. * @param uniqueId efines the unique id to search for
  102715. * @return the found transform node or null if not found at all.
  102716. */
  102717. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102718. /**
  102719. * Gets a list of transform nodes using their id
  102720. * @param id defines the id to search for
  102721. * @returns a list of transform nodes
  102722. */
  102723. getTransformNodesByID(id: string): Array<TransformNode>;
  102724. /**
  102725. * Gets a mesh with its auto-generated unique id
  102726. * @param uniqueId defines the unique id to search for
  102727. * @return the found mesh or null if not found at all.
  102728. */
  102729. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102730. /**
  102731. * Gets a the last added mesh using a given id
  102732. * @param id defines the id to search for
  102733. * @return the found mesh or null if not found at all.
  102734. */
  102735. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102736. /**
  102737. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102738. * @param id defines the id to search for
  102739. * @return the found node or null if not found at all
  102740. */
  102741. getLastEntryByID(id: string): Nullable<Node>;
  102742. /**
  102743. * Gets a node (Mesh, Camera, Light) using a given id
  102744. * @param id defines the id to search for
  102745. * @return the found node or null if not found at all
  102746. */
  102747. getNodeByID(id: string): Nullable<Node>;
  102748. /**
  102749. * Gets a node (Mesh, Camera, Light) using a given name
  102750. * @param name defines the name to search for
  102751. * @return the found node or null if not found at all.
  102752. */
  102753. getNodeByName(name: string): Nullable<Node>;
  102754. /**
  102755. * Gets a mesh using a given name
  102756. * @param name defines the name to search for
  102757. * @return the found mesh or null if not found at all.
  102758. */
  102759. getMeshByName(name: string): Nullable<AbstractMesh>;
  102760. /**
  102761. * Gets a transform node using a given name
  102762. * @param name defines the name to search for
  102763. * @return the found transform node or null if not found at all.
  102764. */
  102765. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102766. /**
  102767. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102768. * @param id defines the id to search for
  102769. * @return the found skeleton or null if not found at all.
  102770. */
  102771. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102772. /**
  102773. * Gets a skeleton using a given auto generated unique id
  102774. * @param uniqueId defines the unique id to search for
  102775. * @return the found skeleton or null if not found at all.
  102776. */
  102777. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102778. /**
  102779. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102780. * @param id defines the id to search for
  102781. * @return the found skeleton or null if not found at all.
  102782. */
  102783. getSkeletonById(id: string): Nullable<Skeleton>;
  102784. /**
  102785. * Gets a skeleton using a given name
  102786. * @param name defines the name to search for
  102787. * @return the found skeleton or null if not found at all.
  102788. */
  102789. getSkeletonByName(name: string): Nullable<Skeleton>;
  102790. /**
  102791. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102792. * @param id defines the id to search for
  102793. * @return the found morph target manager or null if not found at all.
  102794. */
  102795. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102796. /**
  102797. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102798. * @param id defines the id to search for
  102799. * @return the found morph target or null if not found at all.
  102800. */
  102801. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102802. /**
  102803. * Gets a boolean indicating if the given mesh is active
  102804. * @param mesh defines the mesh to look for
  102805. * @returns true if the mesh is in the active list
  102806. */
  102807. isActiveMesh(mesh: AbstractMesh): boolean;
  102808. /**
  102809. * Return a unique id as a string which can serve as an identifier for the scene
  102810. */
  102811. readonly uid: string;
  102812. /**
  102813. * Add an externaly attached data from its key.
  102814. * This method call will fail and return false, if such key already exists.
  102815. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102816. * @param key the unique key that identifies the data
  102817. * @param data the data object to associate to the key for this Engine instance
  102818. * @return true if no such key were already present and the data was added successfully, false otherwise
  102819. */
  102820. addExternalData<T>(key: string, data: T): boolean;
  102821. /**
  102822. * Get an externaly attached data from its key
  102823. * @param key the unique key that identifies the data
  102824. * @return the associated data, if present (can be null), or undefined if not present
  102825. */
  102826. getExternalData<T>(key: string): Nullable<T>;
  102827. /**
  102828. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102829. * @param key the unique key that identifies the data
  102830. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102831. * @return the associated data, can be null if the factory returned null.
  102832. */
  102833. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102834. /**
  102835. * Remove an externaly attached data from the Engine instance
  102836. * @param key the unique key that identifies the data
  102837. * @return true if the data was successfully removed, false if it doesn't exist
  102838. */
  102839. removeExternalData(key: string): boolean;
  102840. private _evaluateSubMesh;
  102841. /**
  102842. * Clear the processed materials smart array preventing retention point in material dispose.
  102843. */
  102844. freeProcessedMaterials(): void;
  102845. private _preventFreeActiveMeshesAndRenderingGroups;
  102846. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102847. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102848. * when disposing several meshes in a row or a hierarchy of meshes.
  102849. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102850. */
  102851. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102852. /**
  102853. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102854. */
  102855. freeActiveMeshes(): void;
  102856. /**
  102857. * Clear the info related to rendering groups preventing retention points during dispose.
  102858. */
  102859. freeRenderingGroups(): void;
  102860. /** @hidden */
  102861. _isInIntermediateRendering(): boolean;
  102862. /**
  102863. * Lambda returning the list of potentially active meshes.
  102864. */
  102865. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102866. /**
  102867. * Lambda returning the list of potentially active sub meshes.
  102868. */
  102869. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102870. /**
  102871. * Lambda returning the list of potentially intersecting sub meshes.
  102872. */
  102873. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102874. /**
  102875. * Lambda returning the list of potentially colliding sub meshes.
  102876. */
  102877. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102878. private _activeMeshesFrozen;
  102879. /**
  102880. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102881. * @returns the current scene
  102882. */
  102883. freezeActiveMeshes(): Scene;
  102884. /**
  102885. * Use this function to restart evaluating active meshes on every frame
  102886. * @returns the current scene
  102887. */
  102888. unfreezeActiveMeshes(): Scene;
  102889. private _evaluateActiveMeshes;
  102890. private _activeMesh;
  102891. /**
  102892. * Update the transform matrix to update from the current active camera
  102893. * @param force defines a boolean used to force the update even if cache is up to date
  102894. */
  102895. updateTransformMatrix(force?: boolean): void;
  102896. private _bindFrameBuffer;
  102897. /** @hidden */
  102898. _allowPostProcessClearColor: boolean;
  102899. /** @hidden */
  102900. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102901. private _processSubCameras;
  102902. private _checkIntersections;
  102903. /** @hidden */
  102904. _advancePhysicsEngineStep(step: number): void;
  102905. /**
  102906. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102907. */
  102908. getDeterministicFrameTime: () => number;
  102909. /** @hidden */
  102910. _animate(): void;
  102911. /** Execute all animations (for a frame) */
  102912. animate(): void;
  102913. /**
  102914. * Render the scene
  102915. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102916. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102917. */
  102918. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102919. /**
  102920. * Freeze all materials
  102921. * A frozen material will not be updatable but should be faster to render
  102922. */
  102923. freezeMaterials(): void;
  102924. /**
  102925. * Unfreeze all materials
  102926. * A frozen material will not be updatable but should be faster to render
  102927. */
  102928. unfreezeMaterials(): void;
  102929. /**
  102930. * Releases all held ressources
  102931. */
  102932. dispose(): void;
  102933. /**
  102934. * Gets if the scene is already disposed
  102935. */
  102936. readonly isDisposed: boolean;
  102937. /**
  102938. * Call this function to reduce memory footprint of the scene.
  102939. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102940. */
  102941. clearCachedVertexData(): void;
  102942. /**
  102943. * This function will remove the local cached buffer data from texture.
  102944. * It will save memory but will prevent the texture from being rebuilt
  102945. */
  102946. cleanCachedTextureBuffer(): void;
  102947. /**
  102948. * Get the world extend vectors with an optional filter
  102949. *
  102950. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102951. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102952. */
  102953. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102954. min: Vector3;
  102955. max: Vector3;
  102956. };
  102957. /**
  102958. * Creates a ray that can be used to pick in the scene
  102959. * @param x defines the x coordinate of the origin (on-screen)
  102960. * @param y defines the y coordinate of the origin (on-screen)
  102961. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102962. * @param camera defines the camera to use for the picking
  102963. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102964. * @returns a Ray
  102965. */
  102966. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102967. /**
  102968. * Creates a ray that can be used to pick in the scene
  102969. * @param x defines the x coordinate of the origin (on-screen)
  102970. * @param y defines the y coordinate of the origin (on-screen)
  102971. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102972. * @param result defines the ray where to store the picking ray
  102973. * @param camera defines the camera to use for the picking
  102974. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102975. * @returns the current scene
  102976. */
  102977. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102978. /**
  102979. * Creates a ray that can be used to pick in the scene
  102980. * @param x defines the x coordinate of the origin (on-screen)
  102981. * @param y defines the y coordinate of the origin (on-screen)
  102982. * @param camera defines the camera to use for the picking
  102983. * @returns a Ray
  102984. */
  102985. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102986. /**
  102987. * Creates a ray that can be used to pick in the scene
  102988. * @param x defines the x coordinate of the origin (on-screen)
  102989. * @param y defines the y coordinate of the origin (on-screen)
  102990. * @param result defines the ray where to store the picking ray
  102991. * @param camera defines the camera to use for the picking
  102992. * @returns the current scene
  102993. */
  102994. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102995. /** Launch a ray to try to pick a mesh in the scene
  102996. * @param x position on screen
  102997. * @param y position on screen
  102998. * @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
  102999. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103000. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103002. * @returns a PickingInfo
  103003. */
  103004. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103005. /** Use the given ray to pick a mesh in the scene
  103006. * @param ray The ray to use to pick meshes
  103007. * @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
  103008. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103009. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103010. * @returns a PickingInfo
  103011. */
  103012. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103013. /**
  103014. * Launch a ray to try to pick a mesh in the scene
  103015. * @param x X position on screen
  103016. * @param y Y position on screen
  103017. * @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
  103018. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103019. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103020. * @returns an array of PickingInfo
  103021. */
  103022. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103023. /**
  103024. * Launch a ray to try to pick a mesh in the scene
  103025. * @param ray Ray to use
  103026. * @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
  103027. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103028. * @returns an array of PickingInfo
  103029. */
  103030. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103031. /**
  103032. * Force the value of meshUnderPointer
  103033. * @param mesh defines the mesh to use
  103034. */
  103035. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103036. /**
  103037. * Gets the mesh under the pointer
  103038. * @returns a Mesh or null if no mesh is under the pointer
  103039. */
  103040. getPointerOverMesh(): Nullable<AbstractMesh>;
  103041. /** @hidden */
  103042. _rebuildGeometries(): void;
  103043. /** @hidden */
  103044. _rebuildTextures(): void;
  103045. private _getByTags;
  103046. /**
  103047. * Get a list of meshes by tags
  103048. * @param tagsQuery defines the tags query to use
  103049. * @param forEach defines a predicate used to filter results
  103050. * @returns an array of Mesh
  103051. */
  103052. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103053. /**
  103054. * Get a list of cameras by tags
  103055. * @param tagsQuery defines the tags query to use
  103056. * @param forEach defines a predicate used to filter results
  103057. * @returns an array of Camera
  103058. */
  103059. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103060. /**
  103061. * Get a list of lights by tags
  103062. * @param tagsQuery defines the tags query to use
  103063. * @param forEach defines a predicate used to filter results
  103064. * @returns an array of Light
  103065. */
  103066. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103067. /**
  103068. * Get a list of materials by tags
  103069. * @param tagsQuery defines the tags query to use
  103070. * @param forEach defines a predicate used to filter results
  103071. * @returns an array of Material
  103072. */
  103073. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103074. /**
  103075. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103076. * This allowed control for front to back rendering or reversly depending of the special needs.
  103077. *
  103078. * @param renderingGroupId The rendering group id corresponding to its index
  103079. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103080. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103081. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103082. */
  103083. 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;
  103084. /**
  103085. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103086. *
  103087. * @param renderingGroupId The rendering group id corresponding to its index
  103088. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103089. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103090. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103091. */
  103092. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103093. /**
  103094. * Gets the current auto clear configuration for one rendering group of the rendering
  103095. * manager.
  103096. * @param index the rendering group index to get the information for
  103097. * @returns The auto clear setup for the requested rendering group
  103098. */
  103099. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103100. private _blockMaterialDirtyMechanism;
  103101. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103102. blockMaterialDirtyMechanism: boolean;
  103103. /**
  103104. * Will flag all materials as dirty to trigger new shader compilation
  103105. * @param flag defines the flag used to specify which material part must be marked as dirty
  103106. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103107. */
  103108. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103109. /** @hidden */
  103110. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  103111. /** @hidden */
  103112. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103113. /** @hidden */
  103114. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  103115. /** @hidden */
  103116. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103117. /** @hidden */
  103118. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103119. /** @hidden */
  103120. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103121. }
  103122. }
  103123. declare module BABYLON {
  103124. /**
  103125. * Set of assets to keep when moving a scene into an asset container.
  103126. */
  103127. export class KeepAssets extends AbstractScene {
  103128. }
  103129. /**
  103130. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103131. */
  103132. export class InstantiatedEntries {
  103133. /**
  103134. * List of new root nodes (eg. nodes with no parent)
  103135. */
  103136. rootNodes: TransformNode[];
  103137. /**
  103138. * List of new skeletons
  103139. */
  103140. skeletons: Skeleton[];
  103141. /**
  103142. * List of new animation groups
  103143. */
  103144. animationGroups: AnimationGroup[];
  103145. }
  103146. /**
  103147. * Container with a set of assets that can be added or removed from a scene.
  103148. */
  103149. export class AssetContainer extends AbstractScene {
  103150. /**
  103151. * The scene the AssetContainer belongs to.
  103152. */
  103153. scene: Scene;
  103154. /**
  103155. * Instantiates an AssetContainer.
  103156. * @param scene The scene the AssetContainer belongs to.
  103157. */
  103158. constructor(scene: Scene);
  103159. /**
  103160. * Instantiate or clone all meshes and add the new ones to the scene.
  103161. * Skeletons and animation groups will all be cloned
  103162. * @param nameFunction defines an optional function used to get new names for clones
  103163. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103164. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103165. */
  103166. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103167. /**
  103168. * Adds all the assets from the container to the scene.
  103169. */
  103170. addAllToScene(): void;
  103171. /**
  103172. * Removes all the assets in the container from the scene
  103173. */
  103174. removeAllFromScene(): void;
  103175. /**
  103176. * Disposes all the assets in the container
  103177. */
  103178. dispose(): void;
  103179. private _moveAssets;
  103180. /**
  103181. * Removes all the assets contained in the scene and adds them to the container.
  103182. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103183. */
  103184. moveAllFromScene(keepAssets?: KeepAssets): void;
  103185. /**
  103186. * 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.
  103187. * @returns the root mesh
  103188. */
  103189. createRootMesh(): Mesh;
  103190. }
  103191. }
  103192. declare module BABYLON {
  103193. /**
  103194. * Defines how the parser contract is defined.
  103195. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103196. */
  103197. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103198. /**
  103199. * Defines how the individual parser contract is defined.
  103200. * These parser can parse an individual asset
  103201. */
  103202. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103203. /**
  103204. * Base class of the scene acting as a container for the different elements composing a scene.
  103205. * This class is dynamically extended by the different components of the scene increasing
  103206. * flexibility and reducing coupling
  103207. */
  103208. export abstract class AbstractScene {
  103209. /**
  103210. * Stores the list of available parsers in the application.
  103211. */
  103212. private static _BabylonFileParsers;
  103213. /**
  103214. * Stores the list of available individual parsers in the application.
  103215. */
  103216. private static _IndividualBabylonFileParsers;
  103217. /**
  103218. * Adds a parser in the list of available ones
  103219. * @param name Defines the name of the parser
  103220. * @param parser Defines the parser to add
  103221. */
  103222. static AddParser(name: string, parser: BabylonFileParser): void;
  103223. /**
  103224. * Gets a general parser from the list of avaialble ones
  103225. * @param name Defines the name of the parser
  103226. * @returns the requested parser or null
  103227. */
  103228. static GetParser(name: string): Nullable<BabylonFileParser>;
  103229. /**
  103230. * Adds n individual parser in the list of available ones
  103231. * @param name Defines the name of the parser
  103232. * @param parser Defines the parser to add
  103233. */
  103234. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103235. /**
  103236. * Gets an individual parser from the list of avaialble ones
  103237. * @param name Defines the name of the parser
  103238. * @returns the requested parser or null
  103239. */
  103240. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103241. /**
  103242. * Parser json data and populate both a scene and its associated container object
  103243. * @param jsonData Defines the data to parse
  103244. * @param scene Defines the scene to parse the data for
  103245. * @param container Defines the container attached to the parsing sequence
  103246. * @param rootUrl Defines the root url of the data
  103247. */
  103248. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103249. /**
  103250. * Gets the list of root nodes (ie. nodes with no parent)
  103251. */
  103252. rootNodes: Node[];
  103253. /** All of the cameras added to this scene
  103254. * @see http://doc.babylonjs.com/babylon101/cameras
  103255. */
  103256. cameras: Camera[];
  103257. /**
  103258. * All of the lights added to this scene
  103259. * @see http://doc.babylonjs.com/babylon101/lights
  103260. */
  103261. lights: Light[];
  103262. /**
  103263. * All of the (abstract) meshes added to this scene
  103264. */
  103265. meshes: AbstractMesh[];
  103266. /**
  103267. * The list of skeletons added to the scene
  103268. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103269. */
  103270. skeletons: Skeleton[];
  103271. /**
  103272. * All of the particle systems added to this scene
  103273. * @see http://doc.babylonjs.com/babylon101/particles
  103274. */
  103275. particleSystems: IParticleSystem[];
  103276. /**
  103277. * Gets a list of Animations associated with the scene
  103278. */
  103279. animations: Animation[];
  103280. /**
  103281. * All of the animation groups added to this scene
  103282. * @see http://doc.babylonjs.com/how_to/group
  103283. */
  103284. animationGroups: AnimationGroup[];
  103285. /**
  103286. * All of the multi-materials added to this scene
  103287. * @see http://doc.babylonjs.com/how_to/multi_materials
  103288. */
  103289. multiMaterials: MultiMaterial[];
  103290. /**
  103291. * All of the materials added to this scene
  103292. * In the context of a Scene, it is not supposed to be modified manually.
  103293. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103294. * Note also that the order of the Material within the array is not significant and might change.
  103295. * @see http://doc.babylonjs.com/babylon101/materials
  103296. */
  103297. materials: Material[];
  103298. /**
  103299. * The list of morph target managers added to the scene
  103300. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103301. */
  103302. morphTargetManagers: MorphTargetManager[];
  103303. /**
  103304. * The list of geometries used in the scene.
  103305. */
  103306. geometries: Geometry[];
  103307. /**
  103308. * All of the tranform nodes added to this scene
  103309. * In the context of a Scene, it is not supposed to be modified manually.
  103310. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103311. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103312. * @see http://doc.babylonjs.com/how_to/transformnode
  103313. */
  103314. transformNodes: TransformNode[];
  103315. /**
  103316. * ActionManagers available on the scene.
  103317. */
  103318. actionManagers: AbstractActionManager[];
  103319. /**
  103320. * Textures to keep.
  103321. */
  103322. textures: BaseTexture[];
  103323. /**
  103324. * Environment texture for the scene
  103325. */
  103326. environmentTexture: Nullable<BaseTexture>;
  103327. }
  103328. }
  103329. declare module BABYLON {
  103330. /**
  103331. * Interface used to define options for Sound class
  103332. */
  103333. export interface ISoundOptions {
  103334. /**
  103335. * Does the sound autoplay once loaded.
  103336. */
  103337. autoplay?: boolean;
  103338. /**
  103339. * Does the sound loop after it finishes playing once.
  103340. */
  103341. loop?: boolean;
  103342. /**
  103343. * Sound's volume
  103344. */
  103345. volume?: number;
  103346. /**
  103347. * Is it a spatial sound?
  103348. */
  103349. spatialSound?: boolean;
  103350. /**
  103351. * Maximum distance to hear that sound
  103352. */
  103353. maxDistance?: number;
  103354. /**
  103355. * Uses user defined attenuation function
  103356. */
  103357. useCustomAttenuation?: boolean;
  103358. /**
  103359. * Define the roll off factor of spatial sounds.
  103360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103361. */
  103362. rolloffFactor?: number;
  103363. /**
  103364. * Define the reference distance the sound should be heard perfectly.
  103365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103366. */
  103367. refDistance?: number;
  103368. /**
  103369. * Define the distance attenuation model the sound will follow.
  103370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103371. */
  103372. distanceModel?: string;
  103373. /**
  103374. * Defines the playback speed (1 by default)
  103375. */
  103376. playbackRate?: number;
  103377. /**
  103378. * Defines if the sound is from a streaming source
  103379. */
  103380. streaming?: boolean;
  103381. /**
  103382. * Defines an optional length (in seconds) inside the sound file
  103383. */
  103384. length?: number;
  103385. /**
  103386. * Defines an optional offset (in seconds) inside the sound file
  103387. */
  103388. offset?: number;
  103389. /**
  103390. * If true, URLs will not be required to state the audio file codec to use.
  103391. */
  103392. skipCodecCheck?: boolean;
  103393. }
  103394. /**
  103395. * Defines a sound that can be played in the application.
  103396. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103398. */
  103399. export class Sound {
  103400. /**
  103401. * The name of the sound in the scene.
  103402. */
  103403. name: string;
  103404. /**
  103405. * Does the sound autoplay once loaded.
  103406. */
  103407. autoplay: boolean;
  103408. /**
  103409. * Does the sound loop after it finishes playing once.
  103410. */
  103411. loop: boolean;
  103412. /**
  103413. * Does the sound use a custom attenuation curve to simulate the falloff
  103414. * happening when the source gets further away from the camera.
  103415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103416. */
  103417. useCustomAttenuation: boolean;
  103418. /**
  103419. * The sound track id this sound belongs to.
  103420. */
  103421. soundTrackId: number;
  103422. /**
  103423. * Is this sound currently played.
  103424. */
  103425. isPlaying: boolean;
  103426. /**
  103427. * Is this sound currently paused.
  103428. */
  103429. isPaused: boolean;
  103430. /**
  103431. * Does this sound enables spatial sound.
  103432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103433. */
  103434. spatialSound: boolean;
  103435. /**
  103436. * Define the reference distance the sound should be heard perfectly.
  103437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103438. */
  103439. refDistance: number;
  103440. /**
  103441. * Define the roll off factor of spatial sounds.
  103442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103443. */
  103444. rolloffFactor: number;
  103445. /**
  103446. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103448. */
  103449. maxDistance: number;
  103450. /**
  103451. * Define the distance attenuation model the sound will follow.
  103452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103453. */
  103454. distanceModel: string;
  103455. /**
  103456. * @hidden
  103457. * Back Compat
  103458. **/
  103459. onended: () => any;
  103460. /**
  103461. * Observable event when the current playing sound finishes.
  103462. */
  103463. onEndedObservable: Observable<Sound>;
  103464. private _panningModel;
  103465. private _playbackRate;
  103466. private _streaming;
  103467. private _startTime;
  103468. private _startOffset;
  103469. private _position;
  103470. /** @hidden */
  103471. _positionInEmitterSpace: boolean;
  103472. private _localDirection;
  103473. private _volume;
  103474. private _isReadyToPlay;
  103475. private _isDirectional;
  103476. private _readyToPlayCallback;
  103477. private _audioBuffer;
  103478. private _soundSource;
  103479. private _streamingSource;
  103480. private _soundPanner;
  103481. private _soundGain;
  103482. private _inputAudioNode;
  103483. private _outputAudioNode;
  103484. private _coneInnerAngle;
  103485. private _coneOuterAngle;
  103486. private _coneOuterGain;
  103487. private _scene;
  103488. private _connectedTransformNode;
  103489. private _customAttenuationFunction;
  103490. private _registerFunc;
  103491. private _isOutputConnected;
  103492. private _htmlAudioElement;
  103493. private _urlType;
  103494. private _length?;
  103495. private _offset?;
  103496. /** @hidden */
  103497. static _SceneComponentInitialization: (scene: Scene) => void;
  103498. /**
  103499. * Create a sound and attach it to a scene
  103500. * @param name Name of your sound
  103501. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103502. * @param scene defines the scene the sound belongs to
  103503. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103504. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103505. */
  103506. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103507. /**
  103508. * Release the sound and its associated resources
  103509. */
  103510. dispose(): void;
  103511. /**
  103512. * Gets if the sounds is ready to be played or not.
  103513. * @returns true if ready, otherwise false
  103514. */
  103515. isReady(): boolean;
  103516. private _soundLoaded;
  103517. /**
  103518. * Sets the data of the sound from an audiobuffer
  103519. * @param audioBuffer The audioBuffer containing the data
  103520. */
  103521. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103522. /**
  103523. * Updates the current sounds options such as maxdistance, loop...
  103524. * @param options A JSON object containing values named as the object properties
  103525. */
  103526. updateOptions(options: ISoundOptions): void;
  103527. private _createSpatialParameters;
  103528. private _updateSpatialParameters;
  103529. /**
  103530. * Switch the panning model to HRTF:
  103531. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103533. */
  103534. switchPanningModelToHRTF(): void;
  103535. /**
  103536. * Switch the panning model to Equal Power:
  103537. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103539. */
  103540. switchPanningModelToEqualPower(): void;
  103541. private _switchPanningModel;
  103542. /**
  103543. * Connect this sound to a sound track audio node like gain...
  103544. * @param soundTrackAudioNode the sound track audio node to connect to
  103545. */
  103546. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103547. /**
  103548. * Transform this sound into a directional source
  103549. * @param coneInnerAngle Size of the inner cone in degree
  103550. * @param coneOuterAngle Size of the outer cone in degree
  103551. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103552. */
  103553. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103554. /**
  103555. * Gets or sets the inner angle for the directional cone.
  103556. */
  103557. /**
  103558. * Gets or sets the inner angle for the directional cone.
  103559. */
  103560. directionalConeInnerAngle: number;
  103561. /**
  103562. * Gets or sets the outer angle for the directional cone.
  103563. */
  103564. /**
  103565. * Gets or sets the outer angle for the directional cone.
  103566. */
  103567. directionalConeOuterAngle: number;
  103568. /**
  103569. * Sets the position of the emitter if spatial sound is enabled
  103570. * @param newPosition Defines the new posisiton
  103571. */
  103572. setPosition(newPosition: Vector3): void;
  103573. /**
  103574. * Sets the local direction of the emitter if spatial sound is enabled
  103575. * @param newLocalDirection Defines the new local direction
  103576. */
  103577. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103578. private _updateDirection;
  103579. /** @hidden */
  103580. updateDistanceFromListener(): void;
  103581. /**
  103582. * Sets a new custom attenuation function for the sound.
  103583. * @param callback Defines the function used for the attenuation
  103584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103585. */
  103586. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103587. /**
  103588. * Play the sound
  103589. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103590. * @param offset (optional) Start the sound at a specific time in seconds
  103591. * @param length (optional) Sound duration (in seconds)
  103592. */
  103593. play(time?: number, offset?: number, length?: number): void;
  103594. private _onended;
  103595. /**
  103596. * Stop the sound
  103597. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103598. */
  103599. stop(time?: number): void;
  103600. /**
  103601. * Put the sound in pause
  103602. */
  103603. pause(): void;
  103604. /**
  103605. * Sets a dedicated volume for this sounds
  103606. * @param newVolume Define the new volume of the sound
  103607. * @param time Define time for gradual change to new volume
  103608. */
  103609. setVolume(newVolume: number, time?: number): void;
  103610. /**
  103611. * Set the sound play back rate
  103612. * @param newPlaybackRate Define the playback rate the sound should be played at
  103613. */
  103614. setPlaybackRate(newPlaybackRate: number): void;
  103615. /**
  103616. * Gets the volume of the sound.
  103617. * @returns the volume of the sound
  103618. */
  103619. getVolume(): number;
  103620. /**
  103621. * Attach the sound to a dedicated mesh
  103622. * @param transformNode The transform node to connect the sound with
  103623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103624. */
  103625. attachToMesh(transformNode: TransformNode): void;
  103626. /**
  103627. * Detach the sound from the previously attached mesh
  103628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103629. */
  103630. detachFromMesh(): void;
  103631. private _onRegisterAfterWorldMatrixUpdate;
  103632. /**
  103633. * Clone the current sound in the scene.
  103634. * @returns the new sound clone
  103635. */
  103636. clone(): Nullable<Sound>;
  103637. /**
  103638. * Gets the current underlying audio buffer containing the data
  103639. * @returns the audio buffer
  103640. */
  103641. getAudioBuffer(): Nullable<AudioBuffer>;
  103642. /**
  103643. * Serializes the Sound in a JSON representation
  103644. * @returns the JSON representation of the sound
  103645. */
  103646. serialize(): any;
  103647. /**
  103648. * Parse a JSON representation of a sound to innstantiate in a given scene
  103649. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103650. * @param scene Define the scene the new parsed sound should be created in
  103651. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103652. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103653. * @returns the newly parsed sound
  103654. */
  103655. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103656. }
  103657. }
  103658. declare module BABYLON {
  103659. /**
  103660. * This defines an action helpful to play a defined sound on a triggered action.
  103661. */
  103662. export class PlaySoundAction extends Action {
  103663. private _sound;
  103664. /**
  103665. * Instantiate the action
  103666. * @param triggerOptions defines the trigger options
  103667. * @param sound defines the sound to play
  103668. * @param condition defines the trigger related conditions
  103669. */
  103670. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103671. /** @hidden */
  103672. _prepare(): void;
  103673. /**
  103674. * Execute the action and play the sound.
  103675. */
  103676. execute(): void;
  103677. /**
  103678. * Serializes the actions and its related information.
  103679. * @param parent defines the object to serialize in
  103680. * @returns the serialized object
  103681. */
  103682. serialize(parent: any): any;
  103683. }
  103684. /**
  103685. * This defines an action helpful to stop a defined sound on a triggered action.
  103686. */
  103687. export class StopSoundAction extends Action {
  103688. private _sound;
  103689. /**
  103690. * Instantiate the action
  103691. * @param triggerOptions defines the trigger options
  103692. * @param sound defines the sound to stop
  103693. * @param condition defines the trigger related conditions
  103694. */
  103695. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103696. /** @hidden */
  103697. _prepare(): void;
  103698. /**
  103699. * Execute the action and stop the sound.
  103700. */
  103701. execute(): void;
  103702. /**
  103703. * Serializes the actions and its related information.
  103704. * @param parent defines the object to serialize in
  103705. * @returns the serialized object
  103706. */
  103707. serialize(parent: any): any;
  103708. }
  103709. }
  103710. declare module BABYLON {
  103711. /**
  103712. * This defines an action responsible to change the value of a property
  103713. * by interpolating between its current value and the newly set one once triggered.
  103714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103715. */
  103716. export class InterpolateValueAction extends Action {
  103717. /**
  103718. * Defines the path of the property where the value should be interpolated
  103719. */
  103720. propertyPath: string;
  103721. /**
  103722. * Defines the target value at the end of the interpolation.
  103723. */
  103724. value: any;
  103725. /**
  103726. * Defines the time it will take for the property to interpolate to the value.
  103727. */
  103728. duration: number;
  103729. /**
  103730. * Defines if the other scene animations should be stopped when the action has been triggered
  103731. */
  103732. stopOtherAnimations?: boolean;
  103733. /**
  103734. * Defines a callback raised once the interpolation animation has been done.
  103735. */
  103736. onInterpolationDone?: () => void;
  103737. /**
  103738. * Observable triggered once the interpolation animation has been done.
  103739. */
  103740. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103741. private _target;
  103742. private _effectiveTarget;
  103743. private _property;
  103744. /**
  103745. * Instantiate the action
  103746. * @param triggerOptions defines the trigger options
  103747. * @param target defines the object containing the value to interpolate
  103748. * @param propertyPath defines the path to the property in the target object
  103749. * @param value defines the target value at the end of the interpolation
  103750. * @param duration deines the time it will take for the property to interpolate to the value.
  103751. * @param condition defines the trigger related conditions
  103752. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103753. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103754. */
  103755. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103756. /** @hidden */
  103757. _prepare(): void;
  103758. /**
  103759. * Execute the action starts the value interpolation.
  103760. */
  103761. execute(): void;
  103762. /**
  103763. * Serializes the actions and its related information.
  103764. * @param parent defines the object to serialize in
  103765. * @returns the serialized object
  103766. */
  103767. serialize(parent: any): any;
  103768. }
  103769. }
  103770. declare module BABYLON {
  103771. /**
  103772. * Options allowed during the creation of a sound track.
  103773. */
  103774. export interface ISoundTrackOptions {
  103775. /**
  103776. * The volume the sound track should take during creation
  103777. */
  103778. volume?: number;
  103779. /**
  103780. * Define if the sound track is the main sound track of the scene
  103781. */
  103782. mainTrack?: boolean;
  103783. }
  103784. /**
  103785. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103786. * It will be also used in a future release to apply effects on a specific track.
  103787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103788. */
  103789. export class SoundTrack {
  103790. /**
  103791. * The unique identifier of the sound track in the scene.
  103792. */
  103793. id: number;
  103794. /**
  103795. * The list of sounds included in the sound track.
  103796. */
  103797. soundCollection: Array<Sound>;
  103798. private _outputAudioNode;
  103799. private _scene;
  103800. private _isMainTrack;
  103801. private _connectedAnalyser;
  103802. private _options;
  103803. private _isInitialized;
  103804. /**
  103805. * Creates a new sound track.
  103806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103807. * @param scene Define the scene the sound track belongs to
  103808. * @param options
  103809. */
  103810. constructor(scene: Scene, options?: ISoundTrackOptions);
  103811. private _initializeSoundTrackAudioGraph;
  103812. /**
  103813. * Release the sound track and its associated resources
  103814. */
  103815. dispose(): void;
  103816. /**
  103817. * Adds a sound to this sound track
  103818. * @param sound define the cound to add
  103819. * @ignoreNaming
  103820. */
  103821. AddSound(sound: Sound): void;
  103822. /**
  103823. * Removes a sound to this sound track
  103824. * @param sound define the cound to remove
  103825. * @ignoreNaming
  103826. */
  103827. RemoveSound(sound: Sound): void;
  103828. /**
  103829. * Set a global volume for the full sound track.
  103830. * @param newVolume Define the new volume of the sound track
  103831. */
  103832. setVolume(newVolume: number): void;
  103833. /**
  103834. * Switch the panning model to HRTF:
  103835. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103837. */
  103838. switchPanningModelToHRTF(): void;
  103839. /**
  103840. * Switch the panning model to Equal Power:
  103841. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103843. */
  103844. switchPanningModelToEqualPower(): void;
  103845. /**
  103846. * Connect the sound track to an audio analyser allowing some amazing
  103847. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103849. * @param analyser The analyser to connect to the engine
  103850. */
  103851. connectToAnalyser(analyser: Analyser): void;
  103852. }
  103853. }
  103854. declare module BABYLON {
  103855. interface AbstractScene {
  103856. /**
  103857. * The list of sounds used in the scene.
  103858. */
  103859. sounds: Nullable<Array<Sound>>;
  103860. }
  103861. interface Scene {
  103862. /**
  103863. * @hidden
  103864. * Backing field
  103865. */
  103866. _mainSoundTrack: SoundTrack;
  103867. /**
  103868. * The main sound track played by the scene.
  103869. * It cotains your primary collection of sounds.
  103870. */
  103871. mainSoundTrack: SoundTrack;
  103872. /**
  103873. * The list of sound tracks added to the scene
  103874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103875. */
  103876. soundTracks: Nullable<Array<SoundTrack>>;
  103877. /**
  103878. * Gets a sound using a given name
  103879. * @param name defines the name to search for
  103880. * @return the found sound or null if not found at all.
  103881. */
  103882. getSoundByName(name: string): Nullable<Sound>;
  103883. /**
  103884. * Gets or sets if audio support is enabled
  103885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103886. */
  103887. audioEnabled: boolean;
  103888. /**
  103889. * Gets or sets if audio will be output to headphones
  103890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103891. */
  103892. headphone: boolean;
  103893. /**
  103894. * Gets or sets custom audio listener position provider
  103895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103896. */
  103897. audioListenerPositionProvider: Nullable<() => Vector3>;
  103898. /**
  103899. * Gets or sets a refresh rate when using 3D audio positioning
  103900. */
  103901. audioPositioningRefreshRate: number;
  103902. }
  103903. /**
  103904. * Defines the sound scene component responsible to manage any sounds
  103905. * in a given scene.
  103906. */
  103907. export class AudioSceneComponent implements ISceneSerializableComponent {
  103908. /**
  103909. * The component name helpfull to identify the component in the list of scene components.
  103910. */
  103911. readonly name: string;
  103912. /**
  103913. * The scene the component belongs to.
  103914. */
  103915. scene: Scene;
  103916. private _audioEnabled;
  103917. /**
  103918. * Gets whether audio is enabled or not.
  103919. * Please use related enable/disable method to switch state.
  103920. */
  103921. readonly audioEnabled: boolean;
  103922. private _headphone;
  103923. /**
  103924. * Gets whether audio is outputing to headphone or not.
  103925. * Please use the according Switch methods to change output.
  103926. */
  103927. readonly headphone: boolean;
  103928. /**
  103929. * Gets or sets a refresh rate when using 3D audio positioning
  103930. */
  103931. audioPositioningRefreshRate: number;
  103932. private _audioListenerPositionProvider;
  103933. /**
  103934. * Gets the current audio listener position provider
  103935. */
  103936. /**
  103937. * Sets a custom listener position for all sounds in the scene
  103938. * By default, this is the position of the first active camera
  103939. */
  103940. audioListenerPositionProvider: Nullable<() => Vector3>;
  103941. /**
  103942. * Creates a new instance of the component for the given scene
  103943. * @param scene Defines the scene to register the component in
  103944. */
  103945. constructor(scene: Scene);
  103946. /**
  103947. * Registers the component in a given scene
  103948. */
  103949. register(): void;
  103950. /**
  103951. * Rebuilds the elements related to this component in case of
  103952. * context lost for instance.
  103953. */
  103954. rebuild(): void;
  103955. /**
  103956. * Serializes the component data to the specified json object
  103957. * @param serializationObject The object to serialize to
  103958. */
  103959. serialize(serializationObject: any): void;
  103960. /**
  103961. * Adds all the elements from the container to the scene
  103962. * @param container the container holding the elements
  103963. */
  103964. addFromContainer(container: AbstractScene): void;
  103965. /**
  103966. * Removes all the elements in the container from the scene
  103967. * @param container contains the elements to remove
  103968. * @param dispose if the removed element should be disposed (default: false)
  103969. */
  103970. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103971. /**
  103972. * Disposes the component and the associated ressources.
  103973. */
  103974. dispose(): void;
  103975. /**
  103976. * Disables audio in the associated scene.
  103977. */
  103978. disableAudio(): void;
  103979. /**
  103980. * Enables audio in the associated scene.
  103981. */
  103982. enableAudio(): void;
  103983. /**
  103984. * Switch audio to headphone output.
  103985. */
  103986. switchAudioModeForHeadphones(): void;
  103987. /**
  103988. * Switch audio to normal speakers.
  103989. */
  103990. switchAudioModeForNormalSpeakers(): void;
  103991. private _cachedCameraDirection;
  103992. private _cachedCameraPosition;
  103993. private _lastCheck;
  103994. private _afterRender;
  103995. }
  103996. }
  103997. declare module BABYLON {
  103998. /**
  103999. * Wraps one or more Sound objects and selects one with random weight for playback.
  104000. */
  104001. export class WeightedSound {
  104002. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104003. loop: boolean;
  104004. private _coneInnerAngle;
  104005. private _coneOuterAngle;
  104006. private _volume;
  104007. /** A Sound is currently playing. */
  104008. isPlaying: boolean;
  104009. /** A Sound is currently paused. */
  104010. isPaused: boolean;
  104011. private _sounds;
  104012. private _weights;
  104013. private _currentIndex?;
  104014. /**
  104015. * Creates a new WeightedSound from the list of sounds given.
  104016. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104017. * @param sounds Array of Sounds that will be selected from.
  104018. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104019. */
  104020. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104021. /**
  104022. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104023. */
  104024. /**
  104025. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104026. */
  104027. directionalConeInnerAngle: number;
  104028. /**
  104029. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104030. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104031. */
  104032. /**
  104033. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104034. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104035. */
  104036. directionalConeOuterAngle: number;
  104037. /**
  104038. * Playback volume.
  104039. */
  104040. /**
  104041. * Playback volume.
  104042. */
  104043. volume: number;
  104044. private _onended;
  104045. /**
  104046. * Suspend playback
  104047. */
  104048. pause(): void;
  104049. /**
  104050. * Stop playback
  104051. */
  104052. stop(): void;
  104053. /**
  104054. * Start playback.
  104055. * @param startOffset Position the clip head at a specific time in seconds.
  104056. */
  104057. play(startOffset?: number): void;
  104058. }
  104059. }
  104060. declare module BABYLON {
  104061. /**
  104062. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104063. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104064. */
  104065. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104066. /**
  104067. * Gets the name of the behavior.
  104068. */
  104069. readonly name: string;
  104070. /**
  104071. * The easing function used by animations
  104072. */
  104073. static EasingFunction: BackEase;
  104074. /**
  104075. * The easing mode used by animations
  104076. */
  104077. static EasingMode: number;
  104078. /**
  104079. * The duration of the animation, in milliseconds
  104080. */
  104081. transitionDuration: number;
  104082. /**
  104083. * Length of the distance animated by the transition when lower radius is reached
  104084. */
  104085. lowerRadiusTransitionRange: number;
  104086. /**
  104087. * Length of the distance animated by the transition when upper radius is reached
  104088. */
  104089. upperRadiusTransitionRange: number;
  104090. private _autoTransitionRange;
  104091. /**
  104092. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104093. */
  104094. /**
  104095. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104096. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104097. */
  104098. autoTransitionRange: boolean;
  104099. private _attachedCamera;
  104100. private _onAfterCheckInputsObserver;
  104101. private _onMeshTargetChangedObserver;
  104102. /**
  104103. * Initializes the behavior.
  104104. */
  104105. init(): void;
  104106. /**
  104107. * Attaches the behavior to its arc rotate camera.
  104108. * @param camera Defines the camera to attach the behavior to
  104109. */
  104110. attach(camera: ArcRotateCamera): void;
  104111. /**
  104112. * Detaches the behavior from its current arc rotate camera.
  104113. */
  104114. detach(): void;
  104115. private _radiusIsAnimating;
  104116. private _radiusBounceTransition;
  104117. private _animatables;
  104118. private _cachedWheelPrecision;
  104119. /**
  104120. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104121. * @param radiusLimit The limit to check against.
  104122. * @return Bool to indicate if at limit.
  104123. */
  104124. private _isRadiusAtLimit;
  104125. /**
  104126. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104127. * @param radiusDelta The delta by which to animate to. Can be negative.
  104128. */
  104129. private _applyBoundRadiusAnimation;
  104130. /**
  104131. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104132. */
  104133. protected _clearAnimationLocks(): void;
  104134. /**
  104135. * Stops and removes all animations that have been applied to the camera
  104136. */
  104137. stopAllAnimations(): void;
  104138. }
  104139. }
  104140. declare module BABYLON {
  104141. /**
  104142. * 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.
  104143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104144. */
  104145. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104146. /**
  104147. * Gets the name of the behavior.
  104148. */
  104149. readonly name: string;
  104150. private _mode;
  104151. private _radiusScale;
  104152. private _positionScale;
  104153. private _defaultElevation;
  104154. private _elevationReturnTime;
  104155. private _elevationReturnWaitTime;
  104156. private _zoomStopsAnimation;
  104157. private _framingTime;
  104158. /**
  104159. * The easing function used by animations
  104160. */
  104161. static EasingFunction: ExponentialEase;
  104162. /**
  104163. * The easing mode used by animations
  104164. */
  104165. static EasingMode: number;
  104166. /**
  104167. * Sets the current mode used by the behavior
  104168. */
  104169. /**
  104170. * Gets current mode used by the behavior.
  104171. */
  104172. mode: number;
  104173. /**
  104174. * Sets the scale applied to the radius (1 by default)
  104175. */
  104176. /**
  104177. * Gets the scale applied to the radius
  104178. */
  104179. radiusScale: number;
  104180. /**
  104181. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104182. */
  104183. /**
  104184. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104185. */
  104186. positionScale: number;
  104187. /**
  104188. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104189. * behaviour is triggered, in radians.
  104190. */
  104191. /**
  104192. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104193. * behaviour is triggered, in radians.
  104194. */
  104195. defaultElevation: number;
  104196. /**
  104197. * Sets the time (in milliseconds) taken to return to the default beta position.
  104198. * Negative value indicates camera should not return to default.
  104199. */
  104200. /**
  104201. * Gets the time (in milliseconds) taken to return to the default beta position.
  104202. * Negative value indicates camera should not return to default.
  104203. */
  104204. elevationReturnTime: number;
  104205. /**
  104206. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104207. */
  104208. /**
  104209. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104210. */
  104211. elevationReturnWaitTime: number;
  104212. /**
  104213. * Sets the flag that indicates if user zooming should stop animation.
  104214. */
  104215. /**
  104216. * Gets the flag that indicates if user zooming should stop animation.
  104217. */
  104218. zoomStopsAnimation: boolean;
  104219. /**
  104220. * Sets the transition time when framing the mesh, in milliseconds
  104221. */
  104222. /**
  104223. * Gets the transition time when framing the mesh, in milliseconds
  104224. */
  104225. framingTime: number;
  104226. /**
  104227. * Define if the behavior should automatically change the configured
  104228. * camera limits and sensibilities.
  104229. */
  104230. autoCorrectCameraLimitsAndSensibility: boolean;
  104231. private _onPrePointerObservableObserver;
  104232. private _onAfterCheckInputsObserver;
  104233. private _onMeshTargetChangedObserver;
  104234. private _attachedCamera;
  104235. private _isPointerDown;
  104236. private _lastInteractionTime;
  104237. /**
  104238. * Initializes the behavior.
  104239. */
  104240. init(): void;
  104241. /**
  104242. * Attaches the behavior to its arc rotate camera.
  104243. * @param camera Defines the camera to attach the behavior to
  104244. */
  104245. attach(camera: ArcRotateCamera): void;
  104246. /**
  104247. * Detaches the behavior from its current arc rotate camera.
  104248. */
  104249. detach(): void;
  104250. private _animatables;
  104251. private _betaIsAnimating;
  104252. private _betaTransition;
  104253. private _radiusTransition;
  104254. private _vectorTransition;
  104255. /**
  104256. * Targets the given mesh and updates zoom level accordingly.
  104257. * @param mesh The mesh to target.
  104258. * @param radius Optional. If a cached radius position already exists, overrides default.
  104259. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104260. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104261. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104262. */
  104263. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104264. /**
  104265. * Targets the given mesh with its children and updates zoom level accordingly.
  104266. * @param mesh The mesh to target.
  104267. * @param radius Optional. If a cached radius position already exists, overrides default.
  104268. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104269. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104270. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104271. */
  104272. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104273. /**
  104274. * Targets the given meshes with their children and updates zoom level accordingly.
  104275. * @param meshes The mesh to target.
  104276. * @param radius Optional. If a cached radius position already exists, overrides default.
  104277. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104278. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104279. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104280. */
  104281. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104282. /**
  104283. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104284. * @param minimumWorld Determines the smaller position of the bounding box extend
  104285. * @param maximumWorld Determines the bigger position of the bounding box extend
  104286. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104287. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104288. */
  104289. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104290. /**
  104291. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104292. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104293. * frustum width.
  104294. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104295. * to fully enclose the mesh in the viewing frustum.
  104296. */
  104297. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104298. /**
  104299. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104300. * is automatically returned to its default position (expected to be above ground plane).
  104301. */
  104302. private _maintainCameraAboveGround;
  104303. /**
  104304. * Returns the frustum slope based on the canvas ratio and camera FOV
  104305. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104306. */
  104307. private _getFrustumSlope;
  104308. /**
  104309. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104310. */
  104311. private _clearAnimationLocks;
  104312. /**
  104313. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104314. */
  104315. private _applyUserInteraction;
  104316. /**
  104317. * Stops and removes all animations that have been applied to the camera
  104318. */
  104319. stopAllAnimations(): void;
  104320. /**
  104321. * Gets a value indicating if the user is moving the camera
  104322. */
  104323. readonly isUserIsMoving: boolean;
  104324. /**
  104325. * The camera can move all the way towards the mesh.
  104326. */
  104327. static IgnoreBoundsSizeMode: number;
  104328. /**
  104329. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104330. */
  104331. static FitFrustumSidesMode: number;
  104332. }
  104333. }
  104334. declare module BABYLON {
  104335. /**
  104336. * Base class for Camera Pointer Inputs.
  104337. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104338. * for example usage.
  104339. */
  104340. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104341. /**
  104342. * Defines the camera the input is attached to.
  104343. */
  104344. abstract camera: Camera;
  104345. /**
  104346. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104347. */
  104348. protected _altKey: boolean;
  104349. protected _ctrlKey: boolean;
  104350. protected _metaKey: boolean;
  104351. protected _shiftKey: boolean;
  104352. /**
  104353. * Which mouse buttons were pressed at time of last mouse event.
  104354. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104355. */
  104356. protected _buttonsPressed: number;
  104357. /**
  104358. * Defines the buttons associated with the input to handle camera move.
  104359. */
  104360. buttons: number[];
  104361. /**
  104362. * Attach the input controls to a specific dom element to get the input from.
  104363. * @param element Defines the element the controls should be listened from
  104364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104365. */
  104366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104367. /**
  104368. * Detach the current controls from the specified dom element.
  104369. * @param element Defines the element to stop listening the inputs from
  104370. */
  104371. detachControl(element: Nullable<HTMLElement>): void;
  104372. /**
  104373. * Gets the class name of the current input.
  104374. * @returns the class name
  104375. */
  104376. getClassName(): string;
  104377. /**
  104378. * Get the friendly name associated with the input class.
  104379. * @returns the input friendly name
  104380. */
  104381. getSimpleName(): string;
  104382. /**
  104383. * Called on pointer POINTERDOUBLETAP event.
  104384. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104385. */
  104386. protected onDoubleTap(type: string): void;
  104387. /**
  104388. * Called on pointer POINTERMOVE event if only a single touch is active.
  104389. * Override this method to provide functionality.
  104390. */
  104391. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104392. /**
  104393. * Called on pointer POINTERMOVE event if multiple touches are active.
  104394. * Override this method to provide functionality.
  104395. */
  104396. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104397. /**
  104398. * Called on JS contextmenu event.
  104399. * Override this method to provide functionality.
  104400. */
  104401. protected onContextMenu(evt: PointerEvent): void;
  104402. /**
  104403. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104404. * press.
  104405. * Override this method to provide functionality.
  104406. */
  104407. protected onButtonDown(evt: PointerEvent): void;
  104408. /**
  104409. * Called each time a new POINTERUP event occurs. Ie, for each button
  104410. * release.
  104411. * Override this method to provide functionality.
  104412. */
  104413. protected onButtonUp(evt: PointerEvent): void;
  104414. /**
  104415. * Called when window becomes inactive.
  104416. * Override this method to provide functionality.
  104417. */
  104418. protected onLostFocus(): void;
  104419. private _pointerInput;
  104420. private _observer;
  104421. private _onLostFocus;
  104422. private pointA;
  104423. private pointB;
  104424. }
  104425. }
  104426. declare module BABYLON {
  104427. /**
  104428. * Manage the pointers inputs to control an arc rotate camera.
  104429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104430. */
  104431. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104432. /**
  104433. * Defines the camera the input is attached to.
  104434. */
  104435. camera: ArcRotateCamera;
  104436. /**
  104437. * Gets the class name of the current input.
  104438. * @returns the class name
  104439. */
  104440. getClassName(): string;
  104441. /**
  104442. * Defines the buttons associated with the input to handle camera move.
  104443. */
  104444. buttons: number[];
  104445. /**
  104446. * Defines the pointer angular sensibility along the X axis or how fast is
  104447. * the camera rotating.
  104448. */
  104449. angularSensibilityX: number;
  104450. /**
  104451. * Defines the pointer angular sensibility along the Y axis or how fast is
  104452. * the camera rotating.
  104453. */
  104454. angularSensibilityY: number;
  104455. /**
  104456. * Defines the pointer pinch precision or how fast is the camera zooming.
  104457. */
  104458. pinchPrecision: number;
  104459. /**
  104460. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104461. * from 0.
  104462. * It defines the percentage of current camera.radius to use as delta when
  104463. * pinch zoom is used.
  104464. */
  104465. pinchDeltaPercentage: number;
  104466. /**
  104467. * Defines the pointer panning sensibility or how fast is the camera moving.
  104468. */
  104469. panningSensibility: number;
  104470. /**
  104471. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104472. */
  104473. multiTouchPanning: boolean;
  104474. /**
  104475. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104476. * zoom (pinch) through multitouch.
  104477. */
  104478. multiTouchPanAndZoom: boolean;
  104479. /**
  104480. * Revers pinch action direction.
  104481. */
  104482. pinchInwards: boolean;
  104483. private _isPanClick;
  104484. private _twoFingerActivityCount;
  104485. private _isPinching;
  104486. /**
  104487. * Called on pointer POINTERMOVE event if only a single touch is active.
  104488. */
  104489. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104490. /**
  104491. * Called on pointer POINTERDOUBLETAP event.
  104492. */
  104493. protected onDoubleTap(type: string): void;
  104494. /**
  104495. * Called on pointer POINTERMOVE event if multiple touches are active.
  104496. */
  104497. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104498. /**
  104499. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104500. * press.
  104501. */
  104502. protected onButtonDown(evt: PointerEvent): void;
  104503. /**
  104504. * Called each time a new POINTERUP event occurs. Ie, for each button
  104505. * release.
  104506. */
  104507. protected onButtonUp(evt: PointerEvent): void;
  104508. /**
  104509. * Called when window becomes inactive.
  104510. */
  104511. protected onLostFocus(): void;
  104512. }
  104513. }
  104514. declare module BABYLON {
  104515. /**
  104516. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104518. */
  104519. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104520. /**
  104521. * Defines the camera the input is attached to.
  104522. */
  104523. camera: ArcRotateCamera;
  104524. /**
  104525. * Defines the list of key codes associated with the up action (increase alpha)
  104526. */
  104527. keysUp: number[];
  104528. /**
  104529. * Defines the list of key codes associated with the down action (decrease alpha)
  104530. */
  104531. keysDown: number[];
  104532. /**
  104533. * Defines the list of key codes associated with the left action (increase beta)
  104534. */
  104535. keysLeft: number[];
  104536. /**
  104537. * Defines the list of key codes associated with the right action (decrease beta)
  104538. */
  104539. keysRight: number[];
  104540. /**
  104541. * Defines the list of key codes associated with the reset action.
  104542. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104543. */
  104544. keysReset: number[];
  104545. /**
  104546. * Defines the panning sensibility of the inputs.
  104547. * (How fast is the camera paning)
  104548. */
  104549. panningSensibility: number;
  104550. /**
  104551. * Defines the zooming sensibility of the inputs.
  104552. * (How fast is the camera zooming)
  104553. */
  104554. zoomingSensibility: number;
  104555. /**
  104556. * Defines wether maintaining the alt key down switch the movement mode from
  104557. * orientation to zoom.
  104558. */
  104559. useAltToZoom: boolean;
  104560. /**
  104561. * Rotation speed of the camera
  104562. */
  104563. angularSpeed: number;
  104564. private _keys;
  104565. private _ctrlPressed;
  104566. private _altPressed;
  104567. private _onCanvasBlurObserver;
  104568. private _onKeyboardObserver;
  104569. private _engine;
  104570. private _scene;
  104571. /**
  104572. * Attach the input controls to a specific dom element to get the input from.
  104573. * @param element Defines the element the controls should be listened from
  104574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104575. */
  104576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104577. /**
  104578. * Detach the current controls from the specified dom element.
  104579. * @param element Defines the element to stop listening the inputs from
  104580. */
  104581. detachControl(element: Nullable<HTMLElement>): void;
  104582. /**
  104583. * Update the current camera state depending on the inputs that have been used this frame.
  104584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104585. */
  104586. checkInputs(): void;
  104587. /**
  104588. * Gets the class name of the current intput.
  104589. * @returns the class name
  104590. */
  104591. getClassName(): string;
  104592. /**
  104593. * Get the friendly name associated with the input class.
  104594. * @returns the input friendly name
  104595. */
  104596. getSimpleName(): string;
  104597. }
  104598. }
  104599. declare module BABYLON {
  104600. /**
  104601. * Manage the mouse wheel inputs to control an arc rotate camera.
  104602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104603. */
  104604. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104605. /**
  104606. * Defines the camera the input is attached to.
  104607. */
  104608. camera: ArcRotateCamera;
  104609. /**
  104610. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104611. */
  104612. wheelPrecision: number;
  104613. /**
  104614. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104615. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104616. */
  104617. wheelDeltaPercentage: number;
  104618. private _wheel;
  104619. private _observer;
  104620. private computeDeltaFromMouseWheelLegacyEvent;
  104621. /**
  104622. * Attach the input controls to a specific dom element to get the input from.
  104623. * @param element Defines the element the controls should be listened from
  104624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104625. */
  104626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104627. /**
  104628. * Detach the current controls from the specified dom element.
  104629. * @param element Defines the element to stop listening the inputs from
  104630. */
  104631. detachControl(element: Nullable<HTMLElement>): void;
  104632. /**
  104633. * Gets the class name of the current intput.
  104634. * @returns the class name
  104635. */
  104636. getClassName(): string;
  104637. /**
  104638. * Get the friendly name associated with the input class.
  104639. * @returns the input friendly name
  104640. */
  104641. getSimpleName(): string;
  104642. }
  104643. }
  104644. declare module BABYLON {
  104645. /**
  104646. * Default Inputs manager for the ArcRotateCamera.
  104647. * It groups all the default supported inputs for ease of use.
  104648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104649. */
  104650. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104651. /**
  104652. * Instantiates a new ArcRotateCameraInputsManager.
  104653. * @param camera Defines the camera the inputs belong to
  104654. */
  104655. constructor(camera: ArcRotateCamera);
  104656. /**
  104657. * Add mouse wheel input support to the input manager.
  104658. * @returns the current input manager
  104659. */
  104660. addMouseWheel(): ArcRotateCameraInputsManager;
  104661. /**
  104662. * Add pointers input support to the input manager.
  104663. * @returns the current input manager
  104664. */
  104665. addPointers(): ArcRotateCameraInputsManager;
  104666. /**
  104667. * Add keyboard input support to the input manager.
  104668. * @returns the current input manager
  104669. */
  104670. addKeyboard(): ArcRotateCameraInputsManager;
  104671. }
  104672. }
  104673. declare module BABYLON {
  104674. /**
  104675. * This represents an orbital type of camera.
  104676. *
  104677. * 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.
  104678. * 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.
  104679. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104680. */
  104681. export class ArcRotateCamera extends TargetCamera {
  104682. /**
  104683. * Defines the rotation angle of the camera along the longitudinal axis.
  104684. */
  104685. alpha: number;
  104686. /**
  104687. * Defines the rotation angle of the camera along the latitudinal axis.
  104688. */
  104689. beta: number;
  104690. /**
  104691. * Defines the radius of the camera from it s target point.
  104692. */
  104693. radius: number;
  104694. protected _target: Vector3;
  104695. protected _targetHost: Nullable<AbstractMesh>;
  104696. /**
  104697. * Defines the target point of the camera.
  104698. * The camera looks towards it form the radius distance.
  104699. */
  104700. target: Vector3;
  104701. /**
  104702. * Define the current local position of the camera in the scene
  104703. */
  104704. position: Vector3;
  104705. protected _upVector: Vector3;
  104706. protected _upToYMatrix: Matrix;
  104707. protected _YToUpMatrix: Matrix;
  104708. /**
  104709. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104710. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104711. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104712. */
  104713. upVector: Vector3;
  104714. /**
  104715. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104716. */
  104717. setMatUp(): void;
  104718. /**
  104719. * Current inertia value on the longitudinal axis.
  104720. * The bigger this number the longer it will take for the camera to stop.
  104721. */
  104722. inertialAlphaOffset: number;
  104723. /**
  104724. * Current inertia value on the latitudinal axis.
  104725. * The bigger this number the longer it will take for the camera to stop.
  104726. */
  104727. inertialBetaOffset: number;
  104728. /**
  104729. * Current inertia value on the radius axis.
  104730. * The bigger this number the longer it will take for the camera to stop.
  104731. */
  104732. inertialRadiusOffset: number;
  104733. /**
  104734. * Minimum allowed angle on the longitudinal axis.
  104735. * This can help limiting how the Camera is able to move in the scene.
  104736. */
  104737. lowerAlphaLimit: Nullable<number>;
  104738. /**
  104739. * Maximum allowed angle on the longitudinal axis.
  104740. * This can help limiting how the Camera is able to move in the scene.
  104741. */
  104742. upperAlphaLimit: Nullable<number>;
  104743. /**
  104744. * Minimum allowed angle on the latitudinal axis.
  104745. * This can help limiting how the Camera is able to move in the scene.
  104746. */
  104747. lowerBetaLimit: number;
  104748. /**
  104749. * Maximum allowed angle on the latitudinal axis.
  104750. * This can help limiting how the Camera is able to move in the scene.
  104751. */
  104752. upperBetaLimit: number;
  104753. /**
  104754. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104755. * This can help limiting how the Camera is able to move in the scene.
  104756. */
  104757. lowerRadiusLimit: Nullable<number>;
  104758. /**
  104759. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104760. * This can help limiting how the Camera is able to move in the scene.
  104761. */
  104762. upperRadiusLimit: Nullable<number>;
  104763. /**
  104764. * Defines the current inertia value used during panning of the camera along the X axis.
  104765. */
  104766. inertialPanningX: number;
  104767. /**
  104768. * Defines the current inertia value used during panning of the camera along the Y axis.
  104769. */
  104770. inertialPanningY: number;
  104771. /**
  104772. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104773. * Basically if your fingers moves away from more than this distance you will be considered
  104774. * in pinch mode.
  104775. */
  104776. pinchToPanMaxDistance: number;
  104777. /**
  104778. * Defines the maximum distance the camera can pan.
  104779. * This could help keeping the cammera always in your scene.
  104780. */
  104781. panningDistanceLimit: Nullable<number>;
  104782. /**
  104783. * Defines the target of the camera before paning.
  104784. */
  104785. panningOriginTarget: Vector3;
  104786. /**
  104787. * Defines the value of the inertia used during panning.
  104788. * 0 would mean stop inertia and one would mean no decelleration at all.
  104789. */
  104790. panningInertia: number;
  104791. /**
  104792. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104793. */
  104794. angularSensibilityX: number;
  104795. /**
  104796. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104797. */
  104798. angularSensibilityY: number;
  104799. /**
  104800. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104801. */
  104802. pinchPrecision: number;
  104803. /**
  104804. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104805. * It will be used instead of pinchDeltaPrecision if different from 0.
  104806. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104807. */
  104808. pinchDeltaPercentage: number;
  104809. /**
  104810. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104811. */
  104812. panningSensibility: number;
  104813. /**
  104814. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104815. */
  104816. keysUp: number[];
  104817. /**
  104818. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104819. */
  104820. keysDown: number[];
  104821. /**
  104822. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104823. */
  104824. keysLeft: number[];
  104825. /**
  104826. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104827. */
  104828. keysRight: number[];
  104829. /**
  104830. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104831. */
  104832. wheelPrecision: number;
  104833. /**
  104834. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104835. * It will be used instead of pinchDeltaPrecision if different from 0.
  104836. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104837. */
  104838. wheelDeltaPercentage: number;
  104839. /**
  104840. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104841. */
  104842. zoomOnFactor: number;
  104843. /**
  104844. * Defines a screen offset for the camera position.
  104845. */
  104846. targetScreenOffset: Vector2;
  104847. /**
  104848. * Allows the camera to be completely reversed.
  104849. * If false the camera can not arrive upside down.
  104850. */
  104851. allowUpsideDown: boolean;
  104852. /**
  104853. * Define if double tap/click is used to restore the previously saved state of the camera.
  104854. */
  104855. useInputToRestoreState: boolean;
  104856. /** @hidden */
  104857. _viewMatrix: Matrix;
  104858. /** @hidden */
  104859. _useCtrlForPanning: boolean;
  104860. /** @hidden */
  104861. _panningMouseButton: number;
  104862. /**
  104863. * Defines the input associated to the camera.
  104864. */
  104865. inputs: ArcRotateCameraInputsManager;
  104866. /** @hidden */
  104867. _reset: () => void;
  104868. /**
  104869. * Defines the allowed panning axis.
  104870. */
  104871. panningAxis: Vector3;
  104872. protected _localDirection: Vector3;
  104873. protected _transformedDirection: Vector3;
  104874. private _bouncingBehavior;
  104875. /**
  104876. * Gets the bouncing behavior of the camera if it has been enabled.
  104877. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104878. */
  104879. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104880. /**
  104881. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104882. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104883. */
  104884. useBouncingBehavior: boolean;
  104885. private _framingBehavior;
  104886. /**
  104887. * Gets the framing behavior of the camera if it has been enabled.
  104888. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104889. */
  104890. readonly framingBehavior: Nullable<FramingBehavior>;
  104891. /**
  104892. * Defines if the framing behavior of the camera is enabled on the camera.
  104893. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104894. */
  104895. useFramingBehavior: boolean;
  104896. private _autoRotationBehavior;
  104897. /**
  104898. * Gets the auto rotation behavior of the camera if it has been enabled.
  104899. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104900. */
  104901. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104902. /**
  104903. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104904. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104905. */
  104906. useAutoRotationBehavior: boolean;
  104907. /**
  104908. * Observable triggered when the mesh target has been changed on the camera.
  104909. */
  104910. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104911. /**
  104912. * Event raised when the camera is colliding with a mesh.
  104913. */
  104914. onCollide: (collidedMesh: AbstractMesh) => void;
  104915. /**
  104916. * Defines whether the camera should check collision with the objects oh the scene.
  104917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104918. */
  104919. checkCollisions: boolean;
  104920. /**
  104921. * Defines the collision radius of the camera.
  104922. * This simulates a sphere around the camera.
  104923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104924. */
  104925. collisionRadius: Vector3;
  104926. protected _collider: Collider;
  104927. protected _previousPosition: Vector3;
  104928. protected _collisionVelocity: Vector3;
  104929. protected _newPosition: Vector3;
  104930. protected _previousAlpha: number;
  104931. protected _previousBeta: number;
  104932. protected _previousRadius: number;
  104933. protected _collisionTriggered: boolean;
  104934. protected _targetBoundingCenter: Nullable<Vector3>;
  104935. private _computationVector;
  104936. /**
  104937. * Instantiates a new ArcRotateCamera in a given scene
  104938. * @param name Defines the name of the camera
  104939. * @param alpha Defines the camera rotation along the logitudinal axis
  104940. * @param beta Defines the camera rotation along the latitudinal axis
  104941. * @param radius Defines the camera distance from its target
  104942. * @param target Defines the camera target
  104943. * @param scene Defines the scene the camera belongs to
  104944. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104945. */
  104946. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104947. /** @hidden */
  104948. _initCache(): void;
  104949. /** @hidden */
  104950. _updateCache(ignoreParentClass?: boolean): void;
  104951. protected _getTargetPosition(): Vector3;
  104952. private _storedAlpha;
  104953. private _storedBeta;
  104954. private _storedRadius;
  104955. private _storedTarget;
  104956. private _storedTargetScreenOffset;
  104957. /**
  104958. * Stores the current state of the camera (alpha, beta, radius and target)
  104959. * @returns the camera itself
  104960. */
  104961. storeState(): Camera;
  104962. /**
  104963. * @hidden
  104964. * Restored camera state. You must call storeState() first
  104965. */
  104966. _restoreStateValues(): boolean;
  104967. /** @hidden */
  104968. _isSynchronizedViewMatrix(): boolean;
  104969. /**
  104970. * Attached controls to the current camera.
  104971. * @param element Defines the element the controls should be listened from
  104972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104973. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104974. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104975. */
  104976. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104977. /**
  104978. * Detach the current controls from the camera.
  104979. * The camera will stop reacting to inputs.
  104980. * @param element Defines the element to stop listening the inputs from
  104981. */
  104982. detachControl(element: HTMLElement): void;
  104983. /** @hidden */
  104984. _checkInputs(): void;
  104985. protected _checkLimits(): void;
  104986. /**
  104987. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104988. */
  104989. rebuildAnglesAndRadius(): void;
  104990. /**
  104991. * Use a position to define the current camera related information like alpha, beta and radius
  104992. * @param position Defines the position to set the camera at
  104993. */
  104994. setPosition(position: Vector3): void;
  104995. /**
  104996. * Defines the target the camera should look at.
  104997. * This will automatically adapt alpha beta and radius to fit within the new target.
  104998. * @param target Defines the new target as a Vector or a mesh
  104999. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105000. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105001. */
  105002. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105003. /** @hidden */
  105004. _getViewMatrix(): Matrix;
  105005. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105006. /**
  105007. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105008. * @param meshes Defines the mesh to zoom on
  105009. * @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)
  105010. */
  105011. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105012. /**
  105013. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105014. * The target will be changed but the radius
  105015. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105016. * @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)
  105017. */
  105018. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105019. min: Vector3;
  105020. max: Vector3;
  105021. distance: number;
  105022. }, doNotUpdateMaxZ?: boolean): void;
  105023. /**
  105024. * @override
  105025. * Override Camera.createRigCamera
  105026. */
  105027. createRigCamera(name: string, cameraIndex: number): Camera;
  105028. /**
  105029. * @hidden
  105030. * @override
  105031. * Override Camera._updateRigCameras
  105032. */
  105033. _updateRigCameras(): void;
  105034. /**
  105035. * Destroy the camera and release the current resources hold by it.
  105036. */
  105037. dispose(): void;
  105038. /**
  105039. * Gets the current object class name.
  105040. * @return the class name
  105041. */
  105042. getClassName(): string;
  105043. }
  105044. }
  105045. declare module BABYLON {
  105046. /**
  105047. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105048. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105049. */
  105050. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105051. /**
  105052. * Gets the name of the behavior.
  105053. */
  105054. readonly name: string;
  105055. private _zoomStopsAnimation;
  105056. private _idleRotationSpeed;
  105057. private _idleRotationWaitTime;
  105058. private _idleRotationSpinupTime;
  105059. /**
  105060. * Sets the flag that indicates if user zooming should stop animation.
  105061. */
  105062. /**
  105063. * Gets the flag that indicates if user zooming should stop animation.
  105064. */
  105065. zoomStopsAnimation: boolean;
  105066. /**
  105067. * Sets the default speed at which the camera rotates around the model.
  105068. */
  105069. /**
  105070. * Gets the default speed at which the camera rotates around the model.
  105071. */
  105072. idleRotationSpeed: number;
  105073. /**
  105074. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105075. */
  105076. /**
  105077. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105078. */
  105079. idleRotationWaitTime: number;
  105080. /**
  105081. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105082. */
  105083. /**
  105084. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105085. */
  105086. idleRotationSpinupTime: number;
  105087. /**
  105088. * Gets a value indicating if the camera is currently rotating because of this behavior
  105089. */
  105090. readonly rotationInProgress: boolean;
  105091. private _onPrePointerObservableObserver;
  105092. private _onAfterCheckInputsObserver;
  105093. private _attachedCamera;
  105094. private _isPointerDown;
  105095. private _lastFrameTime;
  105096. private _lastInteractionTime;
  105097. private _cameraRotationSpeed;
  105098. /**
  105099. * Initializes the behavior.
  105100. */
  105101. init(): void;
  105102. /**
  105103. * Attaches the behavior to its arc rotate camera.
  105104. * @param camera Defines the camera to attach the behavior to
  105105. */
  105106. attach(camera: ArcRotateCamera): void;
  105107. /**
  105108. * Detaches the behavior from its current arc rotate camera.
  105109. */
  105110. detach(): void;
  105111. /**
  105112. * Returns true if user is scrolling.
  105113. * @return true if user is scrolling.
  105114. */
  105115. private _userIsZooming;
  105116. private _lastFrameRadius;
  105117. private _shouldAnimationStopForInteraction;
  105118. /**
  105119. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105120. */
  105121. private _applyUserInteraction;
  105122. private _userIsMoving;
  105123. }
  105124. }
  105125. declare module BABYLON {
  105126. /**
  105127. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105128. */
  105129. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105130. private ui;
  105131. /**
  105132. * The name of the behavior
  105133. */
  105134. name: string;
  105135. /**
  105136. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105137. */
  105138. distanceAwayFromFace: number;
  105139. /**
  105140. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105141. */
  105142. distanceAwayFromBottomOfFace: number;
  105143. private _faceVectors;
  105144. private _target;
  105145. private _scene;
  105146. private _onRenderObserver;
  105147. private _tmpMatrix;
  105148. private _tmpVector;
  105149. /**
  105150. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105151. * @param ui The transform node that should be attched to the mesh
  105152. */
  105153. constructor(ui: TransformNode);
  105154. /**
  105155. * Initializes the behavior
  105156. */
  105157. init(): void;
  105158. private _closestFace;
  105159. private _zeroVector;
  105160. private _lookAtTmpMatrix;
  105161. private _lookAtToRef;
  105162. /**
  105163. * Attaches the AttachToBoxBehavior to the passed in mesh
  105164. * @param target The mesh that the specified node will be attached to
  105165. */
  105166. attach(target: Mesh): void;
  105167. /**
  105168. * Detaches the behavior from the mesh
  105169. */
  105170. detach(): void;
  105171. }
  105172. }
  105173. declare module BABYLON {
  105174. /**
  105175. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105176. */
  105177. export class FadeInOutBehavior implements Behavior<Mesh> {
  105178. /**
  105179. * Time in milliseconds to delay before fading in (Default: 0)
  105180. */
  105181. delay: number;
  105182. /**
  105183. * Time in milliseconds for the mesh to fade in (Default: 300)
  105184. */
  105185. fadeInTime: number;
  105186. private _millisecondsPerFrame;
  105187. private _hovered;
  105188. private _hoverValue;
  105189. private _ownerNode;
  105190. /**
  105191. * Instatiates the FadeInOutBehavior
  105192. */
  105193. constructor();
  105194. /**
  105195. * The name of the behavior
  105196. */
  105197. readonly name: string;
  105198. /**
  105199. * Initializes the behavior
  105200. */
  105201. init(): void;
  105202. /**
  105203. * Attaches the fade behavior on the passed in mesh
  105204. * @param ownerNode The mesh that will be faded in/out once attached
  105205. */
  105206. attach(ownerNode: Mesh): void;
  105207. /**
  105208. * Detaches the behavior from the mesh
  105209. */
  105210. detach(): void;
  105211. /**
  105212. * Triggers the mesh to begin fading in or out
  105213. * @param value if the object should fade in or out (true to fade in)
  105214. */
  105215. fadeIn(value: boolean): void;
  105216. private _update;
  105217. private _setAllVisibility;
  105218. }
  105219. }
  105220. declare module BABYLON {
  105221. /**
  105222. * Class containing a set of static utilities functions for managing Pivots
  105223. * @hidden
  105224. */
  105225. export class PivotTools {
  105226. private static _PivotCached;
  105227. private static _OldPivotPoint;
  105228. private static _PivotTranslation;
  105229. private static _PivotTmpVector;
  105230. /** @hidden */
  105231. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105232. /** @hidden */
  105233. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105234. }
  105235. }
  105236. declare module BABYLON {
  105237. /**
  105238. * Class containing static functions to help procedurally build meshes
  105239. */
  105240. export class PlaneBuilder {
  105241. /**
  105242. * Creates a plane mesh
  105243. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105244. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105245. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105249. * @param name defines the name of the mesh
  105250. * @param options defines the options used to create the mesh
  105251. * @param scene defines the hosting scene
  105252. * @returns the plane mesh
  105253. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105254. */
  105255. static CreatePlane(name: string, options: {
  105256. size?: number;
  105257. width?: number;
  105258. height?: number;
  105259. sideOrientation?: number;
  105260. frontUVs?: Vector4;
  105261. backUVs?: Vector4;
  105262. updatable?: boolean;
  105263. sourcePlane?: Plane;
  105264. }, scene?: Nullable<Scene>): Mesh;
  105265. }
  105266. }
  105267. declare module BABYLON {
  105268. /**
  105269. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105270. */
  105271. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105272. private static _AnyMouseID;
  105273. /**
  105274. * Abstract mesh the behavior is set on
  105275. */
  105276. attachedNode: AbstractMesh;
  105277. private _dragPlane;
  105278. private _scene;
  105279. private _pointerObserver;
  105280. private _beforeRenderObserver;
  105281. private static _planeScene;
  105282. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105283. /**
  105284. * 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)
  105285. */
  105286. maxDragAngle: number;
  105287. /**
  105288. * @hidden
  105289. */
  105290. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105291. /**
  105292. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105293. */
  105294. currentDraggingPointerID: number;
  105295. /**
  105296. * The last position where the pointer hit the drag plane in world space
  105297. */
  105298. lastDragPosition: Vector3;
  105299. /**
  105300. * If the behavior is currently in a dragging state
  105301. */
  105302. dragging: boolean;
  105303. /**
  105304. * 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)
  105305. */
  105306. dragDeltaRatio: number;
  105307. /**
  105308. * If the drag plane orientation should be updated during the dragging (Default: true)
  105309. */
  105310. updateDragPlane: boolean;
  105311. private _debugMode;
  105312. private _moving;
  105313. /**
  105314. * Fires each time the attached mesh is dragged with the pointer
  105315. * * delta between last drag position and current drag position in world space
  105316. * * dragDistance along the drag axis
  105317. * * dragPlaneNormal normal of the current drag plane used during the drag
  105318. * * dragPlanePoint in world space where the drag intersects the drag plane
  105319. */
  105320. onDragObservable: Observable<{
  105321. delta: Vector3;
  105322. dragPlanePoint: Vector3;
  105323. dragPlaneNormal: Vector3;
  105324. dragDistance: number;
  105325. pointerId: number;
  105326. }>;
  105327. /**
  105328. * Fires each time a drag begins (eg. mouse down on mesh)
  105329. */
  105330. onDragStartObservable: Observable<{
  105331. dragPlanePoint: Vector3;
  105332. pointerId: number;
  105333. }>;
  105334. /**
  105335. * Fires each time a drag ends (eg. mouse release after drag)
  105336. */
  105337. onDragEndObservable: Observable<{
  105338. dragPlanePoint: Vector3;
  105339. pointerId: number;
  105340. }>;
  105341. /**
  105342. * If the attached mesh should be moved when dragged
  105343. */
  105344. moveAttached: boolean;
  105345. /**
  105346. * If the drag behavior will react to drag events (Default: true)
  105347. */
  105348. enabled: boolean;
  105349. /**
  105350. * If pointer events should start and release the drag (Default: true)
  105351. */
  105352. startAndReleaseDragOnPointerEvents: boolean;
  105353. /**
  105354. * If camera controls should be detached during the drag
  105355. */
  105356. detachCameraControls: boolean;
  105357. /**
  105358. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105359. */
  105360. useObjectOrienationForDragging: boolean;
  105361. private _options;
  105362. /**
  105363. * Creates a pointer drag behavior that can be attached to a mesh
  105364. * @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)
  105365. */
  105366. constructor(options?: {
  105367. dragAxis?: Vector3;
  105368. dragPlaneNormal?: Vector3;
  105369. });
  105370. /**
  105371. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105372. */
  105373. validateDrag: (targetPosition: Vector3) => boolean;
  105374. /**
  105375. * The name of the behavior
  105376. */
  105377. readonly name: string;
  105378. /**
  105379. * Initializes the behavior
  105380. */
  105381. init(): void;
  105382. private _tmpVector;
  105383. private _alternatePickedPoint;
  105384. private _worldDragAxis;
  105385. private _targetPosition;
  105386. private _attachedElement;
  105387. /**
  105388. * Attaches the drag behavior the passed in mesh
  105389. * @param ownerNode The mesh that will be dragged around once attached
  105390. * @param predicate Predicate to use for pick filtering
  105391. */
  105392. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105393. /**
  105394. * Force relase the drag action by code.
  105395. */
  105396. releaseDrag(): void;
  105397. private _startDragRay;
  105398. private _lastPointerRay;
  105399. /**
  105400. * Simulates the start of a pointer drag event on the behavior
  105401. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105402. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105403. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105404. */
  105405. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105406. private _startDrag;
  105407. private _dragDelta;
  105408. private _moveDrag;
  105409. private _pickWithRayOnDragPlane;
  105410. private _pointA;
  105411. private _pointB;
  105412. private _pointC;
  105413. private _lineA;
  105414. private _lineB;
  105415. private _localAxis;
  105416. private _lookAt;
  105417. private _updateDragPlanePosition;
  105418. /**
  105419. * Detaches the behavior from the mesh
  105420. */
  105421. detach(): void;
  105422. }
  105423. }
  105424. declare module BABYLON {
  105425. /**
  105426. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105427. */
  105428. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105429. private _dragBehaviorA;
  105430. private _dragBehaviorB;
  105431. private _startDistance;
  105432. private _initialScale;
  105433. private _targetScale;
  105434. private _ownerNode;
  105435. private _sceneRenderObserver;
  105436. /**
  105437. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105438. */
  105439. constructor();
  105440. /**
  105441. * The name of the behavior
  105442. */
  105443. readonly name: string;
  105444. /**
  105445. * Initializes the behavior
  105446. */
  105447. init(): void;
  105448. private _getCurrentDistance;
  105449. /**
  105450. * Attaches the scale behavior the passed in mesh
  105451. * @param ownerNode The mesh that will be scaled around once attached
  105452. */
  105453. attach(ownerNode: Mesh): void;
  105454. /**
  105455. * Detaches the behavior from the mesh
  105456. */
  105457. detach(): void;
  105458. }
  105459. }
  105460. declare module BABYLON {
  105461. /**
  105462. * 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
  105463. */
  105464. export class SixDofDragBehavior implements Behavior<Mesh> {
  105465. private static _virtualScene;
  105466. private _ownerNode;
  105467. private _sceneRenderObserver;
  105468. private _scene;
  105469. private _targetPosition;
  105470. private _virtualOriginMesh;
  105471. private _virtualDragMesh;
  105472. private _pointerObserver;
  105473. private _moving;
  105474. private _startingOrientation;
  105475. /**
  105476. * 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)
  105477. */
  105478. private zDragFactor;
  105479. /**
  105480. * If the object should rotate to face the drag origin
  105481. */
  105482. rotateDraggedObject: boolean;
  105483. /**
  105484. * If the behavior is currently in a dragging state
  105485. */
  105486. dragging: boolean;
  105487. /**
  105488. * 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)
  105489. */
  105490. dragDeltaRatio: number;
  105491. /**
  105492. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105493. */
  105494. currentDraggingPointerID: number;
  105495. /**
  105496. * If camera controls should be detached during the drag
  105497. */
  105498. detachCameraControls: boolean;
  105499. /**
  105500. * Fires each time a drag starts
  105501. */
  105502. onDragStartObservable: Observable<{}>;
  105503. /**
  105504. * Fires each time a drag ends (eg. mouse release after drag)
  105505. */
  105506. onDragEndObservable: Observable<{}>;
  105507. /**
  105508. * 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
  105509. */
  105510. constructor();
  105511. /**
  105512. * The name of the behavior
  105513. */
  105514. readonly name: string;
  105515. /**
  105516. * Initializes the behavior
  105517. */
  105518. init(): void;
  105519. /**
  105520. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105521. */
  105522. private readonly _pointerCamera;
  105523. /**
  105524. * Attaches the scale behavior the passed in mesh
  105525. * @param ownerNode The mesh that will be scaled around once attached
  105526. */
  105527. attach(ownerNode: Mesh): void;
  105528. /**
  105529. * Detaches the behavior from the mesh
  105530. */
  105531. detach(): void;
  105532. }
  105533. }
  105534. declare module BABYLON {
  105535. /**
  105536. * Class used to apply inverse kinematics to bones
  105537. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105538. */
  105539. export class BoneIKController {
  105540. private static _tmpVecs;
  105541. private static _tmpQuat;
  105542. private static _tmpMats;
  105543. /**
  105544. * Gets or sets the target mesh
  105545. */
  105546. targetMesh: AbstractMesh;
  105547. /** Gets or sets the mesh used as pole */
  105548. poleTargetMesh: AbstractMesh;
  105549. /**
  105550. * Gets or sets the bone used as pole
  105551. */
  105552. poleTargetBone: Nullable<Bone>;
  105553. /**
  105554. * Gets or sets the target position
  105555. */
  105556. targetPosition: Vector3;
  105557. /**
  105558. * Gets or sets the pole target position
  105559. */
  105560. poleTargetPosition: Vector3;
  105561. /**
  105562. * Gets or sets the pole target local offset
  105563. */
  105564. poleTargetLocalOffset: Vector3;
  105565. /**
  105566. * Gets or sets the pole angle
  105567. */
  105568. poleAngle: number;
  105569. /**
  105570. * Gets or sets the mesh associated with the controller
  105571. */
  105572. mesh: AbstractMesh;
  105573. /**
  105574. * 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)
  105575. */
  105576. slerpAmount: number;
  105577. private _bone1Quat;
  105578. private _bone1Mat;
  105579. private _bone2Ang;
  105580. private _bone1;
  105581. private _bone2;
  105582. private _bone1Length;
  105583. private _bone2Length;
  105584. private _maxAngle;
  105585. private _maxReach;
  105586. private _rightHandedSystem;
  105587. private _bendAxis;
  105588. private _slerping;
  105589. private _adjustRoll;
  105590. /**
  105591. * Gets or sets maximum allowed angle
  105592. */
  105593. maxAngle: number;
  105594. /**
  105595. * Creates a new BoneIKController
  105596. * @param mesh defines the mesh to control
  105597. * @param bone defines the bone to control
  105598. * @param options defines options to set up the controller
  105599. */
  105600. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105601. targetMesh?: AbstractMesh;
  105602. poleTargetMesh?: AbstractMesh;
  105603. poleTargetBone?: Bone;
  105604. poleTargetLocalOffset?: Vector3;
  105605. poleAngle?: number;
  105606. bendAxis?: Vector3;
  105607. maxAngle?: number;
  105608. slerpAmount?: number;
  105609. });
  105610. private _setMaxAngle;
  105611. /**
  105612. * Force the controller to update the bones
  105613. */
  105614. update(): void;
  105615. }
  105616. }
  105617. declare module BABYLON {
  105618. /**
  105619. * Class used to make a bone look toward a point in space
  105620. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105621. */
  105622. export class BoneLookController {
  105623. private static _tmpVecs;
  105624. private static _tmpQuat;
  105625. private static _tmpMats;
  105626. /**
  105627. * The target Vector3 that the bone will look at
  105628. */
  105629. target: Vector3;
  105630. /**
  105631. * The mesh that the bone is attached to
  105632. */
  105633. mesh: AbstractMesh;
  105634. /**
  105635. * The bone that will be looking to the target
  105636. */
  105637. bone: Bone;
  105638. /**
  105639. * The up axis of the coordinate system that is used when the bone is rotated
  105640. */
  105641. upAxis: Vector3;
  105642. /**
  105643. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105644. */
  105645. upAxisSpace: Space;
  105646. /**
  105647. * Used to make an adjustment to the yaw of the bone
  105648. */
  105649. adjustYaw: number;
  105650. /**
  105651. * Used to make an adjustment to the pitch of the bone
  105652. */
  105653. adjustPitch: number;
  105654. /**
  105655. * Used to make an adjustment to the roll of the bone
  105656. */
  105657. adjustRoll: number;
  105658. /**
  105659. * 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)
  105660. */
  105661. slerpAmount: number;
  105662. private _minYaw;
  105663. private _maxYaw;
  105664. private _minPitch;
  105665. private _maxPitch;
  105666. private _minYawSin;
  105667. private _minYawCos;
  105668. private _maxYawSin;
  105669. private _maxYawCos;
  105670. private _midYawConstraint;
  105671. private _minPitchTan;
  105672. private _maxPitchTan;
  105673. private _boneQuat;
  105674. private _slerping;
  105675. private _transformYawPitch;
  105676. private _transformYawPitchInv;
  105677. private _firstFrameSkipped;
  105678. private _yawRange;
  105679. private _fowardAxis;
  105680. /**
  105681. * Gets or sets the minimum yaw angle that the bone can look to
  105682. */
  105683. minYaw: number;
  105684. /**
  105685. * Gets or sets the maximum yaw angle that the bone can look to
  105686. */
  105687. maxYaw: number;
  105688. /**
  105689. * Gets or sets the minimum pitch angle that the bone can look to
  105690. */
  105691. minPitch: number;
  105692. /**
  105693. * Gets or sets the maximum pitch angle that the bone can look to
  105694. */
  105695. maxPitch: number;
  105696. /**
  105697. * Create a BoneLookController
  105698. * @param mesh the mesh that the bone belongs to
  105699. * @param bone the bone that will be looking to the target
  105700. * @param target the target Vector3 to look at
  105701. * @param options optional settings:
  105702. * * maxYaw: the maximum angle the bone will yaw to
  105703. * * minYaw: the minimum angle the bone will yaw to
  105704. * * maxPitch: the maximum angle the bone will pitch to
  105705. * * minPitch: the minimum angle the bone will yaw to
  105706. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105707. * * upAxis: the up axis of the coordinate system
  105708. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105709. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105710. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105711. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105712. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105713. * * adjustRoll: used to make an adjustment to the roll of the bone
  105714. **/
  105715. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105716. maxYaw?: number;
  105717. minYaw?: number;
  105718. maxPitch?: number;
  105719. minPitch?: number;
  105720. slerpAmount?: number;
  105721. upAxis?: Vector3;
  105722. upAxisSpace?: Space;
  105723. yawAxis?: Vector3;
  105724. pitchAxis?: Vector3;
  105725. adjustYaw?: number;
  105726. adjustPitch?: number;
  105727. adjustRoll?: number;
  105728. });
  105729. /**
  105730. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105731. */
  105732. update(): void;
  105733. private _getAngleDiff;
  105734. private _getAngleBetween;
  105735. private _isAngleBetween;
  105736. }
  105737. }
  105738. declare module BABYLON {
  105739. /**
  105740. * Manage the gamepad inputs to control an arc rotate camera.
  105741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105742. */
  105743. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105744. /**
  105745. * Defines the camera the input is attached to.
  105746. */
  105747. camera: ArcRotateCamera;
  105748. /**
  105749. * Defines the gamepad the input is gathering event from.
  105750. */
  105751. gamepad: Nullable<Gamepad>;
  105752. /**
  105753. * Defines the gamepad rotation sensiblity.
  105754. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105755. */
  105756. gamepadRotationSensibility: number;
  105757. /**
  105758. * Defines the gamepad move sensiblity.
  105759. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105760. */
  105761. gamepadMoveSensibility: number;
  105762. private _yAxisScale;
  105763. /**
  105764. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105765. */
  105766. invertYAxis: boolean;
  105767. private _onGamepadConnectedObserver;
  105768. private _onGamepadDisconnectedObserver;
  105769. /**
  105770. * Attach the input controls to a specific dom element to get the input from.
  105771. * @param element Defines the element the controls should be listened from
  105772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105773. */
  105774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105775. /**
  105776. * Detach the current controls from the specified dom element.
  105777. * @param element Defines the element to stop listening the inputs from
  105778. */
  105779. detachControl(element: Nullable<HTMLElement>): void;
  105780. /**
  105781. * Update the current camera state depending on the inputs that have been used this frame.
  105782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105783. */
  105784. checkInputs(): void;
  105785. /**
  105786. * Gets the class name of the current intput.
  105787. * @returns the class name
  105788. */
  105789. getClassName(): string;
  105790. /**
  105791. * Get the friendly name associated with the input class.
  105792. * @returns the input friendly name
  105793. */
  105794. getSimpleName(): string;
  105795. }
  105796. }
  105797. declare module BABYLON {
  105798. interface ArcRotateCameraInputsManager {
  105799. /**
  105800. * Add orientation input support to the input manager.
  105801. * @returns the current input manager
  105802. */
  105803. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105804. }
  105805. /**
  105806. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105808. */
  105809. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105810. /**
  105811. * Defines the camera the input is attached to.
  105812. */
  105813. camera: ArcRotateCamera;
  105814. /**
  105815. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105816. */
  105817. alphaCorrection: number;
  105818. /**
  105819. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105820. */
  105821. gammaCorrection: number;
  105822. private _alpha;
  105823. private _gamma;
  105824. private _dirty;
  105825. private _deviceOrientationHandler;
  105826. /**
  105827. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105828. */
  105829. constructor();
  105830. /**
  105831. * Attach the input controls to a specific dom element to get the input from.
  105832. * @param element Defines the element the controls should be listened from
  105833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105834. */
  105835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105836. /** @hidden */
  105837. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105838. /**
  105839. * Update the current camera state depending on the inputs that have been used this frame.
  105840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105841. */
  105842. checkInputs(): void;
  105843. /**
  105844. * Detach the current controls from the specified dom element.
  105845. * @param element Defines the element to stop listening the inputs from
  105846. */
  105847. detachControl(element: Nullable<HTMLElement>): void;
  105848. /**
  105849. * Gets the class name of the current intput.
  105850. * @returns the class name
  105851. */
  105852. getClassName(): string;
  105853. /**
  105854. * Get the friendly name associated with the input class.
  105855. * @returns the input friendly name
  105856. */
  105857. getSimpleName(): string;
  105858. }
  105859. }
  105860. declare module BABYLON {
  105861. /**
  105862. * Listen to mouse events to control the camera.
  105863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105864. */
  105865. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105866. /**
  105867. * Defines the camera the input is attached to.
  105868. */
  105869. camera: FlyCamera;
  105870. /**
  105871. * Defines if touch is enabled. (Default is true.)
  105872. */
  105873. touchEnabled: boolean;
  105874. /**
  105875. * Defines the buttons associated with the input to handle camera rotation.
  105876. */
  105877. buttons: number[];
  105878. /**
  105879. * Assign buttons for Yaw control.
  105880. */
  105881. buttonsYaw: number[];
  105882. /**
  105883. * Assign buttons for Pitch control.
  105884. */
  105885. buttonsPitch: number[];
  105886. /**
  105887. * Assign buttons for Roll control.
  105888. */
  105889. buttonsRoll: number[];
  105890. /**
  105891. * Detect if any button is being pressed while mouse is moved.
  105892. * -1 = Mouse locked.
  105893. * 0 = Left button.
  105894. * 1 = Middle Button.
  105895. * 2 = Right Button.
  105896. */
  105897. activeButton: number;
  105898. /**
  105899. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105900. * Higher values reduce its sensitivity.
  105901. */
  105902. angularSensibility: number;
  105903. private _mousemoveCallback;
  105904. private _observer;
  105905. private _rollObserver;
  105906. private previousPosition;
  105907. private noPreventDefault;
  105908. private element;
  105909. /**
  105910. * Listen to mouse events to control the camera.
  105911. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105913. */
  105914. constructor(touchEnabled?: boolean);
  105915. /**
  105916. * Attach the mouse control to the HTML DOM element.
  105917. * @param element Defines the element that listens to the input events.
  105918. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105919. */
  105920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105921. /**
  105922. * Detach the current controls from the specified dom element.
  105923. * @param element Defines the element to stop listening the inputs from
  105924. */
  105925. detachControl(element: Nullable<HTMLElement>): void;
  105926. /**
  105927. * Gets the class name of the current input.
  105928. * @returns the class name.
  105929. */
  105930. getClassName(): string;
  105931. /**
  105932. * Get the friendly name associated with the input class.
  105933. * @returns the input's friendly name.
  105934. */
  105935. getSimpleName(): string;
  105936. private _pointerInput;
  105937. private _onMouseMove;
  105938. /**
  105939. * Rotate camera by mouse offset.
  105940. */
  105941. private rotateCamera;
  105942. }
  105943. }
  105944. declare module BABYLON {
  105945. /**
  105946. * Default Inputs manager for the FlyCamera.
  105947. * It groups all the default supported inputs for ease of use.
  105948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105949. */
  105950. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105951. /**
  105952. * Instantiates a new FlyCameraInputsManager.
  105953. * @param camera Defines the camera the inputs belong to.
  105954. */
  105955. constructor(camera: FlyCamera);
  105956. /**
  105957. * Add keyboard input support to the input manager.
  105958. * @returns the new FlyCameraKeyboardMoveInput().
  105959. */
  105960. addKeyboard(): FlyCameraInputsManager;
  105961. /**
  105962. * Add mouse input support to the input manager.
  105963. * @param touchEnabled Enable touch screen support.
  105964. * @returns the new FlyCameraMouseInput().
  105965. */
  105966. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105967. }
  105968. }
  105969. declare module BABYLON {
  105970. /**
  105971. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105972. * such as in a 3D Space Shooter or a Flight Simulator.
  105973. */
  105974. export class FlyCamera extends TargetCamera {
  105975. /**
  105976. * Define the collision ellipsoid of the camera.
  105977. * This is helpful for simulating a camera body, like a player's body.
  105978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105979. */
  105980. ellipsoid: Vector3;
  105981. /**
  105982. * Define an offset for the position of the ellipsoid around the camera.
  105983. * This can be helpful if the camera is attached away from the player's body center,
  105984. * such as at its head.
  105985. */
  105986. ellipsoidOffset: Vector3;
  105987. /**
  105988. * Enable or disable collisions of the camera with the rest of the scene objects.
  105989. */
  105990. checkCollisions: boolean;
  105991. /**
  105992. * Enable or disable gravity on the camera.
  105993. */
  105994. applyGravity: boolean;
  105995. /**
  105996. * Define the current direction the camera is moving to.
  105997. */
  105998. cameraDirection: Vector3;
  105999. /**
  106000. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106001. * This overrides and empties cameraRotation.
  106002. */
  106003. rotationQuaternion: Quaternion;
  106004. /**
  106005. * Track Roll to maintain the wanted Rolling when looking around.
  106006. */
  106007. _trackRoll: number;
  106008. /**
  106009. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106010. */
  106011. rollCorrect: number;
  106012. /**
  106013. * Mimic a banked turn, Rolling the camera when Yawing.
  106014. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106015. */
  106016. bankedTurn: boolean;
  106017. /**
  106018. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106019. */
  106020. bankedTurnLimit: number;
  106021. /**
  106022. * Value of 0 disables the banked Roll.
  106023. * Value of 1 is equal to the Yaw angle in radians.
  106024. */
  106025. bankedTurnMultiplier: number;
  106026. /**
  106027. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106028. */
  106029. inputs: FlyCameraInputsManager;
  106030. /**
  106031. * Gets the input sensibility for mouse input.
  106032. * Higher values reduce sensitivity.
  106033. */
  106034. /**
  106035. * Sets the input sensibility for a mouse input.
  106036. * Higher values reduce sensitivity.
  106037. */
  106038. angularSensibility: number;
  106039. /**
  106040. * Get the keys for camera movement forward.
  106041. */
  106042. /**
  106043. * Set the keys for camera movement forward.
  106044. */
  106045. keysForward: number[];
  106046. /**
  106047. * Get the keys for camera movement backward.
  106048. */
  106049. keysBackward: number[];
  106050. /**
  106051. * Get the keys for camera movement up.
  106052. */
  106053. /**
  106054. * Set the keys for camera movement up.
  106055. */
  106056. keysUp: number[];
  106057. /**
  106058. * Get the keys for camera movement down.
  106059. */
  106060. /**
  106061. * Set the keys for camera movement down.
  106062. */
  106063. keysDown: number[];
  106064. /**
  106065. * Get the keys for camera movement left.
  106066. */
  106067. /**
  106068. * Set the keys for camera movement left.
  106069. */
  106070. keysLeft: number[];
  106071. /**
  106072. * Set the keys for camera movement right.
  106073. */
  106074. /**
  106075. * Set the keys for camera movement right.
  106076. */
  106077. keysRight: number[];
  106078. /**
  106079. * Event raised when the camera collides with a mesh in the scene.
  106080. */
  106081. onCollide: (collidedMesh: AbstractMesh) => void;
  106082. private _collider;
  106083. private _needMoveForGravity;
  106084. private _oldPosition;
  106085. private _diffPosition;
  106086. private _newPosition;
  106087. /** @hidden */
  106088. _localDirection: Vector3;
  106089. /** @hidden */
  106090. _transformedDirection: Vector3;
  106091. /**
  106092. * Instantiates a FlyCamera.
  106093. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106094. * such as in a 3D Space Shooter or a Flight Simulator.
  106095. * @param name Define the name of the camera in the scene.
  106096. * @param position Define the starting position of the camera in the scene.
  106097. * @param scene Define the scene the camera belongs to.
  106098. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106099. */
  106100. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106101. /**
  106102. * Attach a control to the HTML DOM element.
  106103. * @param element Defines the element that listens to the input events.
  106104. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106105. */
  106106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106107. /**
  106108. * Detach a control from the HTML DOM element.
  106109. * The camera will stop reacting to that input.
  106110. * @param element Defines the element that listens to the input events.
  106111. */
  106112. detachControl(element: HTMLElement): void;
  106113. private _collisionMask;
  106114. /**
  106115. * Get the mask that the camera ignores in collision events.
  106116. */
  106117. /**
  106118. * Set the mask that the camera ignores in collision events.
  106119. */
  106120. collisionMask: number;
  106121. /** @hidden */
  106122. _collideWithWorld(displacement: Vector3): void;
  106123. /** @hidden */
  106124. private _onCollisionPositionChange;
  106125. /** @hidden */
  106126. _checkInputs(): void;
  106127. /** @hidden */
  106128. _decideIfNeedsToMove(): boolean;
  106129. /** @hidden */
  106130. _updatePosition(): void;
  106131. /**
  106132. * Restore the Roll to its target value at the rate specified.
  106133. * @param rate - Higher means slower restoring.
  106134. * @hidden
  106135. */
  106136. restoreRoll(rate: number): void;
  106137. /**
  106138. * Destroy the camera and release the current resources held by it.
  106139. */
  106140. dispose(): void;
  106141. /**
  106142. * Get the current object class name.
  106143. * @returns the class name.
  106144. */
  106145. getClassName(): string;
  106146. }
  106147. }
  106148. declare module BABYLON {
  106149. /**
  106150. * Listen to keyboard events to control the camera.
  106151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106152. */
  106153. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106154. /**
  106155. * Defines the camera the input is attached to.
  106156. */
  106157. camera: FlyCamera;
  106158. /**
  106159. * The list of keyboard keys used to control the forward move of the camera.
  106160. */
  106161. keysForward: number[];
  106162. /**
  106163. * The list of keyboard keys used to control the backward move of the camera.
  106164. */
  106165. keysBackward: number[];
  106166. /**
  106167. * The list of keyboard keys used to control the forward move of the camera.
  106168. */
  106169. keysUp: number[];
  106170. /**
  106171. * The list of keyboard keys used to control the backward move of the camera.
  106172. */
  106173. keysDown: number[];
  106174. /**
  106175. * The list of keyboard keys used to control the right strafe move of the camera.
  106176. */
  106177. keysRight: number[];
  106178. /**
  106179. * The list of keyboard keys used to control the left strafe move of the camera.
  106180. */
  106181. keysLeft: number[];
  106182. private _keys;
  106183. private _onCanvasBlurObserver;
  106184. private _onKeyboardObserver;
  106185. private _engine;
  106186. private _scene;
  106187. /**
  106188. * Attach the input controls to a specific dom element to get the input from.
  106189. * @param element Defines the element the controls should be listened from
  106190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106191. */
  106192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106193. /**
  106194. * Detach the current controls from the specified dom element.
  106195. * @param element Defines the element to stop listening the inputs from
  106196. */
  106197. detachControl(element: Nullable<HTMLElement>): void;
  106198. /**
  106199. * Gets the class name of the current intput.
  106200. * @returns the class name
  106201. */
  106202. getClassName(): string;
  106203. /** @hidden */
  106204. _onLostFocus(e: FocusEvent): void;
  106205. /**
  106206. * Get the friendly name associated with the input class.
  106207. * @returns the input friendly name
  106208. */
  106209. getSimpleName(): string;
  106210. /**
  106211. * Update the current camera state depending on the inputs that have been used this frame.
  106212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106213. */
  106214. checkInputs(): void;
  106215. }
  106216. }
  106217. declare module BABYLON {
  106218. /**
  106219. * Manage the mouse wheel inputs to control a follow camera.
  106220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106221. */
  106222. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106223. /**
  106224. * Defines the camera the input is attached to.
  106225. */
  106226. camera: FollowCamera;
  106227. /**
  106228. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106229. */
  106230. axisControlRadius: boolean;
  106231. /**
  106232. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106233. */
  106234. axisControlHeight: boolean;
  106235. /**
  106236. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106237. */
  106238. axisControlRotation: boolean;
  106239. /**
  106240. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106241. * relation to mouseWheel events.
  106242. */
  106243. wheelPrecision: number;
  106244. /**
  106245. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106246. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106247. */
  106248. wheelDeltaPercentage: number;
  106249. private _wheel;
  106250. private _observer;
  106251. /**
  106252. * Attach the input controls to a specific dom element to get the input from.
  106253. * @param element Defines the element the controls should be listened from
  106254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106255. */
  106256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106257. /**
  106258. * Detach the current controls from the specified dom element.
  106259. * @param element Defines the element to stop listening the inputs from
  106260. */
  106261. detachControl(element: Nullable<HTMLElement>): void;
  106262. /**
  106263. * Gets the class name of the current intput.
  106264. * @returns the class name
  106265. */
  106266. getClassName(): string;
  106267. /**
  106268. * Get the friendly name associated with the input class.
  106269. * @returns the input friendly name
  106270. */
  106271. getSimpleName(): string;
  106272. }
  106273. }
  106274. declare module BABYLON {
  106275. /**
  106276. * Manage the pointers inputs to control an follow camera.
  106277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106278. */
  106279. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106280. /**
  106281. * Defines the camera the input is attached to.
  106282. */
  106283. camera: FollowCamera;
  106284. /**
  106285. * Gets the class name of the current input.
  106286. * @returns the class name
  106287. */
  106288. getClassName(): string;
  106289. /**
  106290. * Defines the pointer angular sensibility along the X axis or how fast is
  106291. * the camera rotating.
  106292. * A negative number will reverse the axis direction.
  106293. */
  106294. angularSensibilityX: number;
  106295. /**
  106296. * Defines the pointer angular sensibility along the Y axis or how fast is
  106297. * the camera rotating.
  106298. * A negative number will reverse the axis direction.
  106299. */
  106300. angularSensibilityY: number;
  106301. /**
  106302. * Defines the pointer pinch precision or how fast is the camera zooming.
  106303. * A negative number will reverse the axis direction.
  106304. */
  106305. pinchPrecision: number;
  106306. /**
  106307. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106308. * from 0.
  106309. * It defines the percentage of current camera.radius to use as delta when
  106310. * pinch zoom is used.
  106311. */
  106312. pinchDeltaPercentage: number;
  106313. /**
  106314. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106315. */
  106316. axisXControlRadius: boolean;
  106317. /**
  106318. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106319. */
  106320. axisXControlHeight: boolean;
  106321. /**
  106322. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106323. */
  106324. axisXControlRotation: boolean;
  106325. /**
  106326. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106327. */
  106328. axisYControlRadius: boolean;
  106329. /**
  106330. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106331. */
  106332. axisYControlHeight: boolean;
  106333. /**
  106334. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106335. */
  106336. axisYControlRotation: boolean;
  106337. /**
  106338. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106339. */
  106340. axisPinchControlRadius: boolean;
  106341. /**
  106342. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106343. */
  106344. axisPinchControlHeight: boolean;
  106345. /**
  106346. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106347. */
  106348. axisPinchControlRotation: boolean;
  106349. /**
  106350. * Log error messages if basic misconfiguration has occurred.
  106351. */
  106352. warningEnable: boolean;
  106353. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106354. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106355. private _warningCounter;
  106356. private _warning;
  106357. }
  106358. }
  106359. declare module BABYLON {
  106360. /**
  106361. * Default Inputs manager for the FollowCamera.
  106362. * It groups all the default supported inputs for ease of use.
  106363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106364. */
  106365. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106366. /**
  106367. * Instantiates a new FollowCameraInputsManager.
  106368. * @param camera Defines the camera the inputs belong to
  106369. */
  106370. constructor(camera: FollowCamera);
  106371. /**
  106372. * Add keyboard input support to the input manager.
  106373. * @returns the current input manager
  106374. */
  106375. addKeyboard(): FollowCameraInputsManager;
  106376. /**
  106377. * Add mouse wheel input support to the input manager.
  106378. * @returns the current input manager
  106379. */
  106380. addMouseWheel(): FollowCameraInputsManager;
  106381. /**
  106382. * Add pointers input support to the input manager.
  106383. * @returns the current input manager
  106384. */
  106385. addPointers(): FollowCameraInputsManager;
  106386. /**
  106387. * Add orientation input support to the input manager.
  106388. * @returns the current input manager
  106389. */
  106390. addVRDeviceOrientation(): FollowCameraInputsManager;
  106391. }
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106396. * an arc rotate version arcFollowCamera are available.
  106397. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106398. */
  106399. export class FollowCamera extends TargetCamera {
  106400. /**
  106401. * Distance the follow camera should follow an object at
  106402. */
  106403. radius: number;
  106404. /**
  106405. * Minimum allowed distance of the camera to the axis of rotation
  106406. * (The camera can not get closer).
  106407. * This can help limiting how the Camera is able to move in the scene.
  106408. */
  106409. lowerRadiusLimit: Nullable<number>;
  106410. /**
  106411. * Maximum allowed distance of the camera to the axis of rotation
  106412. * (The camera can not get further).
  106413. * This can help limiting how the Camera is able to move in the scene.
  106414. */
  106415. upperRadiusLimit: Nullable<number>;
  106416. /**
  106417. * Define a rotation offset between the camera and the object it follows
  106418. */
  106419. rotationOffset: number;
  106420. /**
  106421. * Minimum allowed angle to camera position relative to target object.
  106422. * This can help limiting how the Camera is able to move in the scene.
  106423. */
  106424. lowerRotationOffsetLimit: Nullable<number>;
  106425. /**
  106426. * Maximum allowed angle to camera position relative to target object.
  106427. * This can help limiting how the Camera is able to move in the scene.
  106428. */
  106429. upperRotationOffsetLimit: Nullable<number>;
  106430. /**
  106431. * Define a height offset between the camera and the object it follows.
  106432. * It can help following an object from the top (like a car chaing a plane)
  106433. */
  106434. heightOffset: number;
  106435. /**
  106436. * Minimum allowed height of camera position relative to target object.
  106437. * This can help limiting how the Camera is able to move in the scene.
  106438. */
  106439. lowerHeightOffsetLimit: Nullable<number>;
  106440. /**
  106441. * Maximum allowed height of camera position relative to target object.
  106442. * This can help limiting how the Camera is able to move in the scene.
  106443. */
  106444. upperHeightOffsetLimit: Nullable<number>;
  106445. /**
  106446. * Define how fast the camera can accelerate to follow it s target.
  106447. */
  106448. cameraAcceleration: number;
  106449. /**
  106450. * Define the speed limit of the camera following an object.
  106451. */
  106452. maxCameraSpeed: number;
  106453. /**
  106454. * Define the target of the camera.
  106455. */
  106456. lockedTarget: Nullable<AbstractMesh>;
  106457. /**
  106458. * Defines the input associated with the camera.
  106459. */
  106460. inputs: FollowCameraInputsManager;
  106461. /**
  106462. * Instantiates the follow camera.
  106463. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106464. * @param name Define the name of the camera in the scene
  106465. * @param position Define the position of the camera
  106466. * @param scene Define the scene the camera belong to
  106467. * @param lockedTarget Define the target of the camera
  106468. */
  106469. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106470. private _follow;
  106471. /**
  106472. * Attached controls to the current camera.
  106473. * @param element Defines the element the controls should be listened from
  106474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106475. */
  106476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106477. /**
  106478. * Detach the current controls from the camera.
  106479. * The camera will stop reacting to inputs.
  106480. * @param element Defines the element to stop listening the inputs from
  106481. */
  106482. detachControl(element: HTMLElement): void;
  106483. /** @hidden */
  106484. _checkInputs(): void;
  106485. private _checkLimits;
  106486. /**
  106487. * Gets the camera class name.
  106488. * @returns the class name
  106489. */
  106490. getClassName(): string;
  106491. }
  106492. /**
  106493. * Arc Rotate version of the follow camera.
  106494. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106495. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106496. */
  106497. export class ArcFollowCamera extends TargetCamera {
  106498. /** The longitudinal angle of the camera */
  106499. alpha: number;
  106500. /** The latitudinal angle of the camera */
  106501. beta: number;
  106502. /** The radius of the camera from its target */
  106503. radius: number;
  106504. /** Define the camera target (the messh it should follow) */
  106505. target: Nullable<AbstractMesh>;
  106506. private _cartesianCoordinates;
  106507. /**
  106508. * Instantiates a new ArcFollowCamera
  106509. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106510. * @param name Define the name of the camera
  106511. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106512. * @param beta Define the rotation angle of the camera around the elevation axis
  106513. * @param radius Define the radius of the camera from its target point
  106514. * @param target Define the target of the camera
  106515. * @param scene Define the scene the camera belongs to
  106516. */
  106517. constructor(name: string,
  106518. /** The longitudinal angle of the camera */
  106519. alpha: number,
  106520. /** The latitudinal angle of the camera */
  106521. beta: number,
  106522. /** The radius of the camera from its target */
  106523. radius: number,
  106524. /** Define the camera target (the messh it should follow) */
  106525. target: Nullable<AbstractMesh>, scene: Scene);
  106526. private _follow;
  106527. /** @hidden */
  106528. _checkInputs(): void;
  106529. /**
  106530. * Returns the class name of the object.
  106531. * It is mostly used internally for serialization purposes.
  106532. */
  106533. getClassName(): string;
  106534. }
  106535. }
  106536. declare module BABYLON {
  106537. /**
  106538. * Manage the keyboard inputs to control the movement of a follow camera.
  106539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106540. */
  106541. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106542. /**
  106543. * Defines the camera the input is attached to.
  106544. */
  106545. camera: FollowCamera;
  106546. /**
  106547. * Defines the list of key codes associated with the up action (increase heightOffset)
  106548. */
  106549. keysHeightOffsetIncr: number[];
  106550. /**
  106551. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106552. */
  106553. keysHeightOffsetDecr: number[];
  106554. /**
  106555. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106556. */
  106557. keysHeightOffsetModifierAlt: boolean;
  106558. /**
  106559. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106560. */
  106561. keysHeightOffsetModifierCtrl: boolean;
  106562. /**
  106563. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106564. */
  106565. keysHeightOffsetModifierShift: boolean;
  106566. /**
  106567. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106568. */
  106569. keysRotationOffsetIncr: number[];
  106570. /**
  106571. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106572. */
  106573. keysRotationOffsetDecr: number[];
  106574. /**
  106575. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106576. */
  106577. keysRotationOffsetModifierAlt: boolean;
  106578. /**
  106579. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106580. */
  106581. keysRotationOffsetModifierCtrl: boolean;
  106582. /**
  106583. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106584. */
  106585. keysRotationOffsetModifierShift: boolean;
  106586. /**
  106587. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106588. */
  106589. keysRadiusIncr: number[];
  106590. /**
  106591. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106592. */
  106593. keysRadiusDecr: number[];
  106594. /**
  106595. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106596. */
  106597. keysRadiusModifierAlt: boolean;
  106598. /**
  106599. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106600. */
  106601. keysRadiusModifierCtrl: boolean;
  106602. /**
  106603. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106604. */
  106605. keysRadiusModifierShift: boolean;
  106606. /**
  106607. * Defines the rate of change of heightOffset.
  106608. */
  106609. heightSensibility: number;
  106610. /**
  106611. * Defines the rate of change of rotationOffset.
  106612. */
  106613. rotationSensibility: number;
  106614. /**
  106615. * Defines the rate of change of radius.
  106616. */
  106617. radiusSensibility: number;
  106618. private _keys;
  106619. private _ctrlPressed;
  106620. private _altPressed;
  106621. private _shiftPressed;
  106622. private _onCanvasBlurObserver;
  106623. private _onKeyboardObserver;
  106624. private _engine;
  106625. private _scene;
  106626. /**
  106627. * Attach the input controls to a specific dom element to get the input from.
  106628. * @param element Defines the element the controls should be listened from
  106629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106630. */
  106631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106632. /**
  106633. * Detach the current controls from the specified dom element.
  106634. * @param element Defines the element to stop listening the inputs from
  106635. */
  106636. detachControl(element: Nullable<HTMLElement>): void;
  106637. /**
  106638. * Update the current camera state depending on the inputs that have been used this frame.
  106639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106640. */
  106641. checkInputs(): void;
  106642. /**
  106643. * Gets the class name of the current input.
  106644. * @returns the class name
  106645. */
  106646. getClassName(): string;
  106647. /**
  106648. * Get the friendly name associated with the input class.
  106649. * @returns the input friendly name
  106650. */
  106651. getSimpleName(): string;
  106652. /**
  106653. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106654. * allow modification of the heightOffset value.
  106655. */
  106656. private _modifierHeightOffset;
  106657. /**
  106658. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106659. * allow modification of the rotationOffset value.
  106660. */
  106661. private _modifierRotationOffset;
  106662. /**
  106663. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106664. * allow modification of the radius value.
  106665. */
  106666. private _modifierRadius;
  106667. }
  106668. }
  106669. declare module BABYLON {
  106670. interface FreeCameraInputsManager {
  106671. /**
  106672. * @hidden
  106673. */
  106674. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106675. /**
  106676. * Add orientation input support to the input manager.
  106677. * @returns the current input manager
  106678. */
  106679. addDeviceOrientation(): FreeCameraInputsManager;
  106680. }
  106681. /**
  106682. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106683. * Screen rotation is taken into account.
  106684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106685. */
  106686. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106687. private _camera;
  106688. private _screenOrientationAngle;
  106689. private _constantTranform;
  106690. private _screenQuaternion;
  106691. private _alpha;
  106692. private _beta;
  106693. private _gamma;
  106694. /**
  106695. * Can be used to detect if a device orientation sensor is availible on a device
  106696. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106697. * @returns a promise that will resolve on orientation change
  106698. */
  106699. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106700. /**
  106701. * @hidden
  106702. */
  106703. _onDeviceOrientationChangedObservable: Observable<void>;
  106704. /**
  106705. * Instantiates a new input
  106706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106707. */
  106708. constructor();
  106709. /**
  106710. * Define the camera controlled by the input.
  106711. */
  106712. camera: FreeCamera;
  106713. /**
  106714. * Attach the input controls to a specific dom element to get the input from.
  106715. * @param element Defines the element the controls should be listened from
  106716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106717. */
  106718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106719. private _orientationChanged;
  106720. private _deviceOrientation;
  106721. /**
  106722. * Detach the current controls from the specified dom element.
  106723. * @param element Defines the element to stop listening the inputs from
  106724. */
  106725. detachControl(element: Nullable<HTMLElement>): void;
  106726. /**
  106727. * Update the current camera state depending on the inputs that have been used this frame.
  106728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106729. */
  106730. checkInputs(): void;
  106731. /**
  106732. * Gets the class name of the current intput.
  106733. * @returns the class name
  106734. */
  106735. getClassName(): string;
  106736. /**
  106737. * Get the friendly name associated with the input class.
  106738. * @returns the input friendly name
  106739. */
  106740. getSimpleName(): string;
  106741. }
  106742. }
  106743. declare module BABYLON {
  106744. /**
  106745. * Manage the gamepad inputs to control a free camera.
  106746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106747. */
  106748. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106749. /**
  106750. * Define the camera the input is attached to.
  106751. */
  106752. camera: FreeCamera;
  106753. /**
  106754. * Define the Gamepad controlling the input
  106755. */
  106756. gamepad: Nullable<Gamepad>;
  106757. /**
  106758. * Defines the gamepad rotation sensiblity.
  106759. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106760. */
  106761. gamepadAngularSensibility: number;
  106762. /**
  106763. * Defines the gamepad move sensiblity.
  106764. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106765. */
  106766. gamepadMoveSensibility: number;
  106767. private _yAxisScale;
  106768. /**
  106769. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106770. */
  106771. invertYAxis: boolean;
  106772. private _onGamepadConnectedObserver;
  106773. private _onGamepadDisconnectedObserver;
  106774. private _cameraTransform;
  106775. private _deltaTransform;
  106776. private _vector3;
  106777. private _vector2;
  106778. /**
  106779. * Attach the input controls to a specific dom element to get the input from.
  106780. * @param element Defines the element the controls should be listened from
  106781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106782. */
  106783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106784. /**
  106785. * Detach the current controls from the specified dom element.
  106786. * @param element Defines the element to stop listening the inputs from
  106787. */
  106788. detachControl(element: Nullable<HTMLElement>): void;
  106789. /**
  106790. * Update the current camera state depending on the inputs that have been used this frame.
  106791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106792. */
  106793. checkInputs(): void;
  106794. /**
  106795. * Gets the class name of the current intput.
  106796. * @returns the class name
  106797. */
  106798. getClassName(): string;
  106799. /**
  106800. * Get the friendly name associated with the input class.
  106801. * @returns the input friendly name
  106802. */
  106803. getSimpleName(): string;
  106804. }
  106805. }
  106806. declare module BABYLON {
  106807. /**
  106808. * Defines the potential axis of a Joystick
  106809. */
  106810. export enum JoystickAxis {
  106811. /** X axis */
  106812. X = 0,
  106813. /** Y axis */
  106814. Y = 1,
  106815. /** Z axis */
  106816. Z = 2
  106817. }
  106818. /**
  106819. * Class used to define virtual joystick (used in touch mode)
  106820. */
  106821. export class VirtualJoystick {
  106822. /**
  106823. * Gets or sets a boolean indicating that left and right values must be inverted
  106824. */
  106825. reverseLeftRight: boolean;
  106826. /**
  106827. * Gets or sets a boolean indicating that up and down values must be inverted
  106828. */
  106829. reverseUpDown: boolean;
  106830. /**
  106831. * Gets the offset value for the position (ie. the change of the position value)
  106832. */
  106833. deltaPosition: Vector3;
  106834. /**
  106835. * Gets a boolean indicating if the virtual joystick was pressed
  106836. */
  106837. pressed: boolean;
  106838. /**
  106839. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106840. */
  106841. static Canvas: Nullable<HTMLCanvasElement>;
  106842. private static _globalJoystickIndex;
  106843. private static vjCanvasContext;
  106844. private static vjCanvasWidth;
  106845. private static vjCanvasHeight;
  106846. private static halfWidth;
  106847. private _action;
  106848. private _axisTargetedByLeftAndRight;
  106849. private _axisTargetedByUpAndDown;
  106850. private _joystickSensibility;
  106851. private _inversedSensibility;
  106852. private _joystickPointerID;
  106853. private _joystickColor;
  106854. private _joystickPointerPos;
  106855. private _joystickPreviousPointerPos;
  106856. private _joystickPointerStartPos;
  106857. private _deltaJoystickVector;
  106858. private _leftJoystick;
  106859. private _touches;
  106860. private _onPointerDownHandlerRef;
  106861. private _onPointerMoveHandlerRef;
  106862. private _onPointerUpHandlerRef;
  106863. private _onResize;
  106864. /**
  106865. * Creates a new virtual joystick
  106866. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106867. */
  106868. constructor(leftJoystick?: boolean);
  106869. /**
  106870. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106871. * @param newJoystickSensibility defines the new sensibility
  106872. */
  106873. setJoystickSensibility(newJoystickSensibility: number): void;
  106874. private _onPointerDown;
  106875. private _onPointerMove;
  106876. private _onPointerUp;
  106877. /**
  106878. * Change the color of the virtual joystick
  106879. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106880. */
  106881. setJoystickColor(newColor: string): void;
  106882. /**
  106883. * Defines a callback to call when the joystick is touched
  106884. * @param action defines the callback
  106885. */
  106886. setActionOnTouch(action: () => any): void;
  106887. /**
  106888. * Defines which axis you'd like to control for left & right
  106889. * @param axis defines the axis to use
  106890. */
  106891. setAxisForLeftRight(axis: JoystickAxis): void;
  106892. /**
  106893. * Defines which axis you'd like to control for up & down
  106894. * @param axis defines the axis to use
  106895. */
  106896. setAxisForUpDown(axis: JoystickAxis): void;
  106897. private _drawVirtualJoystick;
  106898. /**
  106899. * Release internal HTML canvas
  106900. */
  106901. releaseCanvas(): void;
  106902. }
  106903. }
  106904. declare module BABYLON {
  106905. interface FreeCameraInputsManager {
  106906. /**
  106907. * Add virtual joystick input support to the input manager.
  106908. * @returns the current input manager
  106909. */
  106910. addVirtualJoystick(): FreeCameraInputsManager;
  106911. }
  106912. /**
  106913. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106915. */
  106916. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106917. /**
  106918. * Defines the camera the input is attached to.
  106919. */
  106920. camera: FreeCamera;
  106921. private _leftjoystick;
  106922. private _rightjoystick;
  106923. /**
  106924. * Gets the left stick of the virtual joystick.
  106925. * @returns The virtual Joystick
  106926. */
  106927. getLeftJoystick(): VirtualJoystick;
  106928. /**
  106929. * Gets the right stick of the virtual joystick.
  106930. * @returns The virtual Joystick
  106931. */
  106932. getRightJoystick(): VirtualJoystick;
  106933. /**
  106934. * Update the current camera state depending on the inputs that have been used this frame.
  106935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106936. */
  106937. checkInputs(): void;
  106938. /**
  106939. * Attach the input controls to a specific dom element to get the input from.
  106940. * @param element Defines the element the controls should be listened from
  106941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106942. */
  106943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106944. /**
  106945. * Detach the current controls from the specified dom element.
  106946. * @param element Defines the element to stop listening the inputs from
  106947. */
  106948. detachControl(element: Nullable<HTMLElement>): void;
  106949. /**
  106950. * Gets the class name of the current intput.
  106951. * @returns the class name
  106952. */
  106953. getClassName(): string;
  106954. /**
  106955. * Get the friendly name associated with the input class.
  106956. * @returns the input friendly name
  106957. */
  106958. getSimpleName(): string;
  106959. }
  106960. }
  106961. declare module BABYLON {
  106962. /**
  106963. * This represents a FPS type of camera controlled by touch.
  106964. * This is like a universal camera minus the Gamepad controls.
  106965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106966. */
  106967. export class TouchCamera extends FreeCamera {
  106968. /**
  106969. * Defines the touch sensibility for rotation.
  106970. * The higher the faster.
  106971. */
  106972. touchAngularSensibility: number;
  106973. /**
  106974. * Defines the touch sensibility for move.
  106975. * The higher the faster.
  106976. */
  106977. touchMoveSensibility: number;
  106978. /**
  106979. * Instantiates a new touch camera.
  106980. * This represents a FPS type of camera controlled by touch.
  106981. * This is like a universal camera minus the Gamepad controls.
  106982. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106983. * @param name Define the name of the camera in the scene
  106984. * @param position Define the start position of the camera in the scene
  106985. * @param scene Define the scene the camera belongs to
  106986. */
  106987. constructor(name: string, position: Vector3, scene: Scene);
  106988. /**
  106989. * Gets the current object class name.
  106990. * @return the class name
  106991. */
  106992. getClassName(): string;
  106993. /** @hidden */
  106994. _setupInputs(): void;
  106995. }
  106996. }
  106997. declare module BABYLON {
  106998. /**
  106999. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107000. * being tilted forward or back and left or right.
  107001. */
  107002. export class DeviceOrientationCamera extends FreeCamera {
  107003. private _initialQuaternion;
  107004. private _quaternionCache;
  107005. private _tmpDragQuaternion;
  107006. private _disablePointerInputWhenUsingDeviceOrientation;
  107007. /**
  107008. * Creates a new device orientation camera
  107009. * @param name The name of the camera
  107010. * @param position The start position camera
  107011. * @param scene The scene the camera belongs to
  107012. */
  107013. constructor(name: string, position: Vector3, scene: Scene);
  107014. /**
  107015. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107016. */
  107017. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107018. private _dragFactor;
  107019. /**
  107020. * Enabled turning on the y axis when the orientation sensor is active
  107021. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107022. */
  107023. enableHorizontalDragging(dragFactor?: number): void;
  107024. /**
  107025. * Gets the current instance class name ("DeviceOrientationCamera").
  107026. * This helps avoiding instanceof at run time.
  107027. * @returns the class name
  107028. */
  107029. getClassName(): string;
  107030. /**
  107031. * @hidden
  107032. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107033. */
  107034. _checkInputs(): void;
  107035. /**
  107036. * Reset the camera to its default orientation on the specified axis only.
  107037. * @param axis The axis to reset
  107038. */
  107039. resetToCurrentRotation(axis?: Axis): void;
  107040. }
  107041. }
  107042. declare module BABYLON {
  107043. /**
  107044. * Defines supported buttons for XBox360 compatible gamepads
  107045. */
  107046. export enum Xbox360Button {
  107047. /** A */
  107048. A = 0,
  107049. /** B */
  107050. B = 1,
  107051. /** X */
  107052. X = 2,
  107053. /** Y */
  107054. Y = 3,
  107055. /** Start */
  107056. Start = 4,
  107057. /** Back */
  107058. Back = 5,
  107059. /** Left button */
  107060. LB = 6,
  107061. /** Right button */
  107062. RB = 7,
  107063. /** Left stick */
  107064. LeftStick = 8,
  107065. /** Right stick */
  107066. RightStick = 9
  107067. }
  107068. /** Defines values for XBox360 DPad */
  107069. export enum Xbox360Dpad {
  107070. /** Up */
  107071. Up = 0,
  107072. /** Down */
  107073. Down = 1,
  107074. /** Left */
  107075. Left = 2,
  107076. /** Right */
  107077. Right = 3
  107078. }
  107079. /**
  107080. * Defines a XBox360 gamepad
  107081. */
  107082. export class Xbox360Pad extends Gamepad {
  107083. private _leftTrigger;
  107084. private _rightTrigger;
  107085. private _onlefttriggerchanged;
  107086. private _onrighttriggerchanged;
  107087. private _onbuttondown;
  107088. private _onbuttonup;
  107089. private _ondpaddown;
  107090. private _ondpadup;
  107091. /** Observable raised when a button is pressed */
  107092. onButtonDownObservable: Observable<Xbox360Button>;
  107093. /** Observable raised when a button is released */
  107094. onButtonUpObservable: Observable<Xbox360Button>;
  107095. /** Observable raised when a pad is pressed */
  107096. onPadDownObservable: Observable<Xbox360Dpad>;
  107097. /** Observable raised when a pad is released */
  107098. onPadUpObservable: Observable<Xbox360Dpad>;
  107099. private _buttonA;
  107100. private _buttonB;
  107101. private _buttonX;
  107102. private _buttonY;
  107103. private _buttonBack;
  107104. private _buttonStart;
  107105. private _buttonLB;
  107106. private _buttonRB;
  107107. private _buttonLeftStick;
  107108. private _buttonRightStick;
  107109. private _dPadUp;
  107110. private _dPadDown;
  107111. private _dPadLeft;
  107112. private _dPadRight;
  107113. private _isXboxOnePad;
  107114. /**
  107115. * Creates a new XBox360 gamepad object
  107116. * @param id defines the id of this gamepad
  107117. * @param index defines its index
  107118. * @param gamepad defines the internal HTML gamepad object
  107119. * @param xboxOne defines if it is a XBox One gamepad
  107120. */
  107121. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107122. /**
  107123. * Defines the callback to call when left trigger is pressed
  107124. * @param callback defines the callback to use
  107125. */
  107126. onlefttriggerchanged(callback: (value: number) => void): void;
  107127. /**
  107128. * Defines the callback to call when right trigger is pressed
  107129. * @param callback defines the callback to use
  107130. */
  107131. onrighttriggerchanged(callback: (value: number) => void): void;
  107132. /**
  107133. * Gets the left trigger value
  107134. */
  107135. /**
  107136. * Sets the left trigger value
  107137. */
  107138. leftTrigger: number;
  107139. /**
  107140. * Gets the right trigger value
  107141. */
  107142. /**
  107143. * Sets the right trigger value
  107144. */
  107145. rightTrigger: number;
  107146. /**
  107147. * Defines the callback to call when a button is pressed
  107148. * @param callback defines the callback to use
  107149. */
  107150. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107151. /**
  107152. * Defines the callback to call when a button is released
  107153. * @param callback defines the callback to use
  107154. */
  107155. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107156. /**
  107157. * Defines the callback to call when a pad is pressed
  107158. * @param callback defines the callback to use
  107159. */
  107160. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107161. /**
  107162. * Defines the callback to call when a pad is released
  107163. * @param callback defines the callback to use
  107164. */
  107165. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107166. private _setButtonValue;
  107167. private _setDPadValue;
  107168. /**
  107169. * Gets the value of the `A` button
  107170. */
  107171. /**
  107172. * Sets the value of the `A` button
  107173. */
  107174. buttonA: number;
  107175. /**
  107176. * Gets the value of the `B` button
  107177. */
  107178. /**
  107179. * Sets the value of the `B` button
  107180. */
  107181. buttonB: number;
  107182. /**
  107183. * Gets the value of the `X` button
  107184. */
  107185. /**
  107186. * Sets the value of the `X` button
  107187. */
  107188. buttonX: number;
  107189. /**
  107190. * Gets the value of the `Y` button
  107191. */
  107192. /**
  107193. * Sets the value of the `Y` button
  107194. */
  107195. buttonY: number;
  107196. /**
  107197. * Gets the value of the `Start` button
  107198. */
  107199. /**
  107200. * Sets the value of the `Start` button
  107201. */
  107202. buttonStart: number;
  107203. /**
  107204. * Gets the value of the `Back` button
  107205. */
  107206. /**
  107207. * Sets the value of the `Back` button
  107208. */
  107209. buttonBack: number;
  107210. /**
  107211. * Gets the value of the `Left` button
  107212. */
  107213. /**
  107214. * Sets the value of the `Left` button
  107215. */
  107216. buttonLB: number;
  107217. /**
  107218. * Gets the value of the `Right` button
  107219. */
  107220. /**
  107221. * Sets the value of the `Right` button
  107222. */
  107223. buttonRB: number;
  107224. /**
  107225. * Gets the value of the Left joystick
  107226. */
  107227. /**
  107228. * Sets the value of the Left joystick
  107229. */
  107230. buttonLeftStick: number;
  107231. /**
  107232. * Gets the value of the Right joystick
  107233. */
  107234. /**
  107235. * Sets the value of the Right joystick
  107236. */
  107237. buttonRightStick: number;
  107238. /**
  107239. * Gets the value of D-pad up
  107240. */
  107241. /**
  107242. * Sets the value of D-pad up
  107243. */
  107244. dPadUp: number;
  107245. /**
  107246. * Gets the value of D-pad down
  107247. */
  107248. /**
  107249. * Sets the value of D-pad down
  107250. */
  107251. dPadDown: number;
  107252. /**
  107253. * Gets the value of D-pad left
  107254. */
  107255. /**
  107256. * Sets the value of D-pad left
  107257. */
  107258. dPadLeft: number;
  107259. /**
  107260. * Gets the value of D-pad right
  107261. */
  107262. /**
  107263. * Sets the value of D-pad right
  107264. */
  107265. dPadRight: number;
  107266. /**
  107267. * Force the gamepad to synchronize with device values
  107268. */
  107269. update(): void;
  107270. /**
  107271. * Disposes the gamepad
  107272. */
  107273. dispose(): void;
  107274. }
  107275. }
  107276. declare module BABYLON {
  107277. /**
  107278. * Defines supported buttons for DualShock compatible gamepads
  107279. */
  107280. export enum DualShockButton {
  107281. /** Cross */
  107282. Cross = 0,
  107283. /** Circle */
  107284. Circle = 1,
  107285. /** Square */
  107286. Square = 2,
  107287. /** Triangle */
  107288. Triangle = 3,
  107289. /** Options */
  107290. Options = 4,
  107291. /** Share */
  107292. Share = 5,
  107293. /** L1 */
  107294. L1 = 6,
  107295. /** R1 */
  107296. R1 = 7,
  107297. /** Left stick */
  107298. LeftStick = 8,
  107299. /** Right stick */
  107300. RightStick = 9
  107301. }
  107302. /** Defines values for DualShock DPad */
  107303. export enum DualShockDpad {
  107304. /** Up */
  107305. Up = 0,
  107306. /** Down */
  107307. Down = 1,
  107308. /** Left */
  107309. Left = 2,
  107310. /** Right */
  107311. Right = 3
  107312. }
  107313. /**
  107314. * Defines a DualShock gamepad
  107315. */
  107316. export class DualShockPad extends Gamepad {
  107317. private _leftTrigger;
  107318. private _rightTrigger;
  107319. private _onlefttriggerchanged;
  107320. private _onrighttriggerchanged;
  107321. private _onbuttondown;
  107322. private _onbuttonup;
  107323. private _ondpaddown;
  107324. private _ondpadup;
  107325. /** Observable raised when a button is pressed */
  107326. onButtonDownObservable: Observable<DualShockButton>;
  107327. /** Observable raised when a button is released */
  107328. onButtonUpObservable: Observable<DualShockButton>;
  107329. /** Observable raised when a pad is pressed */
  107330. onPadDownObservable: Observable<DualShockDpad>;
  107331. /** Observable raised when a pad is released */
  107332. onPadUpObservable: Observable<DualShockDpad>;
  107333. private _buttonCross;
  107334. private _buttonCircle;
  107335. private _buttonSquare;
  107336. private _buttonTriangle;
  107337. private _buttonShare;
  107338. private _buttonOptions;
  107339. private _buttonL1;
  107340. private _buttonR1;
  107341. private _buttonLeftStick;
  107342. private _buttonRightStick;
  107343. private _dPadUp;
  107344. private _dPadDown;
  107345. private _dPadLeft;
  107346. private _dPadRight;
  107347. /**
  107348. * Creates a new DualShock gamepad object
  107349. * @param id defines the id of this gamepad
  107350. * @param index defines its index
  107351. * @param gamepad defines the internal HTML gamepad object
  107352. */
  107353. constructor(id: string, index: number, gamepad: any);
  107354. /**
  107355. * Defines the callback to call when left trigger is pressed
  107356. * @param callback defines the callback to use
  107357. */
  107358. onlefttriggerchanged(callback: (value: number) => void): void;
  107359. /**
  107360. * Defines the callback to call when right trigger is pressed
  107361. * @param callback defines the callback to use
  107362. */
  107363. onrighttriggerchanged(callback: (value: number) => void): void;
  107364. /**
  107365. * Gets the left trigger value
  107366. */
  107367. /**
  107368. * Sets the left trigger value
  107369. */
  107370. leftTrigger: number;
  107371. /**
  107372. * Gets the right trigger value
  107373. */
  107374. /**
  107375. * Sets the right trigger value
  107376. */
  107377. rightTrigger: number;
  107378. /**
  107379. * Defines the callback to call when a button is pressed
  107380. * @param callback defines the callback to use
  107381. */
  107382. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107383. /**
  107384. * Defines the callback to call when a button is released
  107385. * @param callback defines the callback to use
  107386. */
  107387. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107388. /**
  107389. * Defines the callback to call when a pad is pressed
  107390. * @param callback defines the callback to use
  107391. */
  107392. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107393. /**
  107394. * Defines the callback to call when a pad is released
  107395. * @param callback defines the callback to use
  107396. */
  107397. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107398. private _setButtonValue;
  107399. private _setDPadValue;
  107400. /**
  107401. * Gets the value of the `Cross` button
  107402. */
  107403. /**
  107404. * Sets the value of the `Cross` button
  107405. */
  107406. buttonCross: number;
  107407. /**
  107408. * Gets the value of the `Circle` button
  107409. */
  107410. /**
  107411. * Sets the value of the `Circle` button
  107412. */
  107413. buttonCircle: number;
  107414. /**
  107415. * Gets the value of the `Square` button
  107416. */
  107417. /**
  107418. * Sets the value of the `Square` button
  107419. */
  107420. buttonSquare: number;
  107421. /**
  107422. * Gets the value of the `Triangle` button
  107423. */
  107424. /**
  107425. * Sets the value of the `Triangle` button
  107426. */
  107427. buttonTriangle: number;
  107428. /**
  107429. * Gets the value of the `Options` button
  107430. */
  107431. /**
  107432. * Sets the value of the `Options` button
  107433. */
  107434. buttonOptions: number;
  107435. /**
  107436. * Gets the value of the `Share` button
  107437. */
  107438. /**
  107439. * Sets the value of the `Share` button
  107440. */
  107441. buttonShare: number;
  107442. /**
  107443. * Gets the value of the `L1` button
  107444. */
  107445. /**
  107446. * Sets the value of the `L1` button
  107447. */
  107448. buttonL1: number;
  107449. /**
  107450. * Gets the value of the `R1` button
  107451. */
  107452. /**
  107453. * Sets the value of the `R1` button
  107454. */
  107455. buttonR1: number;
  107456. /**
  107457. * Gets the value of the Left joystick
  107458. */
  107459. /**
  107460. * Sets the value of the Left joystick
  107461. */
  107462. buttonLeftStick: number;
  107463. /**
  107464. * Gets the value of the Right joystick
  107465. */
  107466. /**
  107467. * Sets the value of the Right joystick
  107468. */
  107469. buttonRightStick: number;
  107470. /**
  107471. * Gets the value of D-pad up
  107472. */
  107473. /**
  107474. * Sets the value of D-pad up
  107475. */
  107476. dPadUp: number;
  107477. /**
  107478. * Gets the value of D-pad down
  107479. */
  107480. /**
  107481. * Sets the value of D-pad down
  107482. */
  107483. dPadDown: number;
  107484. /**
  107485. * Gets the value of D-pad left
  107486. */
  107487. /**
  107488. * Sets the value of D-pad left
  107489. */
  107490. dPadLeft: number;
  107491. /**
  107492. * Gets the value of D-pad right
  107493. */
  107494. /**
  107495. * Sets the value of D-pad right
  107496. */
  107497. dPadRight: number;
  107498. /**
  107499. * Force the gamepad to synchronize with device values
  107500. */
  107501. update(): void;
  107502. /**
  107503. * Disposes the gamepad
  107504. */
  107505. dispose(): void;
  107506. }
  107507. }
  107508. declare module BABYLON {
  107509. /**
  107510. * Manager for handling gamepads
  107511. */
  107512. export class GamepadManager {
  107513. private _scene?;
  107514. private _babylonGamepads;
  107515. private _oneGamepadConnected;
  107516. /** @hidden */
  107517. _isMonitoring: boolean;
  107518. private _gamepadEventSupported;
  107519. private _gamepadSupport;
  107520. /**
  107521. * observable to be triggered when the gamepad controller has been connected
  107522. */
  107523. onGamepadConnectedObservable: Observable<Gamepad>;
  107524. /**
  107525. * observable to be triggered when the gamepad controller has been disconnected
  107526. */
  107527. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107528. private _onGamepadConnectedEvent;
  107529. private _onGamepadDisconnectedEvent;
  107530. /**
  107531. * Initializes the gamepad manager
  107532. * @param _scene BabylonJS scene
  107533. */
  107534. constructor(_scene?: Scene | undefined);
  107535. /**
  107536. * The gamepads in the game pad manager
  107537. */
  107538. readonly gamepads: Gamepad[];
  107539. /**
  107540. * Get the gamepad controllers based on type
  107541. * @param type The type of gamepad controller
  107542. * @returns Nullable gamepad
  107543. */
  107544. getGamepadByType(type?: number): Nullable<Gamepad>;
  107545. /**
  107546. * Disposes the gamepad manager
  107547. */
  107548. dispose(): void;
  107549. private _addNewGamepad;
  107550. private _startMonitoringGamepads;
  107551. private _stopMonitoringGamepads;
  107552. /** @hidden */
  107553. _checkGamepadsStatus(): void;
  107554. private _updateGamepadObjects;
  107555. }
  107556. }
  107557. declare module BABYLON {
  107558. interface Scene {
  107559. /** @hidden */
  107560. _gamepadManager: Nullable<GamepadManager>;
  107561. /**
  107562. * Gets the gamepad manager associated with the scene
  107563. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107564. */
  107565. gamepadManager: GamepadManager;
  107566. }
  107567. /**
  107568. * Interface representing a free camera inputs manager
  107569. */
  107570. interface FreeCameraInputsManager {
  107571. /**
  107572. * Adds gamepad input support to the FreeCameraInputsManager.
  107573. * @returns the FreeCameraInputsManager
  107574. */
  107575. addGamepad(): FreeCameraInputsManager;
  107576. }
  107577. /**
  107578. * Interface representing an arc rotate camera inputs manager
  107579. */
  107580. interface ArcRotateCameraInputsManager {
  107581. /**
  107582. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107583. * @returns the camera inputs manager
  107584. */
  107585. addGamepad(): ArcRotateCameraInputsManager;
  107586. }
  107587. /**
  107588. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107589. */
  107590. export class GamepadSystemSceneComponent implements ISceneComponent {
  107591. /**
  107592. * The component name helpfull to identify the component in the list of scene components.
  107593. */
  107594. readonly name: string;
  107595. /**
  107596. * The scene the component belongs to.
  107597. */
  107598. scene: Scene;
  107599. /**
  107600. * Creates a new instance of the component for the given scene
  107601. * @param scene Defines the scene to register the component in
  107602. */
  107603. constructor(scene: Scene);
  107604. /**
  107605. * Registers the component in a given scene
  107606. */
  107607. register(): void;
  107608. /**
  107609. * Rebuilds the elements related to this component in case of
  107610. * context lost for instance.
  107611. */
  107612. rebuild(): void;
  107613. /**
  107614. * Disposes the component and the associated ressources
  107615. */
  107616. dispose(): void;
  107617. private _beforeCameraUpdate;
  107618. }
  107619. }
  107620. declare module BABYLON {
  107621. /**
  107622. * 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,
  107623. * which still works and will still be found in many Playgrounds.
  107624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107625. */
  107626. export class UniversalCamera extends TouchCamera {
  107627. /**
  107628. * Defines the gamepad rotation sensiblity.
  107629. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107630. */
  107631. gamepadAngularSensibility: number;
  107632. /**
  107633. * Defines the gamepad move sensiblity.
  107634. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107635. */
  107636. gamepadMoveSensibility: number;
  107637. /**
  107638. * 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,
  107639. * which still works and will still be found in many Playgrounds.
  107640. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107641. * @param name Define the name of the camera in the scene
  107642. * @param position Define the start position of the camera in the scene
  107643. * @param scene Define the scene the camera belongs to
  107644. */
  107645. constructor(name: string, position: Vector3, scene: Scene);
  107646. /**
  107647. * Gets the current object class name.
  107648. * @return the class name
  107649. */
  107650. getClassName(): string;
  107651. }
  107652. }
  107653. declare module BABYLON {
  107654. /**
  107655. * This represents a FPS type of camera. This is only here for back compat purpose.
  107656. * Please use the UniversalCamera instead as both are identical.
  107657. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107658. */
  107659. export class GamepadCamera extends UniversalCamera {
  107660. /**
  107661. * Instantiates a new Gamepad Camera
  107662. * This represents a FPS type of camera. This is only here for back compat purpose.
  107663. * Please use the UniversalCamera instead as both are identical.
  107664. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107665. * @param name Define the name of the camera in the scene
  107666. * @param position Define the start position of the camera in the scene
  107667. * @param scene Define the scene the camera belongs to
  107668. */
  107669. constructor(name: string, position: Vector3, scene: Scene);
  107670. /**
  107671. * Gets the current object class name.
  107672. * @return the class name
  107673. */
  107674. getClassName(): string;
  107675. }
  107676. }
  107677. declare module BABYLON {
  107678. /** @hidden */
  107679. export var passPixelShader: {
  107680. name: string;
  107681. shader: string;
  107682. };
  107683. }
  107684. declare module BABYLON {
  107685. /** @hidden */
  107686. export var passCubePixelShader: {
  107687. name: string;
  107688. shader: string;
  107689. };
  107690. }
  107691. declare module BABYLON {
  107692. /**
  107693. * PassPostProcess which produces an output the same as it's input
  107694. */
  107695. export class PassPostProcess extends PostProcess {
  107696. /**
  107697. * Creates the PassPostProcess
  107698. * @param name The name of the effect.
  107699. * @param options The required width/height ratio to downsize to before computing the render pass.
  107700. * @param camera The camera to apply the render pass to.
  107701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107702. * @param engine The engine which the post process will be applied. (default: current engine)
  107703. * @param reusable If the post process can be reused on the same frame. (default: false)
  107704. * @param textureType The type of texture to be used when performing the post processing.
  107705. * @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)
  107706. */
  107707. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107708. }
  107709. /**
  107710. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107711. */
  107712. export class PassCubePostProcess extends PostProcess {
  107713. private _face;
  107714. /**
  107715. * Gets or sets the cube face to display.
  107716. * * 0 is +X
  107717. * * 1 is -X
  107718. * * 2 is +Y
  107719. * * 3 is -Y
  107720. * * 4 is +Z
  107721. * * 5 is -Z
  107722. */
  107723. face: number;
  107724. /**
  107725. * Creates the PassCubePostProcess
  107726. * @param name The name of the effect.
  107727. * @param options The required width/height ratio to downsize to before computing the render pass.
  107728. * @param camera The camera to apply the render pass to.
  107729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107730. * @param engine The engine which the post process will be applied. (default: current engine)
  107731. * @param reusable If the post process can be reused on the same frame. (default: false)
  107732. * @param textureType The type of texture to be used when performing the post processing.
  107733. * @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)
  107734. */
  107735. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107736. }
  107737. }
  107738. declare module BABYLON {
  107739. /** @hidden */
  107740. export var anaglyphPixelShader: {
  107741. name: string;
  107742. shader: string;
  107743. };
  107744. }
  107745. declare module BABYLON {
  107746. /**
  107747. * Postprocess used to generate anaglyphic rendering
  107748. */
  107749. export class AnaglyphPostProcess extends PostProcess {
  107750. private _passedProcess;
  107751. /**
  107752. * Creates a new AnaglyphPostProcess
  107753. * @param name defines postprocess name
  107754. * @param options defines creation options or target ratio scale
  107755. * @param rigCameras defines cameras using this postprocess
  107756. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107757. * @param engine defines hosting engine
  107758. * @param reusable defines if the postprocess will be reused multiple times per frame
  107759. */
  107760. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107761. }
  107762. }
  107763. declare module BABYLON {
  107764. /**
  107765. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107766. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107767. */
  107768. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107769. /**
  107770. * Creates a new AnaglyphArcRotateCamera
  107771. * @param name defines camera name
  107772. * @param alpha defines alpha angle (in radians)
  107773. * @param beta defines beta angle (in radians)
  107774. * @param radius defines radius
  107775. * @param target defines camera target
  107776. * @param interaxialDistance defines distance between each color axis
  107777. * @param scene defines the hosting scene
  107778. */
  107779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107780. /**
  107781. * Gets camera class name
  107782. * @returns AnaglyphArcRotateCamera
  107783. */
  107784. getClassName(): string;
  107785. }
  107786. }
  107787. declare module BABYLON {
  107788. /**
  107789. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107790. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107791. */
  107792. export class AnaglyphFreeCamera extends FreeCamera {
  107793. /**
  107794. * Creates a new AnaglyphFreeCamera
  107795. * @param name defines camera name
  107796. * @param position defines initial position
  107797. * @param interaxialDistance defines distance between each color axis
  107798. * @param scene defines the hosting scene
  107799. */
  107800. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107801. /**
  107802. * Gets camera class name
  107803. * @returns AnaglyphFreeCamera
  107804. */
  107805. getClassName(): string;
  107806. }
  107807. }
  107808. declare module BABYLON {
  107809. /**
  107810. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107811. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107812. */
  107813. export class AnaglyphGamepadCamera extends GamepadCamera {
  107814. /**
  107815. * Creates a new AnaglyphGamepadCamera
  107816. * @param name defines camera name
  107817. * @param position defines initial position
  107818. * @param interaxialDistance defines distance between each color axis
  107819. * @param scene defines the hosting scene
  107820. */
  107821. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107822. /**
  107823. * Gets camera class name
  107824. * @returns AnaglyphGamepadCamera
  107825. */
  107826. getClassName(): string;
  107827. }
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107832. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107833. */
  107834. export class AnaglyphUniversalCamera extends UniversalCamera {
  107835. /**
  107836. * Creates a new AnaglyphUniversalCamera
  107837. * @param name defines camera name
  107838. * @param position defines initial position
  107839. * @param interaxialDistance defines distance between each color axis
  107840. * @param scene defines the hosting scene
  107841. */
  107842. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107843. /**
  107844. * Gets camera class name
  107845. * @returns AnaglyphUniversalCamera
  107846. */
  107847. getClassName(): string;
  107848. }
  107849. }
  107850. declare module BABYLON {
  107851. /** @hidden */
  107852. export var stereoscopicInterlacePixelShader: {
  107853. name: string;
  107854. shader: string;
  107855. };
  107856. }
  107857. declare module BABYLON {
  107858. /**
  107859. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107860. */
  107861. export class StereoscopicInterlacePostProcess extends PostProcess {
  107862. private _stepSize;
  107863. private _passedProcess;
  107864. /**
  107865. * Initializes a StereoscopicInterlacePostProcess
  107866. * @param name The name of the effect.
  107867. * @param rigCameras The rig cameras to be appled to the post process
  107868. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107870. * @param engine The engine which the post process will be applied. (default: current engine)
  107871. * @param reusable If the post process can be reused on the same frame. (default: false)
  107872. */
  107873. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107874. }
  107875. }
  107876. declare module BABYLON {
  107877. /**
  107878. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107879. * @see http://doc.babylonjs.com/features/cameras
  107880. */
  107881. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107882. /**
  107883. * Creates a new StereoscopicArcRotateCamera
  107884. * @param name defines camera name
  107885. * @param alpha defines alpha angle (in radians)
  107886. * @param beta defines beta angle (in radians)
  107887. * @param radius defines radius
  107888. * @param target defines camera target
  107889. * @param interaxialDistance defines distance between each color axis
  107890. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107891. * @param scene defines the hosting scene
  107892. */
  107893. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107894. /**
  107895. * Gets camera class name
  107896. * @returns StereoscopicArcRotateCamera
  107897. */
  107898. getClassName(): string;
  107899. }
  107900. }
  107901. declare module BABYLON {
  107902. /**
  107903. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107904. * @see http://doc.babylonjs.com/features/cameras
  107905. */
  107906. export class StereoscopicFreeCamera extends FreeCamera {
  107907. /**
  107908. * Creates a new StereoscopicFreeCamera
  107909. * @param name defines camera name
  107910. * @param position defines initial position
  107911. * @param interaxialDistance defines distance between each color axis
  107912. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107913. * @param scene defines the hosting scene
  107914. */
  107915. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107916. /**
  107917. * Gets camera class name
  107918. * @returns StereoscopicFreeCamera
  107919. */
  107920. getClassName(): string;
  107921. }
  107922. }
  107923. declare module BABYLON {
  107924. /**
  107925. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107926. * @see http://doc.babylonjs.com/features/cameras
  107927. */
  107928. export class StereoscopicGamepadCamera extends GamepadCamera {
  107929. /**
  107930. * Creates a new StereoscopicGamepadCamera
  107931. * @param name defines camera name
  107932. * @param position defines initial position
  107933. * @param interaxialDistance defines distance between each color axis
  107934. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107935. * @param scene defines the hosting scene
  107936. */
  107937. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107938. /**
  107939. * Gets camera class name
  107940. * @returns StereoscopicGamepadCamera
  107941. */
  107942. getClassName(): string;
  107943. }
  107944. }
  107945. declare module BABYLON {
  107946. /**
  107947. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107948. * @see http://doc.babylonjs.com/features/cameras
  107949. */
  107950. export class StereoscopicUniversalCamera extends UniversalCamera {
  107951. /**
  107952. * Creates a new StereoscopicUniversalCamera
  107953. * @param name defines camera name
  107954. * @param position defines initial position
  107955. * @param interaxialDistance defines distance between each color axis
  107956. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107957. * @param scene defines the hosting scene
  107958. */
  107959. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107960. /**
  107961. * Gets camera class name
  107962. * @returns StereoscopicUniversalCamera
  107963. */
  107964. getClassName(): string;
  107965. }
  107966. }
  107967. declare module BABYLON {
  107968. /**
  107969. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107970. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107971. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107972. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107973. */
  107974. export class VirtualJoysticksCamera extends FreeCamera {
  107975. /**
  107976. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107977. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107978. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107979. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107980. * @param name Define the name of the camera in the scene
  107981. * @param position Define the start position of the camera in the scene
  107982. * @param scene Define the scene the camera belongs to
  107983. */
  107984. constructor(name: string, position: Vector3, scene: Scene);
  107985. /**
  107986. * Gets the current object class name.
  107987. * @return the class name
  107988. */
  107989. getClassName(): string;
  107990. }
  107991. }
  107992. declare module BABYLON {
  107993. /**
  107994. * This represents all the required metrics to create a VR camera.
  107995. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107996. */
  107997. export class VRCameraMetrics {
  107998. /**
  107999. * Define the horizontal resolution off the screen.
  108000. */
  108001. hResolution: number;
  108002. /**
  108003. * Define the vertical resolution off the screen.
  108004. */
  108005. vResolution: number;
  108006. /**
  108007. * Define the horizontal screen size.
  108008. */
  108009. hScreenSize: number;
  108010. /**
  108011. * Define the vertical screen size.
  108012. */
  108013. vScreenSize: number;
  108014. /**
  108015. * Define the vertical screen center position.
  108016. */
  108017. vScreenCenter: number;
  108018. /**
  108019. * Define the distance of the eyes to the screen.
  108020. */
  108021. eyeToScreenDistance: number;
  108022. /**
  108023. * Define the distance between both lenses
  108024. */
  108025. lensSeparationDistance: number;
  108026. /**
  108027. * Define the distance between both viewer's eyes.
  108028. */
  108029. interpupillaryDistance: number;
  108030. /**
  108031. * Define the distortion factor of the VR postprocess.
  108032. * Please, touch with care.
  108033. */
  108034. distortionK: number[];
  108035. /**
  108036. * Define the chromatic aberration correction factors for the VR post process.
  108037. */
  108038. chromaAbCorrection: number[];
  108039. /**
  108040. * Define the scale factor of the post process.
  108041. * The smaller the better but the slower.
  108042. */
  108043. postProcessScaleFactor: number;
  108044. /**
  108045. * Define an offset for the lens center.
  108046. */
  108047. lensCenterOffset: number;
  108048. /**
  108049. * Define if the current vr camera should compensate the distortion of the lense or not.
  108050. */
  108051. compensateDistortion: boolean;
  108052. /**
  108053. * Defines if multiview should be enabled when rendering (Default: false)
  108054. */
  108055. multiviewEnabled: boolean;
  108056. /**
  108057. * Gets the rendering aspect ratio based on the provided resolutions.
  108058. */
  108059. readonly aspectRatio: number;
  108060. /**
  108061. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108062. */
  108063. readonly aspectRatioFov: number;
  108064. /**
  108065. * @hidden
  108066. */
  108067. readonly leftHMatrix: Matrix;
  108068. /**
  108069. * @hidden
  108070. */
  108071. readonly rightHMatrix: Matrix;
  108072. /**
  108073. * @hidden
  108074. */
  108075. readonly leftPreViewMatrix: Matrix;
  108076. /**
  108077. * @hidden
  108078. */
  108079. readonly rightPreViewMatrix: Matrix;
  108080. /**
  108081. * Get the default VRMetrics based on the most generic setup.
  108082. * @returns the default vr metrics
  108083. */
  108084. static GetDefault(): VRCameraMetrics;
  108085. }
  108086. }
  108087. declare module BABYLON {
  108088. /** @hidden */
  108089. export var vrDistortionCorrectionPixelShader: {
  108090. name: string;
  108091. shader: string;
  108092. };
  108093. }
  108094. declare module BABYLON {
  108095. /**
  108096. * VRDistortionCorrectionPostProcess used for mobile VR
  108097. */
  108098. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108099. private _isRightEye;
  108100. private _distortionFactors;
  108101. private _postProcessScaleFactor;
  108102. private _lensCenterOffset;
  108103. private _scaleIn;
  108104. private _scaleFactor;
  108105. private _lensCenter;
  108106. /**
  108107. * Initializes the VRDistortionCorrectionPostProcess
  108108. * @param name The name of the effect.
  108109. * @param camera The camera to apply the render pass to.
  108110. * @param isRightEye If this is for the right eye distortion
  108111. * @param vrMetrics All the required metrics for the VR camera
  108112. */
  108113. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108114. }
  108115. }
  108116. declare module BABYLON {
  108117. /**
  108118. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108119. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108120. */
  108121. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108122. /**
  108123. * Creates a new VRDeviceOrientationArcRotateCamera
  108124. * @param name defines camera name
  108125. * @param alpha defines the camera rotation along the logitudinal axis
  108126. * @param beta defines the camera rotation along the latitudinal axis
  108127. * @param radius defines the camera distance from its target
  108128. * @param target defines the camera target
  108129. * @param scene defines the scene the camera belongs to
  108130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108132. */
  108133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108134. /**
  108135. * Gets camera class name
  108136. * @returns VRDeviceOrientationArcRotateCamera
  108137. */
  108138. getClassName(): string;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. /**
  108143. * Camera used to simulate VR rendering (based on FreeCamera)
  108144. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108145. */
  108146. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108147. /**
  108148. * Creates a new VRDeviceOrientationFreeCamera
  108149. * @param name defines camera name
  108150. * @param position defines the start position of the camera
  108151. * @param scene defines the scene the camera belongs to
  108152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108154. */
  108155. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108156. /**
  108157. * Gets camera class name
  108158. * @returns VRDeviceOrientationFreeCamera
  108159. */
  108160. getClassName(): string;
  108161. }
  108162. }
  108163. declare module BABYLON {
  108164. /**
  108165. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108166. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108167. */
  108168. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108169. /**
  108170. * Creates a new VRDeviceOrientationGamepadCamera
  108171. * @param name defines camera name
  108172. * @param position defines the start position of the camera
  108173. * @param scene defines the scene the camera belongs to
  108174. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108175. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108176. */
  108177. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108178. /**
  108179. * Gets camera class name
  108180. * @returns VRDeviceOrientationGamepadCamera
  108181. */
  108182. getClassName(): string;
  108183. }
  108184. }
  108185. declare module BABYLON {
  108186. /**
  108187. * Base class of materials working in push mode in babylon JS
  108188. * @hidden
  108189. */
  108190. export class PushMaterial extends Material {
  108191. protected _activeEffect: Effect;
  108192. protected _normalMatrix: Matrix;
  108193. /**
  108194. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108195. * This means that the material can keep using a previous shader while a new one is being compiled.
  108196. * This is mostly used when shader parallel compilation is supported (true by default)
  108197. */
  108198. allowShaderHotSwapping: boolean;
  108199. constructor(name: string, scene: Scene);
  108200. getEffect(): Effect;
  108201. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108202. /**
  108203. * Binds the given world matrix to the active effect
  108204. *
  108205. * @param world the matrix to bind
  108206. */
  108207. bindOnlyWorldMatrix(world: Matrix): void;
  108208. /**
  108209. * Binds the given normal matrix to the active effect
  108210. *
  108211. * @param normalMatrix the matrix to bind
  108212. */
  108213. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108214. bind(world: Matrix, mesh?: Mesh): void;
  108215. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108216. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108217. }
  108218. }
  108219. declare module BABYLON {
  108220. /**
  108221. * This groups all the flags used to control the materials channel.
  108222. */
  108223. export class MaterialFlags {
  108224. private static _DiffuseTextureEnabled;
  108225. /**
  108226. * Are diffuse textures enabled in the application.
  108227. */
  108228. static DiffuseTextureEnabled: boolean;
  108229. private static _AmbientTextureEnabled;
  108230. /**
  108231. * Are ambient textures enabled in the application.
  108232. */
  108233. static AmbientTextureEnabled: boolean;
  108234. private static _OpacityTextureEnabled;
  108235. /**
  108236. * Are opacity textures enabled in the application.
  108237. */
  108238. static OpacityTextureEnabled: boolean;
  108239. private static _ReflectionTextureEnabled;
  108240. /**
  108241. * Are reflection textures enabled in the application.
  108242. */
  108243. static ReflectionTextureEnabled: boolean;
  108244. private static _EmissiveTextureEnabled;
  108245. /**
  108246. * Are emissive textures enabled in the application.
  108247. */
  108248. static EmissiveTextureEnabled: boolean;
  108249. private static _SpecularTextureEnabled;
  108250. /**
  108251. * Are specular textures enabled in the application.
  108252. */
  108253. static SpecularTextureEnabled: boolean;
  108254. private static _BumpTextureEnabled;
  108255. /**
  108256. * Are bump textures enabled in the application.
  108257. */
  108258. static BumpTextureEnabled: boolean;
  108259. private static _LightmapTextureEnabled;
  108260. /**
  108261. * Are lightmap textures enabled in the application.
  108262. */
  108263. static LightmapTextureEnabled: boolean;
  108264. private static _RefractionTextureEnabled;
  108265. /**
  108266. * Are refraction textures enabled in the application.
  108267. */
  108268. static RefractionTextureEnabled: boolean;
  108269. private static _ColorGradingTextureEnabled;
  108270. /**
  108271. * Are color grading textures enabled in the application.
  108272. */
  108273. static ColorGradingTextureEnabled: boolean;
  108274. private static _FresnelEnabled;
  108275. /**
  108276. * Are fresnels enabled in the application.
  108277. */
  108278. static FresnelEnabled: boolean;
  108279. private static _ClearCoatTextureEnabled;
  108280. /**
  108281. * Are clear coat textures enabled in the application.
  108282. */
  108283. static ClearCoatTextureEnabled: boolean;
  108284. private static _ClearCoatBumpTextureEnabled;
  108285. /**
  108286. * Are clear coat bump textures enabled in the application.
  108287. */
  108288. static ClearCoatBumpTextureEnabled: boolean;
  108289. private static _ClearCoatTintTextureEnabled;
  108290. /**
  108291. * Are clear coat tint textures enabled in the application.
  108292. */
  108293. static ClearCoatTintTextureEnabled: boolean;
  108294. private static _SheenTextureEnabled;
  108295. /**
  108296. * Are sheen textures enabled in the application.
  108297. */
  108298. static SheenTextureEnabled: boolean;
  108299. private static _AnisotropicTextureEnabled;
  108300. /**
  108301. * Are anisotropic textures enabled in the application.
  108302. */
  108303. static AnisotropicTextureEnabled: boolean;
  108304. private static _ThicknessTextureEnabled;
  108305. /**
  108306. * Are thickness textures enabled in the application.
  108307. */
  108308. static ThicknessTextureEnabled: boolean;
  108309. }
  108310. }
  108311. declare module BABYLON {
  108312. /** @hidden */
  108313. export var defaultFragmentDeclaration: {
  108314. name: string;
  108315. shader: string;
  108316. };
  108317. }
  108318. declare module BABYLON {
  108319. /** @hidden */
  108320. export var defaultUboDeclaration: {
  108321. name: string;
  108322. shader: string;
  108323. };
  108324. }
  108325. declare module BABYLON {
  108326. /** @hidden */
  108327. export var lightFragmentDeclaration: {
  108328. name: string;
  108329. shader: string;
  108330. };
  108331. }
  108332. declare module BABYLON {
  108333. /** @hidden */
  108334. export var lightUboDeclaration: {
  108335. name: string;
  108336. shader: string;
  108337. };
  108338. }
  108339. declare module BABYLON {
  108340. /** @hidden */
  108341. export var lightsFragmentFunctions: {
  108342. name: string;
  108343. shader: string;
  108344. };
  108345. }
  108346. declare module BABYLON {
  108347. /** @hidden */
  108348. export var shadowsFragmentFunctions: {
  108349. name: string;
  108350. shader: string;
  108351. };
  108352. }
  108353. declare module BABYLON {
  108354. /** @hidden */
  108355. export var fresnelFunction: {
  108356. name: string;
  108357. shader: string;
  108358. };
  108359. }
  108360. declare module BABYLON {
  108361. /** @hidden */
  108362. export var reflectionFunction: {
  108363. name: string;
  108364. shader: string;
  108365. };
  108366. }
  108367. declare module BABYLON {
  108368. /** @hidden */
  108369. export var bumpFragmentFunctions: {
  108370. name: string;
  108371. shader: string;
  108372. };
  108373. }
  108374. declare module BABYLON {
  108375. /** @hidden */
  108376. export var logDepthDeclaration: {
  108377. name: string;
  108378. shader: string;
  108379. };
  108380. }
  108381. declare module BABYLON {
  108382. /** @hidden */
  108383. export var bumpFragment: {
  108384. name: string;
  108385. shader: string;
  108386. };
  108387. }
  108388. declare module BABYLON {
  108389. /** @hidden */
  108390. export var depthPrePass: {
  108391. name: string;
  108392. shader: string;
  108393. };
  108394. }
  108395. declare module BABYLON {
  108396. /** @hidden */
  108397. export var lightFragment: {
  108398. name: string;
  108399. shader: string;
  108400. };
  108401. }
  108402. declare module BABYLON {
  108403. /** @hidden */
  108404. export var logDepthFragment: {
  108405. name: string;
  108406. shader: string;
  108407. };
  108408. }
  108409. declare module BABYLON {
  108410. /** @hidden */
  108411. export var defaultPixelShader: {
  108412. name: string;
  108413. shader: string;
  108414. };
  108415. }
  108416. declare module BABYLON {
  108417. /** @hidden */
  108418. export var defaultVertexDeclaration: {
  108419. name: string;
  108420. shader: string;
  108421. };
  108422. }
  108423. declare module BABYLON {
  108424. /** @hidden */
  108425. export var bumpVertexDeclaration: {
  108426. name: string;
  108427. shader: string;
  108428. };
  108429. }
  108430. declare module BABYLON {
  108431. /** @hidden */
  108432. export var bumpVertex: {
  108433. name: string;
  108434. shader: string;
  108435. };
  108436. }
  108437. declare module BABYLON {
  108438. /** @hidden */
  108439. export var fogVertex: {
  108440. name: string;
  108441. shader: string;
  108442. };
  108443. }
  108444. declare module BABYLON {
  108445. /** @hidden */
  108446. export var shadowsVertex: {
  108447. name: string;
  108448. shader: string;
  108449. };
  108450. }
  108451. declare module BABYLON {
  108452. /** @hidden */
  108453. export var pointCloudVertex: {
  108454. name: string;
  108455. shader: string;
  108456. };
  108457. }
  108458. declare module BABYLON {
  108459. /** @hidden */
  108460. export var logDepthVertex: {
  108461. name: string;
  108462. shader: string;
  108463. };
  108464. }
  108465. declare module BABYLON {
  108466. /** @hidden */
  108467. export var defaultVertexShader: {
  108468. name: string;
  108469. shader: string;
  108470. };
  108471. }
  108472. declare module BABYLON {
  108473. /** @hidden */
  108474. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108475. MAINUV1: boolean;
  108476. MAINUV2: boolean;
  108477. DIFFUSE: boolean;
  108478. DIFFUSEDIRECTUV: number;
  108479. AMBIENT: boolean;
  108480. AMBIENTDIRECTUV: number;
  108481. OPACITY: boolean;
  108482. OPACITYDIRECTUV: number;
  108483. OPACITYRGB: boolean;
  108484. REFLECTION: boolean;
  108485. EMISSIVE: boolean;
  108486. EMISSIVEDIRECTUV: number;
  108487. SPECULAR: boolean;
  108488. SPECULARDIRECTUV: number;
  108489. BUMP: boolean;
  108490. BUMPDIRECTUV: number;
  108491. PARALLAX: boolean;
  108492. PARALLAXOCCLUSION: boolean;
  108493. SPECULAROVERALPHA: boolean;
  108494. CLIPPLANE: boolean;
  108495. CLIPPLANE2: boolean;
  108496. CLIPPLANE3: boolean;
  108497. CLIPPLANE4: boolean;
  108498. ALPHATEST: boolean;
  108499. DEPTHPREPASS: boolean;
  108500. ALPHAFROMDIFFUSE: boolean;
  108501. POINTSIZE: boolean;
  108502. FOG: boolean;
  108503. SPECULARTERM: boolean;
  108504. DIFFUSEFRESNEL: boolean;
  108505. OPACITYFRESNEL: boolean;
  108506. REFLECTIONFRESNEL: boolean;
  108507. REFRACTIONFRESNEL: boolean;
  108508. EMISSIVEFRESNEL: boolean;
  108509. FRESNEL: boolean;
  108510. NORMAL: boolean;
  108511. UV1: boolean;
  108512. UV2: boolean;
  108513. VERTEXCOLOR: boolean;
  108514. VERTEXALPHA: boolean;
  108515. NUM_BONE_INFLUENCERS: number;
  108516. BonesPerMesh: number;
  108517. BONETEXTURE: boolean;
  108518. INSTANCES: boolean;
  108519. GLOSSINESS: boolean;
  108520. ROUGHNESS: boolean;
  108521. EMISSIVEASILLUMINATION: boolean;
  108522. LINKEMISSIVEWITHDIFFUSE: boolean;
  108523. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108524. LIGHTMAP: boolean;
  108525. LIGHTMAPDIRECTUV: number;
  108526. OBJECTSPACE_NORMALMAP: boolean;
  108527. USELIGHTMAPASSHADOWMAP: boolean;
  108528. REFLECTIONMAP_3D: boolean;
  108529. REFLECTIONMAP_SPHERICAL: boolean;
  108530. REFLECTIONMAP_PLANAR: boolean;
  108531. REFLECTIONMAP_CUBIC: boolean;
  108532. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108533. REFLECTIONMAP_PROJECTION: boolean;
  108534. REFLECTIONMAP_SKYBOX: boolean;
  108535. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108536. REFLECTIONMAP_EXPLICIT: boolean;
  108537. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108538. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108539. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108540. INVERTCUBICMAP: boolean;
  108541. LOGARITHMICDEPTH: boolean;
  108542. REFRACTION: boolean;
  108543. REFRACTIONMAP_3D: boolean;
  108544. REFLECTIONOVERALPHA: boolean;
  108545. TWOSIDEDLIGHTING: boolean;
  108546. SHADOWFLOAT: boolean;
  108547. MORPHTARGETS: boolean;
  108548. MORPHTARGETS_NORMAL: boolean;
  108549. MORPHTARGETS_TANGENT: boolean;
  108550. MORPHTARGETS_UV: boolean;
  108551. NUM_MORPH_INFLUENCERS: number;
  108552. NONUNIFORMSCALING: boolean;
  108553. PREMULTIPLYALPHA: boolean;
  108554. IMAGEPROCESSING: boolean;
  108555. VIGNETTE: boolean;
  108556. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108557. VIGNETTEBLENDMODEOPAQUE: boolean;
  108558. TONEMAPPING: boolean;
  108559. TONEMAPPING_ACES: boolean;
  108560. CONTRAST: boolean;
  108561. COLORCURVES: boolean;
  108562. COLORGRADING: boolean;
  108563. COLORGRADING3D: boolean;
  108564. SAMPLER3DGREENDEPTH: boolean;
  108565. SAMPLER3DBGRMAP: boolean;
  108566. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108567. MULTIVIEW: boolean;
  108568. /**
  108569. * If the reflection texture on this material is in linear color space
  108570. * @hidden
  108571. */
  108572. IS_REFLECTION_LINEAR: boolean;
  108573. /**
  108574. * If the refraction texture on this material is in linear color space
  108575. * @hidden
  108576. */
  108577. IS_REFRACTION_LINEAR: boolean;
  108578. EXPOSURE: boolean;
  108579. constructor();
  108580. setReflectionMode(modeToEnable: string): void;
  108581. }
  108582. /**
  108583. * This is the default material used in Babylon. It is the best trade off between quality
  108584. * and performances.
  108585. * @see http://doc.babylonjs.com/babylon101/materials
  108586. */
  108587. export class StandardMaterial extends PushMaterial {
  108588. private _diffuseTexture;
  108589. /**
  108590. * The basic texture of the material as viewed under a light.
  108591. */
  108592. diffuseTexture: Nullable<BaseTexture>;
  108593. private _ambientTexture;
  108594. /**
  108595. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108596. */
  108597. ambientTexture: Nullable<BaseTexture>;
  108598. private _opacityTexture;
  108599. /**
  108600. * Define the transparency of the material from a texture.
  108601. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108602. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108603. */
  108604. opacityTexture: Nullable<BaseTexture>;
  108605. private _reflectionTexture;
  108606. /**
  108607. * Define the texture used to display the reflection.
  108608. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108609. */
  108610. reflectionTexture: Nullable<BaseTexture>;
  108611. private _emissiveTexture;
  108612. /**
  108613. * Define texture of the material as if self lit.
  108614. * This will be mixed in the final result even in the absence of light.
  108615. */
  108616. emissiveTexture: Nullable<BaseTexture>;
  108617. private _specularTexture;
  108618. /**
  108619. * Define how the color and intensity of the highlight given by the light in the material.
  108620. */
  108621. specularTexture: Nullable<BaseTexture>;
  108622. private _bumpTexture;
  108623. /**
  108624. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108625. * 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.
  108626. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108627. */
  108628. bumpTexture: Nullable<BaseTexture>;
  108629. private _lightmapTexture;
  108630. /**
  108631. * Complex lighting can be computationally expensive to compute at runtime.
  108632. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108633. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108634. */
  108635. lightmapTexture: Nullable<BaseTexture>;
  108636. private _refractionTexture;
  108637. /**
  108638. * Define the texture used to display the refraction.
  108639. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108640. */
  108641. refractionTexture: Nullable<BaseTexture>;
  108642. /**
  108643. * The color of the material lit by the environmental background lighting.
  108644. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108645. */
  108646. ambientColor: Color3;
  108647. /**
  108648. * The basic color of the material as viewed under a light.
  108649. */
  108650. diffuseColor: Color3;
  108651. /**
  108652. * Define how the color and intensity of the highlight given by the light in the material.
  108653. */
  108654. specularColor: Color3;
  108655. /**
  108656. * Define the color of the material as if self lit.
  108657. * This will be mixed in the final result even in the absence of light.
  108658. */
  108659. emissiveColor: Color3;
  108660. /**
  108661. * Defines how sharp are the highlights in the material.
  108662. * The bigger the value the sharper giving a more glossy feeling to the result.
  108663. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108664. */
  108665. specularPower: number;
  108666. private _useAlphaFromDiffuseTexture;
  108667. /**
  108668. * Does the transparency come from the diffuse texture alpha channel.
  108669. */
  108670. useAlphaFromDiffuseTexture: boolean;
  108671. private _useEmissiveAsIllumination;
  108672. /**
  108673. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108674. */
  108675. useEmissiveAsIllumination: boolean;
  108676. private _linkEmissiveWithDiffuse;
  108677. /**
  108678. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108679. * the emissive level when the final color is close to one.
  108680. */
  108681. linkEmissiveWithDiffuse: boolean;
  108682. private _useSpecularOverAlpha;
  108683. /**
  108684. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108685. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108686. */
  108687. useSpecularOverAlpha: boolean;
  108688. private _useReflectionOverAlpha;
  108689. /**
  108690. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108691. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108692. */
  108693. useReflectionOverAlpha: boolean;
  108694. private _disableLighting;
  108695. /**
  108696. * Does lights from the scene impacts this material.
  108697. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108698. */
  108699. disableLighting: boolean;
  108700. private _useObjectSpaceNormalMap;
  108701. /**
  108702. * Allows using an object space normal map (instead of tangent space).
  108703. */
  108704. useObjectSpaceNormalMap: boolean;
  108705. private _useParallax;
  108706. /**
  108707. * Is parallax enabled or not.
  108708. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108709. */
  108710. useParallax: boolean;
  108711. private _useParallaxOcclusion;
  108712. /**
  108713. * Is parallax occlusion enabled or not.
  108714. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108715. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108716. */
  108717. useParallaxOcclusion: boolean;
  108718. /**
  108719. * 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.
  108720. */
  108721. parallaxScaleBias: number;
  108722. private _roughness;
  108723. /**
  108724. * Helps to define how blurry the reflections should appears in the material.
  108725. */
  108726. roughness: number;
  108727. /**
  108728. * In case of refraction, define the value of the index of refraction.
  108729. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108730. */
  108731. indexOfRefraction: number;
  108732. /**
  108733. * Invert the refraction texture alongside the y axis.
  108734. * It can be useful with procedural textures or probe for instance.
  108735. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108736. */
  108737. invertRefractionY: boolean;
  108738. /**
  108739. * Defines the alpha limits in alpha test mode.
  108740. */
  108741. alphaCutOff: number;
  108742. private _useLightmapAsShadowmap;
  108743. /**
  108744. * In case of light mapping, define whether the map contains light or shadow informations.
  108745. */
  108746. useLightmapAsShadowmap: boolean;
  108747. private _diffuseFresnelParameters;
  108748. /**
  108749. * Define the diffuse fresnel parameters of the material.
  108750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108751. */
  108752. diffuseFresnelParameters: FresnelParameters;
  108753. private _opacityFresnelParameters;
  108754. /**
  108755. * Define the opacity fresnel parameters of the material.
  108756. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108757. */
  108758. opacityFresnelParameters: FresnelParameters;
  108759. private _reflectionFresnelParameters;
  108760. /**
  108761. * Define the reflection fresnel parameters of the material.
  108762. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108763. */
  108764. reflectionFresnelParameters: FresnelParameters;
  108765. private _refractionFresnelParameters;
  108766. /**
  108767. * Define the refraction fresnel parameters of the material.
  108768. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108769. */
  108770. refractionFresnelParameters: FresnelParameters;
  108771. private _emissiveFresnelParameters;
  108772. /**
  108773. * Define the emissive fresnel parameters of the material.
  108774. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108775. */
  108776. emissiveFresnelParameters: FresnelParameters;
  108777. private _useReflectionFresnelFromSpecular;
  108778. /**
  108779. * If true automatically deducts the fresnels values from the material specularity.
  108780. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108781. */
  108782. useReflectionFresnelFromSpecular: boolean;
  108783. private _useGlossinessFromSpecularMapAlpha;
  108784. /**
  108785. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108786. */
  108787. useGlossinessFromSpecularMapAlpha: boolean;
  108788. private _maxSimultaneousLights;
  108789. /**
  108790. * Defines the maximum number of lights that can be used in the material
  108791. */
  108792. maxSimultaneousLights: number;
  108793. private _invertNormalMapX;
  108794. /**
  108795. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108796. */
  108797. invertNormalMapX: boolean;
  108798. private _invertNormalMapY;
  108799. /**
  108800. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108801. */
  108802. invertNormalMapY: boolean;
  108803. private _twoSidedLighting;
  108804. /**
  108805. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108806. */
  108807. twoSidedLighting: boolean;
  108808. /**
  108809. * Default configuration related to image processing available in the standard Material.
  108810. */
  108811. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108812. /**
  108813. * Gets the image processing configuration used either in this material.
  108814. */
  108815. /**
  108816. * Sets the Default image processing configuration used either in the this material.
  108817. *
  108818. * If sets to null, the scene one is in use.
  108819. */
  108820. imageProcessingConfiguration: ImageProcessingConfiguration;
  108821. /**
  108822. * Keep track of the image processing observer to allow dispose and replace.
  108823. */
  108824. private _imageProcessingObserver;
  108825. /**
  108826. * Attaches a new image processing configuration to the Standard Material.
  108827. * @param configuration
  108828. */
  108829. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108830. /**
  108831. * Gets wether the color curves effect is enabled.
  108832. */
  108833. /**
  108834. * Sets wether the color curves effect is enabled.
  108835. */
  108836. cameraColorCurvesEnabled: boolean;
  108837. /**
  108838. * Gets wether the color grading effect is enabled.
  108839. */
  108840. /**
  108841. * Gets wether the color grading effect is enabled.
  108842. */
  108843. cameraColorGradingEnabled: boolean;
  108844. /**
  108845. * Gets wether tonemapping is enabled or not.
  108846. */
  108847. /**
  108848. * Sets wether tonemapping is enabled or not
  108849. */
  108850. cameraToneMappingEnabled: boolean;
  108851. /**
  108852. * The camera exposure used on this material.
  108853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108854. * This corresponds to a photographic exposure.
  108855. */
  108856. /**
  108857. * The camera exposure used on this material.
  108858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108859. * This corresponds to a photographic exposure.
  108860. */
  108861. cameraExposure: number;
  108862. /**
  108863. * Gets The camera contrast used on this material.
  108864. */
  108865. /**
  108866. * Sets The camera contrast used on this material.
  108867. */
  108868. cameraContrast: number;
  108869. /**
  108870. * Gets the Color Grading 2D Lookup Texture.
  108871. */
  108872. /**
  108873. * Sets the Color Grading 2D Lookup Texture.
  108874. */
  108875. cameraColorGradingTexture: Nullable<BaseTexture>;
  108876. /**
  108877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108879. * 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;
  108880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108881. */
  108882. /**
  108883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108885. * 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;
  108886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108887. */
  108888. cameraColorCurves: Nullable<ColorCurves>;
  108889. /**
  108890. * Custom callback helping to override the default shader used in the material.
  108891. */
  108892. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108893. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108894. protected _worldViewProjectionMatrix: Matrix;
  108895. protected _globalAmbientColor: Color3;
  108896. protected _useLogarithmicDepth: boolean;
  108897. protected _rebuildInParallel: boolean;
  108898. /**
  108899. * Instantiates a new standard material.
  108900. * This is the default material used in Babylon. It is the best trade off between quality
  108901. * and performances.
  108902. * @see http://doc.babylonjs.com/babylon101/materials
  108903. * @param name Define the name of the material in the scene
  108904. * @param scene Define the scene the material belong to
  108905. */
  108906. constructor(name: string, scene: Scene);
  108907. /**
  108908. * Gets a boolean indicating that current material needs to register RTT
  108909. */
  108910. readonly hasRenderTargetTextures: boolean;
  108911. /**
  108912. * Gets the current class name of the material e.g. "StandardMaterial"
  108913. * Mainly use in serialization.
  108914. * @returns the class name
  108915. */
  108916. getClassName(): string;
  108917. /**
  108918. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108919. * You can try switching to logarithmic depth.
  108920. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108921. */
  108922. useLogarithmicDepth: boolean;
  108923. /**
  108924. * Specifies if the material will require alpha blending
  108925. * @returns a boolean specifying if alpha blending is needed
  108926. */
  108927. needAlphaBlending(): boolean;
  108928. /**
  108929. * Specifies if this material should be rendered in alpha test mode
  108930. * @returns a boolean specifying if an alpha test is needed.
  108931. */
  108932. needAlphaTesting(): boolean;
  108933. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108934. /**
  108935. * Get the texture used for alpha test purpose.
  108936. * @returns the diffuse texture in case of the standard material.
  108937. */
  108938. getAlphaTestTexture(): Nullable<BaseTexture>;
  108939. /**
  108940. * Get if the submesh is ready to be used and all its information available.
  108941. * Child classes can use it to update shaders
  108942. * @param mesh defines the mesh to check
  108943. * @param subMesh defines which submesh to check
  108944. * @param useInstances specifies that instances should be used
  108945. * @returns a boolean indicating that the submesh is ready or not
  108946. */
  108947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108948. /**
  108949. * Builds the material UBO layouts.
  108950. * Used internally during the effect preparation.
  108951. */
  108952. buildUniformLayout(): void;
  108953. /**
  108954. * Unbinds the material from the mesh
  108955. */
  108956. unbind(): void;
  108957. /**
  108958. * Binds the submesh to this material by preparing the effect and shader to draw
  108959. * @param world defines the world transformation matrix
  108960. * @param mesh defines the mesh containing the submesh
  108961. * @param subMesh defines the submesh to bind the material to
  108962. */
  108963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108964. /**
  108965. * Get the list of animatables in the material.
  108966. * @returns the list of animatables object used in the material
  108967. */
  108968. getAnimatables(): IAnimatable[];
  108969. /**
  108970. * Gets the active textures from the material
  108971. * @returns an array of textures
  108972. */
  108973. getActiveTextures(): BaseTexture[];
  108974. /**
  108975. * Specifies if the material uses a texture
  108976. * @param texture defines the texture to check against the material
  108977. * @returns a boolean specifying if the material uses the texture
  108978. */
  108979. hasTexture(texture: BaseTexture): boolean;
  108980. /**
  108981. * Disposes the material
  108982. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108983. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108984. */
  108985. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108986. /**
  108987. * Makes a duplicate of the material, and gives it a new name
  108988. * @param name defines the new name for the duplicated material
  108989. * @returns the cloned material
  108990. */
  108991. clone(name: string): StandardMaterial;
  108992. /**
  108993. * Serializes this material in a JSON representation
  108994. * @returns the serialized material object
  108995. */
  108996. serialize(): any;
  108997. /**
  108998. * Creates a standard material from parsed material data
  108999. * @param source defines the JSON representation of the material
  109000. * @param scene defines the hosting scene
  109001. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109002. * @returns a new standard material
  109003. */
  109004. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109005. /**
  109006. * Are diffuse textures enabled in the application.
  109007. */
  109008. static DiffuseTextureEnabled: boolean;
  109009. /**
  109010. * Are ambient textures enabled in the application.
  109011. */
  109012. static AmbientTextureEnabled: boolean;
  109013. /**
  109014. * Are opacity textures enabled in the application.
  109015. */
  109016. static OpacityTextureEnabled: boolean;
  109017. /**
  109018. * Are reflection textures enabled in the application.
  109019. */
  109020. static ReflectionTextureEnabled: boolean;
  109021. /**
  109022. * Are emissive textures enabled in the application.
  109023. */
  109024. static EmissiveTextureEnabled: boolean;
  109025. /**
  109026. * Are specular textures enabled in the application.
  109027. */
  109028. static SpecularTextureEnabled: boolean;
  109029. /**
  109030. * Are bump textures enabled in the application.
  109031. */
  109032. static BumpTextureEnabled: boolean;
  109033. /**
  109034. * Are lightmap textures enabled in the application.
  109035. */
  109036. static LightmapTextureEnabled: boolean;
  109037. /**
  109038. * Are refraction textures enabled in the application.
  109039. */
  109040. static RefractionTextureEnabled: boolean;
  109041. /**
  109042. * Are color grading textures enabled in the application.
  109043. */
  109044. static ColorGradingTextureEnabled: boolean;
  109045. /**
  109046. * Are fresnels enabled in the application.
  109047. */
  109048. static FresnelEnabled: boolean;
  109049. }
  109050. }
  109051. declare module BABYLON {
  109052. /** @hidden */
  109053. export var imageProcessingPixelShader: {
  109054. name: string;
  109055. shader: string;
  109056. };
  109057. }
  109058. declare module BABYLON {
  109059. /**
  109060. * ImageProcessingPostProcess
  109061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109062. */
  109063. export class ImageProcessingPostProcess extends PostProcess {
  109064. /**
  109065. * Default configuration related to image processing available in the PBR Material.
  109066. */
  109067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109068. /**
  109069. * Gets the image processing configuration used either in this material.
  109070. */
  109071. /**
  109072. * Sets the Default image processing configuration used either in the this material.
  109073. *
  109074. * If sets to null, the scene one is in use.
  109075. */
  109076. imageProcessingConfiguration: ImageProcessingConfiguration;
  109077. /**
  109078. * Keep track of the image processing observer to allow dispose and replace.
  109079. */
  109080. private _imageProcessingObserver;
  109081. /**
  109082. * Attaches a new image processing configuration to the PBR Material.
  109083. * @param configuration
  109084. */
  109085. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109086. /**
  109087. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109088. */
  109089. /**
  109090. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109091. */
  109092. colorCurves: Nullable<ColorCurves>;
  109093. /**
  109094. * Gets wether the color curves effect is enabled.
  109095. */
  109096. /**
  109097. * Sets wether the color curves effect is enabled.
  109098. */
  109099. colorCurvesEnabled: boolean;
  109100. /**
  109101. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109102. */
  109103. /**
  109104. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109105. */
  109106. colorGradingTexture: Nullable<BaseTexture>;
  109107. /**
  109108. * Gets wether the color grading effect is enabled.
  109109. */
  109110. /**
  109111. * Gets wether the color grading effect is enabled.
  109112. */
  109113. colorGradingEnabled: boolean;
  109114. /**
  109115. * Gets exposure used in the effect.
  109116. */
  109117. /**
  109118. * Sets exposure used in the effect.
  109119. */
  109120. exposure: number;
  109121. /**
  109122. * Gets wether tonemapping is enabled or not.
  109123. */
  109124. /**
  109125. * Sets wether tonemapping is enabled or not
  109126. */
  109127. toneMappingEnabled: boolean;
  109128. /**
  109129. * Gets the type of tone mapping effect.
  109130. */
  109131. /**
  109132. * Sets the type of tone mapping effect.
  109133. */
  109134. toneMappingType: number;
  109135. /**
  109136. * Gets contrast used in the effect.
  109137. */
  109138. /**
  109139. * Sets contrast used in the effect.
  109140. */
  109141. contrast: number;
  109142. /**
  109143. * Gets Vignette stretch size.
  109144. */
  109145. /**
  109146. * Sets Vignette stretch size.
  109147. */
  109148. vignetteStretch: number;
  109149. /**
  109150. * Gets Vignette centre X Offset.
  109151. */
  109152. /**
  109153. * Sets Vignette centre X Offset.
  109154. */
  109155. vignetteCentreX: number;
  109156. /**
  109157. * Gets Vignette centre Y Offset.
  109158. */
  109159. /**
  109160. * Sets Vignette centre Y Offset.
  109161. */
  109162. vignetteCentreY: number;
  109163. /**
  109164. * Gets Vignette weight or intensity of the vignette effect.
  109165. */
  109166. /**
  109167. * Sets Vignette weight or intensity of the vignette effect.
  109168. */
  109169. vignetteWeight: number;
  109170. /**
  109171. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109172. * if vignetteEnabled is set to true.
  109173. */
  109174. /**
  109175. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109176. * if vignetteEnabled is set to true.
  109177. */
  109178. vignetteColor: Color4;
  109179. /**
  109180. * Gets Camera field of view used by the Vignette effect.
  109181. */
  109182. /**
  109183. * Sets Camera field of view used by the Vignette effect.
  109184. */
  109185. vignetteCameraFov: number;
  109186. /**
  109187. * Gets the vignette blend mode allowing different kind of effect.
  109188. */
  109189. /**
  109190. * Sets the vignette blend mode allowing different kind of effect.
  109191. */
  109192. vignetteBlendMode: number;
  109193. /**
  109194. * Gets wether the vignette effect is enabled.
  109195. */
  109196. /**
  109197. * Sets wether the vignette effect is enabled.
  109198. */
  109199. vignetteEnabled: boolean;
  109200. private _fromLinearSpace;
  109201. /**
  109202. * Gets wether the input of the processing is in Gamma or Linear Space.
  109203. */
  109204. /**
  109205. * Sets wether the input of the processing is in Gamma or Linear Space.
  109206. */
  109207. fromLinearSpace: boolean;
  109208. /**
  109209. * Defines cache preventing GC.
  109210. */
  109211. private _defines;
  109212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109213. /**
  109214. * "ImageProcessingPostProcess"
  109215. * @returns "ImageProcessingPostProcess"
  109216. */
  109217. getClassName(): string;
  109218. protected _updateParameters(): void;
  109219. dispose(camera?: Camera): void;
  109220. }
  109221. }
  109222. declare module BABYLON {
  109223. /**
  109224. * Class containing static functions to help procedurally build meshes
  109225. */
  109226. export class GroundBuilder {
  109227. /**
  109228. * Creates a ground mesh
  109229. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109230. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109232. * @param name defines the name of the mesh
  109233. * @param options defines the options used to create the mesh
  109234. * @param scene defines the hosting scene
  109235. * @returns the ground mesh
  109236. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109237. */
  109238. static CreateGround(name: string, options: {
  109239. width?: number;
  109240. height?: number;
  109241. subdivisions?: number;
  109242. subdivisionsX?: number;
  109243. subdivisionsY?: number;
  109244. updatable?: boolean;
  109245. }, scene: any): Mesh;
  109246. /**
  109247. * Creates a tiled ground mesh
  109248. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109249. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109250. * * 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
  109251. * * 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
  109252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109253. * @param name defines the name of the mesh
  109254. * @param options defines the options used to create the mesh
  109255. * @param scene defines the hosting scene
  109256. * @returns the tiled ground mesh
  109257. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109258. */
  109259. static CreateTiledGround(name: string, options: {
  109260. xmin: number;
  109261. zmin: number;
  109262. xmax: number;
  109263. zmax: number;
  109264. subdivisions?: {
  109265. w: number;
  109266. h: number;
  109267. };
  109268. precision?: {
  109269. w: number;
  109270. h: number;
  109271. };
  109272. updatable?: boolean;
  109273. }, scene?: Nullable<Scene>): Mesh;
  109274. /**
  109275. * Creates a ground mesh from a height map
  109276. * * The parameter `url` sets the URL of the height map image resource.
  109277. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109278. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109279. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109280. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109281. * * 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.
  109282. * * 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).
  109283. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109285. * @param name defines the name of the mesh
  109286. * @param url defines the url to the height map
  109287. * @param options defines the options used to create the mesh
  109288. * @param scene defines the hosting scene
  109289. * @returns the ground mesh
  109290. * @see https://doc.babylonjs.com/babylon101/height_map
  109291. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109292. */
  109293. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109294. width?: number;
  109295. height?: number;
  109296. subdivisions?: number;
  109297. minHeight?: number;
  109298. maxHeight?: number;
  109299. colorFilter?: Color3;
  109300. alphaFilter?: number;
  109301. updatable?: boolean;
  109302. onReady?: (mesh: GroundMesh) => void;
  109303. }, scene?: Nullable<Scene>): GroundMesh;
  109304. }
  109305. }
  109306. declare module BABYLON {
  109307. /**
  109308. * Class containing static functions to help procedurally build meshes
  109309. */
  109310. export class TorusBuilder {
  109311. /**
  109312. * Creates a torus mesh
  109313. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109314. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109315. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109319. * @param name defines the name of the mesh
  109320. * @param options defines the options used to create the mesh
  109321. * @param scene defines the hosting scene
  109322. * @returns the torus mesh
  109323. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109324. */
  109325. static CreateTorus(name: string, options: {
  109326. diameter?: number;
  109327. thickness?: number;
  109328. tessellation?: number;
  109329. updatable?: boolean;
  109330. sideOrientation?: number;
  109331. frontUVs?: Vector4;
  109332. backUVs?: Vector4;
  109333. }, scene: any): Mesh;
  109334. }
  109335. }
  109336. declare module BABYLON {
  109337. /**
  109338. * Class containing static functions to help procedurally build meshes
  109339. */
  109340. export class CylinderBuilder {
  109341. /**
  109342. * Creates a cylinder or a cone mesh
  109343. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109344. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109345. * * 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.
  109346. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109347. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109348. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109349. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109350. * * 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).
  109351. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109352. * * 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).
  109353. * * 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
  109354. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109355. * * 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
  109356. * * 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.
  109357. * * If `enclose` is false, a ring surface is one element.
  109358. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109359. * * 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
  109360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109363. * @param name defines the name of the mesh
  109364. * @param options defines the options used to create the mesh
  109365. * @param scene defines the hosting scene
  109366. * @returns the cylinder mesh
  109367. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109368. */
  109369. static CreateCylinder(name: string, options: {
  109370. height?: number;
  109371. diameterTop?: number;
  109372. diameterBottom?: number;
  109373. diameter?: number;
  109374. tessellation?: number;
  109375. subdivisions?: number;
  109376. arc?: number;
  109377. faceColors?: Color4[];
  109378. faceUV?: Vector4[];
  109379. updatable?: boolean;
  109380. hasRings?: boolean;
  109381. enclose?: boolean;
  109382. cap?: number;
  109383. sideOrientation?: number;
  109384. frontUVs?: Vector4;
  109385. backUVs?: Vector4;
  109386. }, scene: any): Mesh;
  109387. }
  109388. }
  109389. declare module BABYLON {
  109390. /**
  109391. * Options to modify the vr teleportation behavior.
  109392. */
  109393. export interface VRTeleportationOptions {
  109394. /**
  109395. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109396. */
  109397. floorMeshName?: string;
  109398. /**
  109399. * A list of meshes to be used as the teleportation floor. (default: empty)
  109400. */
  109401. floorMeshes?: Mesh[];
  109402. }
  109403. /**
  109404. * Options to modify the vr experience helper's behavior.
  109405. */
  109406. export interface VRExperienceHelperOptions extends WebVROptions {
  109407. /**
  109408. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109409. */
  109410. createDeviceOrientationCamera?: boolean;
  109411. /**
  109412. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109413. */
  109414. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109415. /**
  109416. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109417. */
  109418. laserToggle?: boolean;
  109419. /**
  109420. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109421. */
  109422. floorMeshes?: Mesh[];
  109423. /**
  109424. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109425. */
  109426. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109427. }
  109428. /**
  109429. * Event containing information after VR has been entered
  109430. */
  109431. export class OnAfterEnteringVRObservableEvent {
  109432. /**
  109433. * If entering vr was successful
  109434. */
  109435. success: boolean;
  109436. }
  109437. /**
  109438. * Helps to quickly add VR support to an existing scene.
  109439. * See http://doc.babylonjs.com/how_to/webvr_helper
  109440. */
  109441. export class VRExperienceHelper {
  109442. /** Options to modify the vr experience helper's behavior. */
  109443. webVROptions: VRExperienceHelperOptions;
  109444. private _scene;
  109445. private _position;
  109446. private _btnVR;
  109447. private _btnVRDisplayed;
  109448. private _webVRsupported;
  109449. private _webVRready;
  109450. private _webVRrequesting;
  109451. private _webVRpresenting;
  109452. private _hasEnteredVR;
  109453. private _fullscreenVRpresenting;
  109454. private _inputElement;
  109455. private _webVRCamera;
  109456. private _vrDeviceOrientationCamera;
  109457. private _deviceOrientationCamera;
  109458. private _existingCamera;
  109459. private _onKeyDown;
  109460. private _onVrDisplayPresentChange;
  109461. private _onVRDisplayChanged;
  109462. private _onVRRequestPresentStart;
  109463. private _onVRRequestPresentComplete;
  109464. /**
  109465. * 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)
  109466. */
  109467. enableGazeEvenWhenNoPointerLock: boolean;
  109468. /**
  109469. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109470. */
  109471. exitVROnDoubleTap: boolean;
  109472. /**
  109473. * Observable raised right before entering VR.
  109474. */
  109475. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109476. /**
  109477. * Observable raised when entering VR has completed.
  109478. */
  109479. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109480. /**
  109481. * Observable raised when exiting VR.
  109482. */
  109483. onExitingVRObservable: Observable<VRExperienceHelper>;
  109484. /**
  109485. * Observable raised when controller mesh is loaded.
  109486. */
  109487. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109488. /** Return this.onEnteringVRObservable
  109489. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109490. */
  109491. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109492. /** Return this.onExitingVRObservable
  109493. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109494. */
  109495. readonly onExitingVR: Observable<VRExperienceHelper>;
  109496. /** Return this.onControllerMeshLoadedObservable
  109497. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109498. */
  109499. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109500. private _rayLength;
  109501. private _useCustomVRButton;
  109502. private _teleportationRequested;
  109503. private _teleportActive;
  109504. private _floorMeshName;
  109505. private _floorMeshesCollection;
  109506. private _rotationAllowed;
  109507. private _teleportBackwardsVector;
  109508. private _teleportationTarget;
  109509. private _isDefaultTeleportationTarget;
  109510. private _postProcessMove;
  109511. private _teleportationFillColor;
  109512. private _teleportationBorderColor;
  109513. private _rotationAngle;
  109514. private _haloCenter;
  109515. private _cameraGazer;
  109516. private _padSensibilityUp;
  109517. private _padSensibilityDown;
  109518. private _leftController;
  109519. private _rightController;
  109520. /**
  109521. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109522. */
  109523. onNewMeshSelected: Observable<AbstractMesh>;
  109524. /**
  109525. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109526. * This observable will provide the mesh and the controller used to select the mesh
  109527. */
  109528. onMeshSelectedWithController: Observable<{
  109529. mesh: AbstractMesh;
  109530. controller: WebVRController;
  109531. }>;
  109532. /**
  109533. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109534. */
  109535. onNewMeshPicked: Observable<PickingInfo>;
  109536. private _circleEase;
  109537. /**
  109538. * Observable raised before camera teleportation
  109539. */
  109540. onBeforeCameraTeleport: Observable<Vector3>;
  109541. /**
  109542. * Observable raised after camera teleportation
  109543. */
  109544. onAfterCameraTeleport: Observable<Vector3>;
  109545. /**
  109546. * Observable raised when current selected mesh gets unselected
  109547. */
  109548. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109549. private _raySelectionPredicate;
  109550. /**
  109551. * To be optionaly changed by user to define custom ray selection
  109552. */
  109553. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109554. /**
  109555. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109556. */
  109557. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109558. /**
  109559. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109560. */
  109561. teleportationEnabled: boolean;
  109562. private _defaultHeight;
  109563. private _teleportationInitialized;
  109564. private _interactionsEnabled;
  109565. private _interactionsRequested;
  109566. private _displayGaze;
  109567. private _displayLaserPointer;
  109568. /**
  109569. * The mesh used to display where the user is going to teleport.
  109570. */
  109571. /**
  109572. * Sets the mesh to be used to display where the user is going to teleport.
  109573. */
  109574. teleportationTarget: Mesh;
  109575. /**
  109576. * 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
  109577. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109578. * See http://doc.babylonjs.com/resources/baking_transformations
  109579. */
  109580. gazeTrackerMesh: Mesh;
  109581. /**
  109582. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109583. */
  109584. updateGazeTrackerScale: boolean;
  109585. /**
  109586. * If the gaze trackers color should be updated when selecting meshes
  109587. */
  109588. updateGazeTrackerColor: boolean;
  109589. /**
  109590. * If the controller laser color should be updated when selecting meshes
  109591. */
  109592. updateControllerLaserColor: boolean;
  109593. /**
  109594. * The gaze tracking mesh corresponding to the left controller
  109595. */
  109596. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109597. /**
  109598. * The gaze tracking mesh corresponding to the right controller
  109599. */
  109600. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109601. /**
  109602. * If the ray of the gaze should be displayed.
  109603. */
  109604. /**
  109605. * Sets if the ray of the gaze should be displayed.
  109606. */
  109607. displayGaze: boolean;
  109608. /**
  109609. * If the ray of the LaserPointer should be displayed.
  109610. */
  109611. /**
  109612. * Sets if the ray of the LaserPointer should be displayed.
  109613. */
  109614. displayLaserPointer: boolean;
  109615. /**
  109616. * The deviceOrientationCamera used as the camera when not in VR.
  109617. */
  109618. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109619. /**
  109620. * Based on the current WebVR support, returns the current VR camera used.
  109621. */
  109622. readonly currentVRCamera: Nullable<Camera>;
  109623. /**
  109624. * The webVRCamera which is used when in VR.
  109625. */
  109626. readonly webVRCamera: WebVRFreeCamera;
  109627. /**
  109628. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109629. */
  109630. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109631. /**
  109632. * The html button that is used to trigger entering into VR.
  109633. */
  109634. readonly vrButton: Nullable<HTMLButtonElement>;
  109635. private readonly _teleportationRequestInitiated;
  109636. /**
  109637. * Defines wether or not Pointer lock should be requested when switching to
  109638. * full screen.
  109639. */
  109640. requestPointerLockOnFullScreen: boolean;
  109641. /**
  109642. * Instantiates a VRExperienceHelper.
  109643. * Helps to quickly add VR support to an existing scene.
  109644. * @param scene The scene the VRExperienceHelper belongs to.
  109645. * @param webVROptions Options to modify the vr experience helper's behavior.
  109646. */
  109647. constructor(scene: Scene,
  109648. /** Options to modify the vr experience helper's behavior. */
  109649. webVROptions?: VRExperienceHelperOptions);
  109650. private _onDefaultMeshLoaded;
  109651. private _onResize;
  109652. private _onFullscreenChange;
  109653. /**
  109654. * Gets a value indicating if we are currently in VR mode.
  109655. */
  109656. readonly isInVRMode: boolean;
  109657. private onVrDisplayPresentChange;
  109658. private onVRDisplayChanged;
  109659. private moveButtonToBottomRight;
  109660. private displayVRButton;
  109661. private updateButtonVisibility;
  109662. private _cachedAngularSensibility;
  109663. /**
  109664. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109665. * Otherwise, will use the fullscreen API.
  109666. */
  109667. enterVR(): void;
  109668. /**
  109669. * Attempt to exit VR, or fullscreen.
  109670. */
  109671. exitVR(): void;
  109672. /**
  109673. * The position of the vr experience helper.
  109674. */
  109675. /**
  109676. * Sets the position of the vr experience helper.
  109677. */
  109678. position: Vector3;
  109679. /**
  109680. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109681. */
  109682. enableInteractions(): void;
  109683. private readonly _noControllerIsActive;
  109684. private beforeRender;
  109685. private _isTeleportationFloor;
  109686. /**
  109687. * Adds a floor mesh to be used for teleportation.
  109688. * @param floorMesh the mesh to be used for teleportation.
  109689. */
  109690. addFloorMesh(floorMesh: Mesh): void;
  109691. /**
  109692. * Removes a floor mesh from being used for teleportation.
  109693. * @param floorMesh the mesh to be removed.
  109694. */
  109695. removeFloorMesh(floorMesh: Mesh): void;
  109696. /**
  109697. * Enables interactions and teleportation using the VR controllers and gaze.
  109698. * @param vrTeleportationOptions options to modify teleportation behavior.
  109699. */
  109700. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109701. private _onNewGamepadConnected;
  109702. private _tryEnableInteractionOnController;
  109703. private _onNewGamepadDisconnected;
  109704. private _enableInteractionOnController;
  109705. private _checkTeleportWithRay;
  109706. private _checkRotate;
  109707. private _checkTeleportBackwards;
  109708. private _enableTeleportationOnController;
  109709. private _createTeleportationCircles;
  109710. private _displayTeleportationTarget;
  109711. private _hideTeleportationTarget;
  109712. private _rotateCamera;
  109713. private _moveTeleportationSelectorTo;
  109714. private _workingVector;
  109715. private _workingQuaternion;
  109716. private _workingMatrix;
  109717. /**
  109718. * Teleports the users feet to the desired location
  109719. * @param location The location where the user's feet should be placed
  109720. */
  109721. teleportCamera(location: Vector3): void;
  109722. private _convertNormalToDirectionOfRay;
  109723. private _castRayAndSelectObject;
  109724. private _notifySelectedMeshUnselected;
  109725. /**
  109726. * Sets the color of the laser ray from the vr controllers.
  109727. * @param color new color for the ray.
  109728. */
  109729. changeLaserColor(color: Color3): void;
  109730. /**
  109731. * Sets the color of the ray from the vr headsets gaze.
  109732. * @param color new color for the ray.
  109733. */
  109734. changeGazeColor(color: Color3): void;
  109735. /**
  109736. * Exits VR and disposes of the vr experience helper
  109737. */
  109738. dispose(): void;
  109739. /**
  109740. * Gets the name of the VRExperienceHelper class
  109741. * @returns "VRExperienceHelper"
  109742. */
  109743. getClassName(): string;
  109744. }
  109745. }
  109746. declare module BABYLON {
  109747. /**
  109748. * States of the webXR experience
  109749. */
  109750. export enum WebXRState {
  109751. /**
  109752. * Transitioning to being in XR mode
  109753. */
  109754. ENTERING_XR = 0,
  109755. /**
  109756. * Transitioning to non XR mode
  109757. */
  109758. EXITING_XR = 1,
  109759. /**
  109760. * In XR mode and presenting
  109761. */
  109762. IN_XR = 2,
  109763. /**
  109764. * Not entered XR mode
  109765. */
  109766. NOT_IN_XR = 3
  109767. }
  109768. /**
  109769. * Abstraction of the XR render target
  109770. */
  109771. export interface WebXRRenderTarget extends IDisposable {
  109772. /**
  109773. * xrpresent context of the canvas which can be used to display/mirror xr content
  109774. */
  109775. canvasContext: WebGLRenderingContext;
  109776. /**
  109777. * xr layer for the canvas
  109778. */
  109779. xrLayer: Nullable<XRWebGLLayer>;
  109780. /**
  109781. * Initializes the xr layer for the session
  109782. * @param xrSession xr session
  109783. * @returns a promise that will resolve once the XR Layer has been created
  109784. */
  109785. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109786. }
  109787. }
  109788. declare module BABYLON {
  109789. /**
  109790. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109791. */
  109792. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109793. private _engine;
  109794. private _canvas;
  109795. /**
  109796. * xrpresent context of the canvas which can be used to display/mirror xr content
  109797. */
  109798. canvasContext: WebGLRenderingContext;
  109799. /**
  109800. * xr layer for the canvas
  109801. */
  109802. xrLayer: Nullable<XRWebGLLayer>;
  109803. /**
  109804. * Initializes the xr layer for the session
  109805. * @param xrSession xr session
  109806. * @returns a promise that will resolve once the XR Layer has been created
  109807. */
  109808. initializeXRLayerAsync(xrSession: any): any;
  109809. /**
  109810. * Initializes the canvas to be added/removed upon entering/exiting xr
  109811. * @param engine the Babylon engine
  109812. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109813. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109814. */
  109815. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  109816. /**
  109817. * Disposes of the object
  109818. */
  109819. dispose(): void;
  109820. private _setManagedOutputCanvas;
  109821. private _addCanvas;
  109822. private _removeCanvas;
  109823. }
  109824. }
  109825. declare module BABYLON {
  109826. /**
  109827. * Manages an XRSession to work with Babylon's engine
  109828. * @see https://doc.babylonjs.com/how_to/webxr
  109829. */
  109830. export class WebXRSessionManager implements IDisposable {
  109831. private scene;
  109832. /**
  109833. * Fires every time a new xrFrame arrives which can be used to update the camera
  109834. */
  109835. onXRFrameObservable: Observable<any>;
  109836. /**
  109837. * Fires when the xr session is ended either by the device or manually done
  109838. */
  109839. onXRSessionEnded: Observable<any>;
  109840. /**
  109841. * Underlying xr session
  109842. */
  109843. session: XRSession;
  109844. /**
  109845. * Type of reference space used when creating the session
  109846. */
  109847. referenceSpace: XRReferenceSpace;
  109848. /**
  109849. * Current XR frame
  109850. */
  109851. currentFrame: Nullable<XRFrame>;
  109852. private _xrNavigator;
  109853. private baseLayer;
  109854. private _rttProvider;
  109855. private _sessionEnded;
  109856. /**
  109857. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109858. * @param scene The scene which the session should be created for
  109859. */
  109860. constructor(scene: Scene);
  109861. /**
  109862. * Initializes the manager
  109863. * After initialization enterXR can be called to start an XR session
  109864. * @returns Promise which resolves after it is initialized
  109865. */
  109866. initializeAsync(): Promise<void>;
  109867. /**
  109868. * Initializes an xr session
  109869. * @param xrSessionMode mode to initialize
  109870. * @param optionalFeatures defines optional values to pass to the session builder
  109871. * @returns a promise which will resolve once the session has been initialized
  109872. */
  109873. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  109874. /**
  109875. * Sets the reference space on the xr session
  109876. * @param referenceSpace space to set
  109877. * @returns a promise that will resolve once the reference space has been set
  109878. */
  109879. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109880. /**
  109881. * Updates the render state of the session
  109882. * @param state state to set
  109883. * @returns a promise that resolves once the render state has been updated
  109884. */
  109885. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109886. /**
  109887. * Starts rendering to the xr layer
  109888. * @returns a promise that will resolve once rendering has started
  109889. */
  109890. startRenderingToXRAsync(): Promise<void>;
  109891. /**
  109892. * Gets the correct render target texture to be rendered this frame for this eye
  109893. * @param eye the eye for which to get the render target
  109894. * @returns the render target for the specified eye
  109895. */
  109896. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109897. /**
  109898. * Stops the xrSession and restores the renderloop
  109899. * @returns Promise which resolves after it exits XR
  109900. */
  109901. exitXRAsync(): Promise<void>;
  109902. /**
  109903. * Checks if a session would be supported for the creation options specified
  109904. * @param sessionMode session mode to check if supported eg. immersive-vr
  109905. * @returns true if supported
  109906. */
  109907. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109908. /**
  109909. * Creates a WebXRRenderTarget object for the XR session
  109910. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109911. * @returns a WebXR render target to which the session can render
  109912. */
  109913. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109914. /**
  109915. * @hidden
  109916. * Converts the render layer of xrSession to a render target
  109917. * @param session session to create render target for
  109918. * @param scene scene the new render target should be created for
  109919. */
  109920. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109921. /**
  109922. * Disposes of the session manager
  109923. */
  109924. dispose(): void;
  109925. }
  109926. }
  109927. declare module BABYLON {
  109928. /**
  109929. * WebXR Camera which holds the views for the xrSession
  109930. * @see https://doc.babylonjs.com/how_to/webxr
  109931. */
  109932. export class WebXRCamera extends FreeCamera {
  109933. private static _TmpMatrix;
  109934. /**
  109935. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109936. * @param name the name of the camera
  109937. * @param scene the scene to add the camera to
  109938. */
  109939. constructor(name: string, scene: Scene);
  109940. private _updateNumberOfRigCameras;
  109941. /** @hidden */
  109942. _updateForDualEyeDebugging(): void;
  109943. /**
  109944. * Updates the cameras position from the current pose information of the XR session
  109945. * @param xrSessionManager the session containing pose information
  109946. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109947. */
  109948. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109949. }
  109950. }
  109951. declare module BABYLON {
  109952. /**
  109953. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109954. * @see https://doc.babylonjs.com/how_to/webxr
  109955. */
  109956. export class WebXRExperienceHelper implements IDisposable {
  109957. private scene;
  109958. /**
  109959. * 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
  109960. */
  109961. container: AbstractMesh;
  109962. /**
  109963. * Camera used to render xr content
  109964. */
  109965. camera: WebXRCamera;
  109966. /**
  109967. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109968. */
  109969. state: WebXRState;
  109970. private _setState;
  109971. private static _TmpVector;
  109972. /**
  109973. * Fires when the state of the experience helper has changed
  109974. */
  109975. onStateChangedObservable: Observable<WebXRState>;
  109976. /** Session manager used to keep track of xr session */
  109977. sessionManager: WebXRSessionManager;
  109978. private _nonVRCamera;
  109979. private _originalSceneAutoClear;
  109980. private _supported;
  109981. /**
  109982. * Creates the experience helper
  109983. * @param scene the scene to attach the experience helper to
  109984. * @returns a promise for the experience helper
  109985. */
  109986. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109987. /**
  109988. * Creates a WebXRExperienceHelper
  109989. * @param scene The scene the helper should be created in
  109990. */
  109991. private constructor();
  109992. /**
  109993. * Exits XR mode and returns the scene to its original state
  109994. * @returns promise that resolves after xr mode has exited
  109995. */
  109996. exitXRAsync(): Promise<void>;
  109997. /**
  109998. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109999. * @param sessionMode options for the XR session
  110000. * @param referenceSpaceType frame of reference of the XR session
  110001. * @param renderTarget the output canvas that will be used to enter XR mode
  110002. * @returns promise that resolves after xr mode has entered
  110003. */
  110004. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110005. /**
  110006. * Updates the global position of the camera by moving the camera's container
  110007. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110008. * @param position The desired global position of the camera
  110009. */
  110010. setPositionOfCameraUsingContainer(position: Vector3): void;
  110011. /**
  110012. * Rotates the xr camera by rotating the camera's container around the camera's position
  110013. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110014. * @param rotation the desired quaternion rotation to apply to the camera
  110015. */
  110016. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110017. /**
  110018. * Disposes of the experience helper
  110019. */
  110020. dispose(): void;
  110021. }
  110022. }
  110023. declare module BABYLON {
  110024. /**
  110025. * Button which can be used to enter a different mode of XR
  110026. */
  110027. export class WebXREnterExitUIButton {
  110028. /** button element */
  110029. element: HTMLElement;
  110030. /** XR initialization options for the button */
  110031. sessionMode: XRSessionMode;
  110032. /** Reference space type */
  110033. referenceSpaceType: XRReferenceSpaceType;
  110034. /**
  110035. * Creates a WebXREnterExitUIButton
  110036. * @param element button element
  110037. * @param sessionMode XR initialization session mode
  110038. * @param referenceSpaceType the type of reference space to be used
  110039. */
  110040. constructor(
  110041. /** button element */
  110042. element: HTMLElement,
  110043. /** XR initialization options for the button */
  110044. sessionMode: XRSessionMode,
  110045. /** Reference space type */
  110046. referenceSpaceType: XRReferenceSpaceType);
  110047. /**
  110048. * Overwritable function which can be used to update the button's visuals when the state changes
  110049. * @param activeButton the current active button in the UI
  110050. */
  110051. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110052. }
  110053. /**
  110054. * Options to create the webXR UI
  110055. */
  110056. export class WebXREnterExitUIOptions {
  110057. /**
  110058. * Context to enter xr with
  110059. */
  110060. renderTarget?: Nullable<WebXRRenderTarget>;
  110061. /**
  110062. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110063. */
  110064. customButtons?: Array<WebXREnterExitUIButton>;
  110065. }
  110066. /**
  110067. * UI to allow the user to enter/exit XR mode
  110068. */
  110069. export class WebXREnterExitUI implements IDisposable {
  110070. private scene;
  110071. private _overlay;
  110072. private _buttons;
  110073. private _activeButton;
  110074. /**
  110075. * Fired every time the active button is changed.
  110076. *
  110077. * When xr is entered via a button that launches xr that button will be the callback parameter
  110078. *
  110079. * When exiting xr the callback parameter will be null)
  110080. */
  110081. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110082. /**
  110083. * Creates UI to allow the user to enter/exit XR mode
  110084. * @param scene the scene to add the ui to
  110085. * @param helper the xr experience helper to enter/exit xr with
  110086. * @param options options to configure the UI
  110087. * @returns the created ui
  110088. */
  110089. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110090. private constructor();
  110091. private _updateButtons;
  110092. /**
  110093. * Disposes of the object
  110094. */
  110095. dispose(): void;
  110096. }
  110097. }
  110098. declare module BABYLON {
  110099. /**
  110100. * Represents an XR input
  110101. */
  110102. export class WebXRController {
  110103. private scene;
  110104. /** The underlying input source for the controller */
  110105. inputSource: XRInputSource;
  110106. private parentContainer;
  110107. /**
  110108. * 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
  110109. */
  110110. grip?: AbstractMesh;
  110111. /**
  110112. * Pointer which can be used to select objects or attach a visible laser to
  110113. */
  110114. pointer: AbstractMesh;
  110115. private _gamepadMode;
  110116. /**
  110117. * If available, this is the gamepad object related to this controller.
  110118. * Using this object it is possible to get click events and trackpad changes of the
  110119. * webxr controller that is currently being used.
  110120. */
  110121. gamepadController?: WebVRController;
  110122. /**
  110123. * Event that fires when the controller is removed/disposed
  110124. */
  110125. onDisposeObservable: Observable<{}>;
  110126. private _tmpMatrix;
  110127. private _tmpQuaternion;
  110128. private _tmpVector;
  110129. /**
  110130. * Creates the controller
  110131. * @see https://doc.babylonjs.com/how_to/webxr
  110132. * @param scene the scene which the controller should be associated to
  110133. * @param inputSource the underlying input source for the controller
  110134. * @param parentContainer parent that the controller meshes should be children of
  110135. */
  110136. constructor(scene: Scene,
  110137. /** The underlying input source for the controller */
  110138. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110139. /**
  110140. * Updates the controller pose based on the given XRFrame
  110141. * @param xrFrame xr frame to update the pose with
  110142. * @param referenceSpace reference space to use
  110143. */
  110144. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110145. /**
  110146. * Gets a world space ray coming from the controller
  110147. * @param result the resulting ray
  110148. */
  110149. getWorldPointerRayToRef(result: Ray): void;
  110150. /**
  110151. * Get the scene associated with this controller
  110152. * @returns the scene object
  110153. */
  110154. getScene(): Scene;
  110155. /**
  110156. * Disposes of the object
  110157. */
  110158. dispose(): void;
  110159. }
  110160. }
  110161. declare module BABYLON {
  110162. /**
  110163. * XR input used to track XR inputs such as controllers/rays
  110164. */
  110165. export class WebXRInput implements IDisposable {
  110166. /**
  110167. * Base experience the input listens to
  110168. */
  110169. baseExperience: WebXRExperienceHelper;
  110170. /**
  110171. * XR controllers being tracked
  110172. */
  110173. controllers: Array<WebXRController>;
  110174. private _frameObserver;
  110175. private _stateObserver;
  110176. /**
  110177. * Event when a controller has been connected/added
  110178. */
  110179. onControllerAddedObservable: Observable<WebXRController>;
  110180. /**
  110181. * Event when a controller has been removed/disconnected
  110182. */
  110183. onControllerRemovedObservable: Observable<WebXRController>;
  110184. /**
  110185. * Initializes the WebXRInput
  110186. * @param baseExperience experience helper which the input should be created for
  110187. */
  110188. constructor(
  110189. /**
  110190. * Base experience the input listens to
  110191. */
  110192. baseExperience: WebXRExperienceHelper);
  110193. private _onInputSourcesChange;
  110194. private _addAndRemoveControllers;
  110195. /**
  110196. * Disposes of the object
  110197. */
  110198. dispose(): void;
  110199. }
  110200. }
  110201. declare module BABYLON {
  110202. /**
  110203. * Enables teleportation
  110204. */
  110205. export class WebXRControllerTeleportation {
  110206. private _teleportationFillColor;
  110207. private _teleportationBorderColor;
  110208. private _tmpRay;
  110209. private _tmpVector;
  110210. /**
  110211. * Creates a WebXRControllerTeleportation
  110212. * @param input input manager to add teleportation to
  110213. * @param floorMeshes floormeshes which can be teleported to
  110214. */
  110215. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110216. }
  110217. }
  110218. declare module BABYLON {
  110219. /**
  110220. * Handles pointer input automatically for the pointer of XR controllers
  110221. */
  110222. export class WebXRControllerPointerSelection {
  110223. private static _idCounter;
  110224. private _tmpRay;
  110225. /**
  110226. * Creates a WebXRControllerPointerSelection
  110227. * @param input input manager to setup pointer selection
  110228. */
  110229. constructor(input: WebXRInput);
  110230. private _convertNormalToDirectionOfRay;
  110231. private _updatePointerDistance;
  110232. }
  110233. }
  110234. declare module BABYLON {
  110235. /**
  110236. * Class used to represent data loading progression
  110237. */
  110238. export class SceneLoaderProgressEvent {
  110239. /** defines if data length to load can be evaluated */
  110240. readonly lengthComputable: boolean;
  110241. /** defines the loaded data length */
  110242. readonly loaded: number;
  110243. /** defines the data length to load */
  110244. readonly total: number;
  110245. /**
  110246. * Create a new progress event
  110247. * @param lengthComputable defines if data length to load can be evaluated
  110248. * @param loaded defines the loaded data length
  110249. * @param total defines the data length to load
  110250. */
  110251. constructor(
  110252. /** defines if data length to load can be evaluated */
  110253. lengthComputable: boolean,
  110254. /** defines the loaded data length */
  110255. loaded: number,
  110256. /** defines the data length to load */
  110257. total: number);
  110258. /**
  110259. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110260. * @param event defines the source event
  110261. * @returns a new SceneLoaderProgressEvent
  110262. */
  110263. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110264. }
  110265. /**
  110266. * Interface used by SceneLoader plugins to define supported file extensions
  110267. */
  110268. export interface ISceneLoaderPluginExtensions {
  110269. /**
  110270. * Defines the list of supported extensions
  110271. */
  110272. [extension: string]: {
  110273. isBinary: boolean;
  110274. };
  110275. }
  110276. /**
  110277. * Interface used by SceneLoader plugin factory
  110278. */
  110279. export interface ISceneLoaderPluginFactory {
  110280. /**
  110281. * Defines the name of the factory
  110282. */
  110283. name: string;
  110284. /**
  110285. * Function called to create a new plugin
  110286. * @return the new plugin
  110287. */
  110288. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110289. /**
  110290. * The callback that returns true if the data can be directly loaded.
  110291. * @param data string containing the file data
  110292. * @returns if the data can be loaded directly
  110293. */
  110294. canDirectLoad?(data: string): boolean;
  110295. }
  110296. /**
  110297. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110298. */
  110299. export interface ISceneLoaderPluginBase {
  110300. /**
  110301. * The friendly name of this plugin.
  110302. */
  110303. name: string;
  110304. /**
  110305. * The file extensions supported by this plugin.
  110306. */
  110307. extensions: string | ISceneLoaderPluginExtensions;
  110308. /**
  110309. * The callback called when loading from a url.
  110310. * @param scene scene loading this url
  110311. * @param url url to load
  110312. * @param onSuccess callback called when the file successfully loads
  110313. * @param onProgress callback called while file is loading (if the server supports this mode)
  110314. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110315. * @param onError callback called when the file fails to load
  110316. * @returns a file request object
  110317. */
  110318. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110319. /**
  110320. * The callback called when loading from a file object.
  110321. * @param scene scene loading this file
  110322. * @param file defines the file to load
  110323. * @param onSuccess defines the callback to call when data is loaded
  110324. * @param onProgress defines the callback to call during loading process
  110325. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110326. * @param onError defines the callback to call when an error occurs
  110327. * @returns a file request object
  110328. */
  110329. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110330. /**
  110331. * The callback that returns true if the data can be directly loaded.
  110332. * @param data string containing the file data
  110333. * @returns if the data can be loaded directly
  110334. */
  110335. canDirectLoad?(data: string): boolean;
  110336. /**
  110337. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110338. * @param scene scene loading this data
  110339. * @param data string containing the data
  110340. * @returns data to pass to the plugin
  110341. */
  110342. directLoad?(scene: Scene, data: string): any;
  110343. /**
  110344. * The callback that allows custom handling of the root url based on the response url.
  110345. * @param rootUrl the original root url
  110346. * @param responseURL the response url if available
  110347. * @returns the new root url
  110348. */
  110349. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110350. }
  110351. /**
  110352. * Interface used to define a SceneLoader plugin
  110353. */
  110354. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110355. /**
  110356. * Import meshes into a scene.
  110357. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110358. * @param scene The scene to import into
  110359. * @param data The data to import
  110360. * @param rootUrl The root url for scene and resources
  110361. * @param meshes The meshes array to import into
  110362. * @param particleSystems The particle systems array to import into
  110363. * @param skeletons The skeletons array to import into
  110364. * @param onError The callback when import fails
  110365. * @returns True if successful or false otherwise
  110366. */
  110367. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110368. /**
  110369. * Load into a scene.
  110370. * @param scene The scene to load into
  110371. * @param data The data to import
  110372. * @param rootUrl The root url for scene and resources
  110373. * @param onError The callback when import fails
  110374. * @returns True if successful or false otherwise
  110375. */
  110376. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110377. /**
  110378. * Load into an asset container.
  110379. * @param scene The scene to load into
  110380. * @param data The data to import
  110381. * @param rootUrl The root url for scene and resources
  110382. * @param onError The callback when import fails
  110383. * @returns The loaded asset container
  110384. */
  110385. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110386. }
  110387. /**
  110388. * Interface used to define an async SceneLoader plugin
  110389. */
  110390. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110391. /**
  110392. * Import meshes into a scene.
  110393. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110394. * @param scene The scene to import into
  110395. * @param data The data to import
  110396. * @param rootUrl The root url for scene and resources
  110397. * @param onProgress The callback when the load progresses
  110398. * @param fileName Defines the name of the file to load
  110399. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110400. */
  110401. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110402. meshes: AbstractMesh[];
  110403. particleSystems: IParticleSystem[];
  110404. skeletons: Skeleton[];
  110405. animationGroups: AnimationGroup[];
  110406. }>;
  110407. /**
  110408. * Load into a scene.
  110409. * @param scene The scene to load into
  110410. * @param data The data to import
  110411. * @param rootUrl The root url for scene and resources
  110412. * @param onProgress The callback when the load progresses
  110413. * @param fileName Defines the name of the file to load
  110414. * @returns Nothing
  110415. */
  110416. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110417. /**
  110418. * Load into an asset container.
  110419. * @param scene The scene to load into
  110420. * @param data The data to import
  110421. * @param rootUrl The root url for scene and resources
  110422. * @param onProgress The callback when the load progresses
  110423. * @param fileName Defines the name of the file to load
  110424. * @returns The loaded asset container
  110425. */
  110426. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110427. }
  110428. /**
  110429. * Class used to load scene from various file formats using registered plugins
  110430. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110431. */
  110432. export class SceneLoader {
  110433. /**
  110434. * No logging while loading
  110435. */
  110436. static readonly NO_LOGGING: number;
  110437. /**
  110438. * Minimal logging while loading
  110439. */
  110440. static readonly MINIMAL_LOGGING: number;
  110441. /**
  110442. * Summary logging while loading
  110443. */
  110444. static readonly SUMMARY_LOGGING: number;
  110445. /**
  110446. * Detailled logging while loading
  110447. */
  110448. static readonly DETAILED_LOGGING: number;
  110449. /**
  110450. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110451. */
  110452. static ForceFullSceneLoadingForIncremental: boolean;
  110453. /**
  110454. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110455. */
  110456. static ShowLoadingScreen: boolean;
  110457. /**
  110458. * Defines the current logging level (while loading the scene)
  110459. * @ignorenaming
  110460. */
  110461. static loggingLevel: number;
  110462. /**
  110463. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110464. */
  110465. static CleanBoneMatrixWeights: boolean;
  110466. /**
  110467. * Event raised when a plugin is used to load a scene
  110468. */
  110469. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110470. private static _registeredPlugins;
  110471. private static _getDefaultPlugin;
  110472. private static _getPluginForExtension;
  110473. private static _getPluginForDirectLoad;
  110474. private static _getPluginForFilename;
  110475. private static _getDirectLoad;
  110476. private static _loadData;
  110477. private static _getFileInfo;
  110478. /**
  110479. * Gets a plugin that can load the given extension
  110480. * @param extension defines the extension to load
  110481. * @returns a plugin or null if none works
  110482. */
  110483. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110484. /**
  110485. * Gets a boolean indicating that the given extension can be loaded
  110486. * @param extension defines the extension to load
  110487. * @returns true if the extension is supported
  110488. */
  110489. static IsPluginForExtensionAvailable(extension: string): boolean;
  110490. /**
  110491. * Adds a new plugin to the list of registered plugins
  110492. * @param plugin defines the plugin to add
  110493. */
  110494. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110495. /**
  110496. * Import meshes into a scene
  110497. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110498. * @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)
  110499. * @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)
  110500. * @param scene the instance of BABYLON.Scene to append to
  110501. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110502. * @param onProgress a callback with a progress event for each file being loaded
  110503. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110504. * @param pluginExtension the extension used to determine the plugin
  110505. * @returns The loaded plugin
  110506. */
  110507. 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>;
  110508. /**
  110509. * Import meshes into a scene
  110510. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110511. * @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)
  110512. * @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)
  110513. * @param scene the instance of BABYLON.Scene to append to
  110514. * @param onProgress a callback with a progress event for each file being loaded
  110515. * @param pluginExtension the extension used to determine the plugin
  110516. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110517. */
  110518. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110519. meshes: AbstractMesh[];
  110520. particleSystems: IParticleSystem[];
  110521. skeletons: Skeleton[];
  110522. animationGroups: AnimationGroup[];
  110523. }>;
  110524. /**
  110525. * Load a scene
  110526. * @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)
  110527. * @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)
  110528. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110529. * @param onSuccess a callback with the scene when import succeeds
  110530. * @param onProgress a callback with a progress event for each file being loaded
  110531. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110532. * @param pluginExtension the extension used to determine the plugin
  110533. * @returns The loaded plugin
  110534. */
  110535. 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>;
  110536. /**
  110537. * Load a scene
  110538. * @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)
  110539. * @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)
  110540. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110541. * @param onProgress a callback with a progress event for each file being loaded
  110542. * @param pluginExtension the extension used to determine the plugin
  110543. * @returns The loaded scene
  110544. */
  110545. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110546. /**
  110547. * Append a scene
  110548. * @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)
  110549. * @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)
  110550. * @param scene is the instance of BABYLON.Scene to append to
  110551. * @param onSuccess a callback with the scene when import succeeds
  110552. * @param onProgress a callback with a progress event for each file being loaded
  110553. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110554. * @param pluginExtension the extension used to determine the plugin
  110555. * @returns The loaded plugin
  110556. */
  110557. 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>;
  110558. /**
  110559. * Append a scene
  110560. * @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)
  110561. * @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)
  110562. * @param scene is the instance of BABYLON.Scene to append to
  110563. * @param onProgress a callback with a progress event for each file being loaded
  110564. * @param pluginExtension the extension used to determine the plugin
  110565. * @returns The given scene
  110566. */
  110567. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110568. /**
  110569. * Load a scene into an asset container
  110570. * @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)
  110571. * @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)
  110572. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110573. * @param onSuccess a callback with the scene when import succeeds
  110574. * @param onProgress a callback with a progress event for each file being loaded
  110575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110576. * @param pluginExtension the extension used to determine the plugin
  110577. * @returns The loaded plugin
  110578. */
  110579. 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>;
  110580. /**
  110581. * Load a scene into an asset container
  110582. * @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)
  110583. * @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)
  110584. * @param scene is the instance of Scene to append to
  110585. * @param onProgress a callback with a progress event for each file being loaded
  110586. * @param pluginExtension the extension used to determine the plugin
  110587. * @returns The loaded asset container
  110588. */
  110589. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110590. }
  110591. }
  110592. declare module BABYLON {
  110593. /**
  110594. * Generic Controller
  110595. */
  110596. export class GenericController extends WebVRController {
  110597. /**
  110598. * Base Url for the controller model.
  110599. */
  110600. static readonly MODEL_BASE_URL: string;
  110601. /**
  110602. * File name for the controller model.
  110603. */
  110604. static readonly MODEL_FILENAME: string;
  110605. /**
  110606. * Creates a new GenericController from a gamepad
  110607. * @param vrGamepad the gamepad that the controller should be created from
  110608. */
  110609. constructor(vrGamepad: any);
  110610. /**
  110611. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110612. * @param scene scene in which to add meshes
  110613. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110614. */
  110615. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110616. /**
  110617. * Called once for each button that changed state since the last frame
  110618. * @param buttonIdx Which button index changed
  110619. * @param state New state of the button
  110620. * @param changes Which properties on the state changed since last frame
  110621. */
  110622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110623. }
  110624. }
  110625. declare module BABYLON {
  110626. /**
  110627. * Defines the WindowsMotionController object that the state of the windows motion controller
  110628. */
  110629. export class WindowsMotionController extends WebVRController {
  110630. /**
  110631. * The base url used to load the left and right controller models
  110632. */
  110633. static MODEL_BASE_URL: string;
  110634. /**
  110635. * The name of the left controller model file
  110636. */
  110637. static MODEL_LEFT_FILENAME: string;
  110638. /**
  110639. * The name of the right controller model file
  110640. */
  110641. static MODEL_RIGHT_FILENAME: string;
  110642. /**
  110643. * The controller name prefix for this controller type
  110644. */
  110645. static readonly GAMEPAD_ID_PREFIX: string;
  110646. /**
  110647. * The controller id pattern for this controller type
  110648. */
  110649. private static readonly GAMEPAD_ID_PATTERN;
  110650. private _loadedMeshInfo;
  110651. private readonly _mapping;
  110652. /**
  110653. * Fired when the trackpad on this controller is clicked
  110654. */
  110655. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110656. /**
  110657. * Fired when the trackpad on this controller is modified
  110658. */
  110659. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110660. /**
  110661. * The current x and y values of this controller's trackpad
  110662. */
  110663. trackpad: StickValues;
  110664. /**
  110665. * Creates a new WindowsMotionController from a gamepad
  110666. * @param vrGamepad the gamepad that the controller should be created from
  110667. */
  110668. constructor(vrGamepad: any);
  110669. /**
  110670. * Fired when the trigger on this controller is modified
  110671. */
  110672. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110673. /**
  110674. * Fired when the menu button on this controller is modified
  110675. */
  110676. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110677. /**
  110678. * Fired when the grip button on this controller is modified
  110679. */
  110680. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110681. /**
  110682. * Fired when the thumbstick button on this controller is modified
  110683. */
  110684. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110685. /**
  110686. * Fired when the touchpad button on this controller is modified
  110687. */
  110688. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110689. /**
  110690. * Fired when the touchpad values on this controller are modified
  110691. */
  110692. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110693. private _updateTrackpad;
  110694. /**
  110695. * Called once per frame by the engine.
  110696. */
  110697. update(): void;
  110698. /**
  110699. * Called once for each button that changed state since the last frame
  110700. * @param buttonIdx Which button index changed
  110701. * @param state New state of the button
  110702. * @param changes Which properties on the state changed since last frame
  110703. */
  110704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110705. /**
  110706. * Moves the buttons on the controller mesh based on their current state
  110707. * @param buttonName the name of the button to move
  110708. * @param buttonValue the value of the button which determines the buttons new position
  110709. */
  110710. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110711. /**
  110712. * Moves the axis on the controller mesh based on its current state
  110713. * @param axis the index of the axis
  110714. * @param axisValue the value of the axis which determines the meshes new position
  110715. * @hidden
  110716. */
  110717. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110718. /**
  110719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110720. * @param scene scene in which to add meshes
  110721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110722. */
  110723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110724. /**
  110725. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110726. * can be transformed by button presses and axes values, based on this._mapping.
  110727. *
  110728. * @param scene scene in which the meshes exist
  110729. * @param meshes list of meshes that make up the controller model to process
  110730. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110731. */
  110732. private processModel;
  110733. private createMeshInfo;
  110734. /**
  110735. * Gets the ray of the controller in the direction the controller is pointing
  110736. * @param length the length the resulting ray should be
  110737. * @returns a ray in the direction the controller is pointing
  110738. */
  110739. getForwardRay(length?: number): Ray;
  110740. /**
  110741. * Disposes of the controller
  110742. */
  110743. dispose(): void;
  110744. }
  110745. }
  110746. declare module BABYLON {
  110747. /**
  110748. * Oculus Touch Controller
  110749. */
  110750. export class OculusTouchController extends WebVRController {
  110751. /**
  110752. * Base Url for the controller model.
  110753. */
  110754. static MODEL_BASE_URL: string;
  110755. /**
  110756. * File name for the left controller model.
  110757. */
  110758. static MODEL_LEFT_FILENAME: string;
  110759. /**
  110760. * File name for the right controller model.
  110761. */
  110762. static MODEL_RIGHT_FILENAME: string;
  110763. /**
  110764. * Base Url for the Quest controller model.
  110765. */
  110766. static QUEST_MODEL_BASE_URL: string;
  110767. /**
  110768. * @hidden
  110769. * If the controllers are running on a device that needs the updated Quest controller models
  110770. */
  110771. static _IsQuest: boolean;
  110772. /**
  110773. * Fired when the secondary trigger on this controller is modified
  110774. */
  110775. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110776. /**
  110777. * Fired when the thumb rest on this controller is modified
  110778. */
  110779. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110780. /**
  110781. * Creates a new OculusTouchController from a gamepad
  110782. * @param vrGamepad the gamepad that the controller should be created from
  110783. */
  110784. constructor(vrGamepad: any);
  110785. /**
  110786. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110787. * @param scene scene in which to add meshes
  110788. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110789. */
  110790. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110791. /**
  110792. * Fired when the A button on this controller is modified
  110793. */
  110794. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110795. /**
  110796. * Fired when the B button on this controller is modified
  110797. */
  110798. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110799. /**
  110800. * Fired when the X button on this controller is modified
  110801. */
  110802. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110803. /**
  110804. * Fired when the Y button on this controller is modified
  110805. */
  110806. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110807. /**
  110808. * Called once for each button that changed state since the last frame
  110809. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110810. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110811. * 2) secondary trigger (same)
  110812. * 3) A (right) X (left), touch, pressed = value
  110813. * 4) B / Y
  110814. * 5) thumb rest
  110815. * @param buttonIdx Which button index changed
  110816. * @param state New state of the button
  110817. * @param changes Which properties on the state changed since last frame
  110818. */
  110819. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110820. }
  110821. }
  110822. declare module BABYLON {
  110823. /**
  110824. * Vive Controller
  110825. */
  110826. export class ViveController extends WebVRController {
  110827. /**
  110828. * Base Url for the controller model.
  110829. */
  110830. static MODEL_BASE_URL: string;
  110831. /**
  110832. * File name for the controller model.
  110833. */
  110834. static MODEL_FILENAME: string;
  110835. /**
  110836. * Creates a new ViveController from a gamepad
  110837. * @param vrGamepad the gamepad that the controller should be created from
  110838. */
  110839. constructor(vrGamepad: any);
  110840. /**
  110841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110842. * @param scene scene in which to add meshes
  110843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110844. */
  110845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110846. /**
  110847. * Fired when the left button on this controller is modified
  110848. */
  110849. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110850. /**
  110851. * Fired when the right button on this controller is modified
  110852. */
  110853. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110854. /**
  110855. * Fired when the menu button on this controller is modified
  110856. */
  110857. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110858. /**
  110859. * Called once for each button that changed state since the last frame
  110860. * Vive mapping:
  110861. * 0: touchpad
  110862. * 1: trigger
  110863. * 2: left AND right buttons
  110864. * 3: menu button
  110865. * @param buttonIdx Which button index changed
  110866. * @param state New state of the button
  110867. * @param changes Which properties on the state changed since last frame
  110868. */
  110869. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110870. }
  110871. }
  110872. declare module BABYLON {
  110873. /**
  110874. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110875. */
  110876. export class WebXRControllerModelLoader {
  110877. /**
  110878. * Creates the WebXRControllerModelLoader
  110879. * @param input xr input that creates the controllers
  110880. */
  110881. constructor(input: WebXRInput);
  110882. }
  110883. }
  110884. declare module BABYLON {
  110885. /**
  110886. * Contains an array of blocks representing the octree
  110887. */
  110888. export interface IOctreeContainer<T> {
  110889. /**
  110890. * Blocks within the octree
  110891. */
  110892. blocks: Array<OctreeBlock<T>>;
  110893. }
  110894. /**
  110895. * Class used to store a cell in an octree
  110896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110897. */
  110898. export class OctreeBlock<T> {
  110899. /**
  110900. * Gets the content of the current block
  110901. */
  110902. entries: T[];
  110903. /**
  110904. * Gets the list of block children
  110905. */
  110906. blocks: Array<OctreeBlock<T>>;
  110907. private _depth;
  110908. private _maxDepth;
  110909. private _capacity;
  110910. private _minPoint;
  110911. private _maxPoint;
  110912. private _boundingVectors;
  110913. private _creationFunc;
  110914. /**
  110915. * Creates a new block
  110916. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110917. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110918. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110919. * @param depth defines the current depth of this block in the octree
  110920. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110921. * @param creationFunc defines a callback to call when an element is added to the block
  110922. */
  110923. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110924. /**
  110925. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110926. */
  110927. readonly capacity: number;
  110928. /**
  110929. * Gets the minimum vector (in world space) of the block's bounding box
  110930. */
  110931. readonly minPoint: Vector3;
  110932. /**
  110933. * Gets the maximum vector (in world space) of the block's bounding box
  110934. */
  110935. readonly maxPoint: Vector3;
  110936. /**
  110937. * Add a new element to this block
  110938. * @param entry defines the element to add
  110939. */
  110940. addEntry(entry: T): void;
  110941. /**
  110942. * Remove an element from this block
  110943. * @param entry defines the element to remove
  110944. */
  110945. removeEntry(entry: T): void;
  110946. /**
  110947. * Add an array of elements to this block
  110948. * @param entries defines the array of elements to add
  110949. */
  110950. addEntries(entries: T[]): void;
  110951. /**
  110952. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110953. * @param frustumPlanes defines the frustum planes to test
  110954. * @param selection defines the array to store current content if selection is positive
  110955. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110956. */
  110957. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110958. /**
  110959. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110960. * @param sphereCenter defines the bounding sphere center
  110961. * @param sphereRadius defines the bounding sphere radius
  110962. * @param selection defines the array to store current content if selection is positive
  110963. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110964. */
  110965. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110966. /**
  110967. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110968. * @param ray defines the ray to test with
  110969. * @param selection defines the array to store current content if selection is positive
  110970. */
  110971. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110972. /**
  110973. * Subdivide the content into child blocks (this block will then be empty)
  110974. */
  110975. createInnerBlocks(): void;
  110976. /**
  110977. * @hidden
  110978. */
  110979. 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;
  110980. }
  110981. }
  110982. declare module BABYLON {
  110983. /**
  110984. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110985. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110986. */
  110987. export class Octree<T> {
  110988. /** 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.) */
  110989. maxDepth: number;
  110990. /**
  110991. * Blocks within the octree containing objects
  110992. */
  110993. blocks: Array<OctreeBlock<T>>;
  110994. /**
  110995. * Content stored in the octree
  110996. */
  110997. dynamicContent: T[];
  110998. private _maxBlockCapacity;
  110999. private _selectionContent;
  111000. private _creationFunc;
  111001. /**
  111002. * Creates a octree
  111003. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111004. * @param creationFunc function to be used to instatiate the octree
  111005. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111006. * @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.)
  111007. */
  111008. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111009. /** 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.) */
  111010. maxDepth?: number);
  111011. /**
  111012. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111013. * @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);
  111014. * @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);
  111015. * @param entries meshes to be added to the octree blocks
  111016. */
  111017. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111018. /**
  111019. * Adds a mesh to the octree
  111020. * @param entry Mesh to add to the octree
  111021. */
  111022. addMesh(entry: T): void;
  111023. /**
  111024. * Remove an element from the octree
  111025. * @param entry defines the element to remove
  111026. */
  111027. removeMesh(entry: T): void;
  111028. /**
  111029. * Selects an array of meshes within the frustum
  111030. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111031. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111032. * @returns array of meshes within the frustum
  111033. */
  111034. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111035. /**
  111036. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111037. * @param sphereCenter defines the bounding sphere center
  111038. * @param sphereRadius defines the bounding sphere radius
  111039. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111040. * @returns an array of objects that intersect the sphere
  111041. */
  111042. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111043. /**
  111044. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111045. * @param ray defines the ray to test with
  111046. * @returns array of intersected objects
  111047. */
  111048. intersectsRay(ray: Ray): SmartArray<T>;
  111049. /**
  111050. * Adds a mesh into the octree block if it intersects the block
  111051. */
  111052. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111053. /**
  111054. * Adds a submesh into the octree block if it intersects the block
  111055. */
  111056. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111057. }
  111058. }
  111059. declare module BABYLON {
  111060. interface Scene {
  111061. /**
  111062. * @hidden
  111063. * Backing Filed
  111064. */
  111065. _selectionOctree: Octree<AbstractMesh>;
  111066. /**
  111067. * Gets the octree used to boost mesh selection (picking)
  111068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111069. */
  111070. selectionOctree: Octree<AbstractMesh>;
  111071. /**
  111072. * Creates or updates the octree used to boost selection (picking)
  111073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111074. * @param maxCapacity defines the maximum capacity per leaf
  111075. * @param maxDepth defines the maximum depth of the octree
  111076. * @returns an octree of AbstractMesh
  111077. */
  111078. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111079. }
  111080. interface AbstractMesh {
  111081. /**
  111082. * @hidden
  111083. * Backing Field
  111084. */
  111085. _submeshesOctree: Octree<SubMesh>;
  111086. /**
  111087. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111088. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111089. * @param maxCapacity defines the maximum size of each block (64 by default)
  111090. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111091. * @returns the new octree
  111092. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111094. */
  111095. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111096. }
  111097. /**
  111098. * Defines the octree scene component responsible to manage any octrees
  111099. * in a given scene.
  111100. */
  111101. export class OctreeSceneComponent {
  111102. /**
  111103. * The component name help to identify the component in the list of scene components.
  111104. */
  111105. readonly name: string;
  111106. /**
  111107. * The scene the component belongs to.
  111108. */
  111109. scene: Scene;
  111110. /**
  111111. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111112. */
  111113. readonly checksIsEnabled: boolean;
  111114. /**
  111115. * Creates a new instance of the component for the given scene
  111116. * @param scene Defines the scene to register the component in
  111117. */
  111118. constructor(scene: Scene);
  111119. /**
  111120. * Registers the component in a given scene
  111121. */
  111122. register(): void;
  111123. /**
  111124. * Return the list of active meshes
  111125. * @returns the list of active meshes
  111126. */
  111127. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111128. /**
  111129. * Return the list of active sub meshes
  111130. * @param mesh The mesh to get the candidates sub meshes from
  111131. * @returns the list of active sub meshes
  111132. */
  111133. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111134. private _tempRay;
  111135. /**
  111136. * Return the list of sub meshes intersecting with a given local ray
  111137. * @param mesh defines the mesh to find the submesh for
  111138. * @param localRay defines the ray in local space
  111139. * @returns the list of intersecting sub meshes
  111140. */
  111141. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111142. /**
  111143. * Return the list of sub meshes colliding with a collider
  111144. * @param mesh defines the mesh to find the submesh for
  111145. * @param collider defines the collider to evaluate the collision against
  111146. * @returns the list of colliding sub meshes
  111147. */
  111148. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111149. /**
  111150. * Rebuilds the elements related to this component in case of
  111151. * context lost for instance.
  111152. */
  111153. rebuild(): void;
  111154. /**
  111155. * Disposes the component and the associated ressources.
  111156. */
  111157. dispose(): void;
  111158. }
  111159. }
  111160. declare module BABYLON {
  111161. /**
  111162. * Renders a layer on top of an existing scene
  111163. */
  111164. export class UtilityLayerRenderer implements IDisposable {
  111165. /** the original scene that will be rendered on top of */
  111166. originalScene: Scene;
  111167. private _pointerCaptures;
  111168. private _lastPointerEvents;
  111169. private static _DefaultUtilityLayer;
  111170. private static _DefaultKeepDepthUtilityLayer;
  111171. private _sharedGizmoLight;
  111172. private _renderCamera;
  111173. /**
  111174. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111175. * @returns the camera that is used when rendering the utility layer
  111176. */
  111177. getRenderCamera(): Nullable<Camera>;
  111178. /**
  111179. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111180. * @param cam the camera that should be used when rendering the utility layer
  111181. */
  111182. setRenderCamera(cam: Nullable<Camera>): void;
  111183. /**
  111184. * @hidden
  111185. * Light which used by gizmos to get light shading
  111186. */
  111187. _getSharedGizmoLight(): HemisphericLight;
  111188. /**
  111189. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111190. */
  111191. pickUtilitySceneFirst: boolean;
  111192. /**
  111193. * 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)
  111194. */
  111195. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111196. /**
  111197. * 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)
  111198. */
  111199. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111200. /**
  111201. * The scene that is rendered on top of the original scene
  111202. */
  111203. utilityLayerScene: Scene;
  111204. /**
  111205. * If the utility layer should automatically be rendered on top of existing scene
  111206. */
  111207. shouldRender: boolean;
  111208. /**
  111209. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111210. */
  111211. onlyCheckPointerDownEvents: boolean;
  111212. /**
  111213. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111214. */
  111215. processAllEvents: boolean;
  111216. /**
  111217. * Observable raised when the pointer move from the utility layer scene to the main scene
  111218. */
  111219. onPointerOutObservable: Observable<number>;
  111220. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111221. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111222. private _afterRenderObserver;
  111223. private _sceneDisposeObserver;
  111224. private _originalPointerObserver;
  111225. /**
  111226. * Instantiates a UtilityLayerRenderer
  111227. * @param originalScene the original scene that will be rendered on top of
  111228. * @param handleEvents boolean indicating if the utility layer should handle events
  111229. */
  111230. constructor(
  111231. /** the original scene that will be rendered on top of */
  111232. originalScene: Scene, handleEvents?: boolean);
  111233. private _notifyObservers;
  111234. /**
  111235. * Renders the utility layers scene on top of the original scene
  111236. */
  111237. render(): void;
  111238. /**
  111239. * Disposes of the renderer
  111240. */
  111241. dispose(): void;
  111242. private _updateCamera;
  111243. }
  111244. }
  111245. declare module BABYLON {
  111246. /**
  111247. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111248. */
  111249. export class Gizmo implements IDisposable {
  111250. /** The utility layer the gizmo will be added to */
  111251. gizmoLayer: UtilityLayerRenderer;
  111252. /**
  111253. * The root mesh of the gizmo
  111254. */
  111255. _rootMesh: Mesh;
  111256. private _attachedMesh;
  111257. /**
  111258. * Ratio for the scale of the gizmo (Default: 1)
  111259. */
  111260. scaleRatio: number;
  111261. /**
  111262. * If a custom mesh has been set (Default: false)
  111263. */
  111264. protected _customMeshSet: boolean;
  111265. /**
  111266. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111267. * * When set, interactions will be enabled
  111268. */
  111269. attachedMesh: Nullable<AbstractMesh>;
  111270. /**
  111271. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111272. * @param mesh The mesh to replace the default mesh of the gizmo
  111273. */
  111274. setCustomMesh(mesh: Mesh): void;
  111275. /**
  111276. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111277. */
  111278. updateGizmoRotationToMatchAttachedMesh: boolean;
  111279. /**
  111280. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111281. */
  111282. updateGizmoPositionToMatchAttachedMesh: boolean;
  111283. /**
  111284. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111285. */
  111286. updateScale: boolean;
  111287. protected _interactionsEnabled: boolean;
  111288. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111289. private _beforeRenderObserver;
  111290. private _tempVector;
  111291. /**
  111292. * Creates a gizmo
  111293. * @param gizmoLayer The utility layer the gizmo will be added to
  111294. */
  111295. constructor(
  111296. /** The utility layer the gizmo will be added to */
  111297. gizmoLayer?: UtilityLayerRenderer);
  111298. /**
  111299. * Updates the gizmo to match the attached mesh's position/rotation
  111300. */
  111301. protected _update(): void;
  111302. /**
  111303. * Disposes of the gizmo
  111304. */
  111305. dispose(): void;
  111306. }
  111307. }
  111308. declare module BABYLON {
  111309. /**
  111310. * Single plane drag gizmo
  111311. */
  111312. export class PlaneDragGizmo extends Gizmo {
  111313. /**
  111314. * Drag behavior responsible for the gizmos dragging interactions
  111315. */
  111316. dragBehavior: PointerDragBehavior;
  111317. private _pointerObserver;
  111318. /**
  111319. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111320. */
  111321. snapDistance: number;
  111322. /**
  111323. * Event that fires each time the gizmo snaps to a new location.
  111324. * * snapDistance is the the change in distance
  111325. */
  111326. onSnapObservable: Observable<{
  111327. snapDistance: number;
  111328. }>;
  111329. private _plane;
  111330. private _coloredMaterial;
  111331. private _hoverMaterial;
  111332. private _isEnabled;
  111333. private _parent;
  111334. /** @hidden */
  111335. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111336. /** @hidden */
  111337. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111338. /**
  111339. * Creates a PlaneDragGizmo
  111340. * @param gizmoLayer The utility layer the gizmo will be added to
  111341. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111342. * @param color The color of the gizmo
  111343. */
  111344. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111345. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111346. /**
  111347. * If the gizmo is enabled
  111348. */
  111349. isEnabled: boolean;
  111350. /**
  111351. * Disposes of the gizmo
  111352. */
  111353. dispose(): void;
  111354. }
  111355. }
  111356. declare module BABYLON {
  111357. /**
  111358. * Gizmo that enables dragging a mesh along 3 axis
  111359. */
  111360. export class PositionGizmo extends Gizmo {
  111361. /**
  111362. * Internal gizmo used for interactions on the x axis
  111363. */
  111364. xGizmo: AxisDragGizmo;
  111365. /**
  111366. * Internal gizmo used for interactions on the y axis
  111367. */
  111368. yGizmo: AxisDragGizmo;
  111369. /**
  111370. * Internal gizmo used for interactions on the z axis
  111371. */
  111372. zGizmo: AxisDragGizmo;
  111373. /**
  111374. * Internal gizmo used for interactions on the yz plane
  111375. */
  111376. xPlaneGizmo: PlaneDragGizmo;
  111377. /**
  111378. * Internal gizmo used for interactions on the xz plane
  111379. */
  111380. yPlaneGizmo: PlaneDragGizmo;
  111381. /**
  111382. * Internal gizmo used for interactions on the xy plane
  111383. */
  111384. zPlaneGizmo: PlaneDragGizmo;
  111385. /**
  111386. * private variables
  111387. */
  111388. private _meshAttached;
  111389. private _updateGizmoRotationToMatchAttachedMesh;
  111390. private _snapDistance;
  111391. private _scaleRatio;
  111392. /** Fires an event when any of it's sub gizmos are dragged */
  111393. onDragStartObservable: Observable<unknown>;
  111394. /** Fires an event when any of it's sub gizmos are released from dragging */
  111395. onDragEndObservable: Observable<unknown>;
  111396. /**
  111397. * If set to true, planar drag is enabled
  111398. */
  111399. private _planarGizmoEnabled;
  111400. attachedMesh: Nullable<AbstractMesh>;
  111401. /**
  111402. * Creates a PositionGizmo
  111403. * @param gizmoLayer The utility layer the gizmo will be added to
  111404. */
  111405. constructor(gizmoLayer?: UtilityLayerRenderer);
  111406. /**
  111407. * If the planar drag gizmo is enabled
  111408. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111409. */
  111410. planarGizmoEnabled: boolean;
  111411. updateGizmoRotationToMatchAttachedMesh: boolean;
  111412. /**
  111413. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111414. */
  111415. snapDistance: number;
  111416. /**
  111417. * Ratio for the scale of the gizmo (Default: 1)
  111418. */
  111419. scaleRatio: number;
  111420. /**
  111421. * Disposes of the gizmo
  111422. */
  111423. dispose(): void;
  111424. /**
  111425. * CustomMeshes are not supported by this gizmo
  111426. * @param mesh The mesh to replace the default mesh of the gizmo
  111427. */
  111428. setCustomMesh(mesh: Mesh): void;
  111429. }
  111430. }
  111431. declare module BABYLON {
  111432. /**
  111433. * Single axis drag gizmo
  111434. */
  111435. export class AxisDragGizmo extends Gizmo {
  111436. /**
  111437. * Drag behavior responsible for the gizmos dragging interactions
  111438. */
  111439. dragBehavior: PointerDragBehavior;
  111440. private _pointerObserver;
  111441. /**
  111442. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111443. */
  111444. snapDistance: number;
  111445. /**
  111446. * Event that fires each time the gizmo snaps to a new location.
  111447. * * snapDistance is the the change in distance
  111448. */
  111449. onSnapObservable: Observable<{
  111450. snapDistance: number;
  111451. }>;
  111452. private _isEnabled;
  111453. private _parent;
  111454. private _arrow;
  111455. private _coloredMaterial;
  111456. private _hoverMaterial;
  111457. /** @hidden */
  111458. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111459. /** @hidden */
  111460. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111461. /**
  111462. * Creates an AxisDragGizmo
  111463. * @param gizmoLayer The utility layer the gizmo will be added to
  111464. * @param dragAxis The axis which the gizmo will be able to drag on
  111465. * @param color The color of the gizmo
  111466. */
  111467. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111468. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111469. /**
  111470. * If the gizmo is enabled
  111471. */
  111472. isEnabled: boolean;
  111473. /**
  111474. * Disposes of the gizmo
  111475. */
  111476. dispose(): void;
  111477. }
  111478. }
  111479. declare module BABYLON.Debug {
  111480. /**
  111481. * The Axes viewer will show 3 axes in a specific point in space
  111482. */
  111483. export class AxesViewer {
  111484. private _xAxis;
  111485. private _yAxis;
  111486. private _zAxis;
  111487. private _scaleLinesFactor;
  111488. private _instanced;
  111489. /**
  111490. * Gets the hosting scene
  111491. */
  111492. scene: Scene;
  111493. /**
  111494. * Gets or sets a number used to scale line length
  111495. */
  111496. scaleLines: number;
  111497. /** Gets the node hierarchy used to render x-axis */
  111498. readonly xAxis: TransformNode;
  111499. /** Gets the node hierarchy used to render y-axis */
  111500. readonly yAxis: TransformNode;
  111501. /** Gets the node hierarchy used to render z-axis */
  111502. readonly zAxis: TransformNode;
  111503. /**
  111504. * Creates a new AxesViewer
  111505. * @param scene defines the hosting scene
  111506. * @param scaleLines defines a number used to scale line length (1 by default)
  111507. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111508. * @param xAxis defines the node hierarchy used to render the x-axis
  111509. * @param yAxis defines the node hierarchy used to render the y-axis
  111510. * @param zAxis defines the node hierarchy used to render the z-axis
  111511. */
  111512. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111513. /**
  111514. * Force the viewer to update
  111515. * @param position defines the position of the viewer
  111516. * @param xaxis defines the x axis of the viewer
  111517. * @param yaxis defines the y axis of the viewer
  111518. * @param zaxis defines the z axis of the viewer
  111519. */
  111520. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111521. /**
  111522. * Creates an instance of this axes viewer.
  111523. * @returns a new axes viewer with instanced meshes
  111524. */
  111525. createInstance(): AxesViewer;
  111526. /** Releases resources */
  111527. dispose(): void;
  111528. private static _SetRenderingGroupId;
  111529. }
  111530. }
  111531. declare module BABYLON.Debug {
  111532. /**
  111533. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111534. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111535. */
  111536. export class BoneAxesViewer extends AxesViewer {
  111537. /**
  111538. * Gets or sets the target mesh where to display the axes viewer
  111539. */
  111540. mesh: Nullable<Mesh>;
  111541. /**
  111542. * Gets or sets the target bone where to display the axes viewer
  111543. */
  111544. bone: Nullable<Bone>;
  111545. /** Gets current position */
  111546. pos: Vector3;
  111547. /** Gets direction of X axis */
  111548. xaxis: Vector3;
  111549. /** Gets direction of Y axis */
  111550. yaxis: Vector3;
  111551. /** Gets direction of Z axis */
  111552. zaxis: Vector3;
  111553. /**
  111554. * Creates a new BoneAxesViewer
  111555. * @param scene defines the hosting scene
  111556. * @param bone defines the target bone
  111557. * @param mesh defines the target mesh
  111558. * @param scaleLines defines a scaling factor for line length (1 by default)
  111559. */
  111560. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111561. /**
  111562. * Force the viewer to update
  111563. */
  111564. update(): void;
  111565. /** Releases resources */
  111566. dispose(): void;
  111567. }
  111568. }
  111569. declare module BABYLON {
  111570. /**
  111571. * Interface used to define scene explorer extensibility option
  111572. */
  111573. export interface IExplorerExtensibilityOption {
  111574. /**
  111575. * Define the option label
  111576. */
  111577. label: string;
  111578. /**
  111579. * Defines the action to execute on click
  111580. */
  111581. action: (entity: any) => void;
  111582. }
  111583. /**
  111584. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111585. */
  111586. export interface IExplorerExtensibilityGroup {
  111587. /**
  111588. * Defines a predicate to test if a given type mut be extended
  111589. */
  111590. predicate: (entity: any) => boolean;
  111591. /**
  111592. * Gets the list of options added to a type
  111593. */
  111594. entries: IExplorerExtensibilityOption[];
  111595. }
  111596. /**
  111597. * Interface used to define the options to use to create the Inspector
  111598. */
  111599. export interface IInspectorOptions {
  111600. /**
  111601. * Display in overlay mode (default: false)
  111602. */
  111603. overlay?: boolean;
  111604. /**
  111605. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111606. */
  111607. globalRoot?: HTMLElement;
  111608. /**
  111609. * Display the Scene explorer
  111610. */
  111611. showExplorer?: boolean;
  111612. /**
  111613. * Display the property inspector
  111614. */
  111615. showInspector?: boolean;
  111616. /**
  111617. * Display in embed mode (both panes on the right)
  111618. */
  111619. embedMode?: boolean;
  111620. /**
  111621. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111622. */
  111623. handleResize?: boolean;
  111624. /**
  111625. * Allow the panes to popup (default: true)
  111626. */
  111627. enablePopup?: boolean;
  111628. /**
  111629. * Allow the panes to be closed by users (default: true)
  111630. */
  111631. enableClose?: boolean;
  111632. /**
  111633. * Optional list of extensibility entries
  111634. */
  111635. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111636. /**
  111637. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111638. */
  111639. inspectorURL?: string;
  111640. }
  111641. interface Scene {
  111642. /**
  111643. * @hidden
  111644. * Backing field
  111645. */
  111646. _debugLayer: DebugLayer;
  111647. /**
  111648. * Gets the debug layer (aka Inspector) associated with the scene
  111649. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111650. */
  111651. debugLayer: DebugLayer;
  111652. }
  111653. /**
  111654. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111655. * what is happening in your scene
  111656. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111657. */
  111658. export class DebugLayer {
  111659. /**
  111660. * Define the url to get the inspector script from.
  111661. * By default it uses the babylonjs CDN.
  111662. * @ignoreNaming
  111663. */
  111664. static InspectorURL: string;
  111665. private _scene;
  111666. private BJSINSPECTOR;
  111667. private _onPropertyChangedObservable?;
  111668. /**
  111669. * Observable triggered when a property is changed through the inspector.
  111670. */
  111671. readonly onPropertyChangedObservable: any;
  111672. /**
  111673. * Instantiates a new debug layer.
  111674. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111675. * what is happening in your scene
  111676. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111677. * @param scene Defines the scene to inspect
  111678. */
  111679. constructor(scene: Scene);
  111680. /** Creates the inspector window. */
  111681. private _createInspector;
  111682. /**
  111683. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111684. * @param entity defines the entity to select
  111685. * @param lineContainerTitle defines the specific block to highlight
  111686. */
  111687. select(entity: any, lineContainerTitle?: string): void;
  111688. /** Get the inspector from bundle or global */
  111689. private _getGlobalInspector;
  111690. /**
  111691. * Get if the inspector is visible or not.
  111692. * @returns true if visible otherwise, false
  111693. */
  111694. isVisible(): boolean;
  111695. /**
  111696. * Hide the inspector and close its window.
  111697. */
  111698. hide(): void;
  111699. /**
  111700. * Launch the debugLayer.
  111701. * @param config Define the configuration of the inspector
  111702. * @return a promise fulfilled when the debug layer is visible
  111703. */
  111704. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. /**
  111709. * Class containing static functions to help procedurally build meshes
  111710. */
  111711. export class BoxBuilder {
  111712. /**
  111713. * Creates a box mesh
  111714. * * The parameter `size` sets the size (float) of each box side (default 1)
  111715. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111716. * * 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)
  111717. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111721. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111722. * @param name defines the name of the mesh
  111723. * @param options defines the options used to create the mesh
  111724. * @param scene defines the hosting scene
  111725. * @returns the box mesh
  111726. */
  111727. static CreateBox(name: string, options: {
  111728. size?: number;
  111729. width?: number;
  111730. height?: number;
  111731. depth?: number;
  111732. faceUV?: Vector4[];
  111733. faceColors?: Color4[];
  111734. sideOrientation?: number;
  111735. frontUVs?: Vector4;
  111736. backUVs?: Vector4;
  111737. wrap?: boolean;
  111738. topBaseAt?: number;
  111739. bottomBaseAt?: number;
  111740. updatable?: boolean;
  111741. }, scene?: Nullable<Scene>): Mesh;
  111742. }
  111743. }
  111744. declare module BABYLON {
  111745. /**
  111746. * Class containing static functions to help procedurally build meshes
  111747. */
  111748. export class SphereBuilder {
  111749. /**
  111750. * Creates a sphere mesh
  111751. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111752. * * 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`)
  111753. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111754. * * 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
  111755. * * 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)
  111756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111759. * @param name defines the name of the mesh
  111760. * @param options defines the options used to create the mesh
  111761. * @param scene defines the hosting scene
  111762. * @returns the sphere mesh
  111763. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111764. */
  111765. static CreateSphere(name: string, options: {
  111766. segments?: number;
  111767. diameter?: number;
  111768. diameterX?: number;
  111769. diameterY?: number;
  111770. diameterZ?: number;
  111771. arc?: number;
  111772. slice?: number;
  111773. sideOrientation?: number;
  111774. frontUVs?: Vector4;
  111775. backUVs?: Vector4;
  111776. updatable?: boolean;
  111777. }, scene?: Nullable<Scene>): Mesh;
  111778. }
  111779. }
  111780. declare module BABYLON.Debug {
  111781. /**
  111782. * Used to show the physics impostor around the specific mesh
  111783. */
  111784. export class PhysicsViewer {
  111785. /** @hidden */
  111786. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111787. /** @hidden */
  111788. protected _meshes: Array<Nullable<AbstractMesh>>;
  111789. /** @hidden */
  111790. protected _scene: Nullable<Scene>;
  111791. /** @hidden */
  111792. protected _numMeshes: number;
  111793. /** @hidden */
  111794. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111795. private _renderFunction;
  111796. private _utilityLayer;
  111797. private _debugBoxMesh;
  111798. private _debugSphereMesh;
  111799. private _debugCylinderMesh;
  111800. private _debugMaterial;
  111801. private _debugMeshMeshes;
  111802. /**
  111803. * Creates a new PhysicsViewer
  111804. * @param scene defines the hosting scene
  111805. */
  111806. constructor(scene: Scene);
  111807. /** @hidden */
  111808. protected _updateDebugMeshes(): void;
  111809. /**
  111810. * Renders a specified physic impostor
  111811. * @param impostor defines the impostor to render
  111812. * @param targetMesh defines the mesh represented by the impostor
  111813. * @returns the new debug mesh used to render the impostor
  111814. */
  111815. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111816. /**
  111817. * Hides a specified physic impostor
  111818. * @param impostor defines the impostor to hide
  111819. */
  111820. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111821. private _getDebugMaterial;
  111822. private _getDebugBoxMesh;
  111823. private _getDebugSphereMesh;
  111824. private _getDebugCylinderMesh;
  111825. private _getDebugMeshMesh;
  111826. private _getDebugMesh;
  111827. /** Releases all resources */
  111828. dispose(): void;
  111829. }
  111830. }
  111831. declare module BABYLON {
  111832. /**
  111833. * Class containing static functions to help procedurally build meshes
  111834. */
  111835. export class LinesBuilder {
  111836. /**
  111837. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111838. * * 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
  111839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111840. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111841. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111842. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111843. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111844. * * 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
  111845. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111848. * @param name defines the name of the new line system
  111849. * @param options defines the options used to create the line system
  111850. * @param scene defines the hosting scene
  111851. * @returns a new line system mesh
  111852. */
  111853. static CreateLineSystem(name: string, options: {
  111854. lines: Vector3[][];
  111855. updatable?: boolean;
  111856. instance?: Nullable<LinesMesh>;
  111857. colors?: Nullable<Color4[][]>;
  111858. useVertexAlpha?: boolean;
  111859. }, scene: Nullable<Scene>): LinesMesh;
  111860. /**
  111861. * Creates a line mesh
  111862. * 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
  111863. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111864. * * The parameter `points` is an array successive Vector3
  111865. * * 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
  111866. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111867. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111868. * * When updating an instance, remember that only point positions can change, not the number of points
  111869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111871. * @param name defines the name of the new line system
  111872. * @param options defines the options used to create the line system
  111873. * @param scene defines the hosting scene
  111874. * @returns a new line mesh
  111875. */
  111876. static CreateLines(name: string, options: {
  111877. points: Vector3[];
  111878. updatable?: boolean;
  111879. instance?: Nullable<LinesMesh>;
  111880. colors?: Color4[];
  111881. useVertexAlpha?: boolean;
  111882. }, scene?: Nullable<Scene>): LinesMesh;
  111883. /**
  111884. * Creates a dashed line mesh
  111885. * * 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
  111886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111887. * * The parameter `points` is an array successive Vector3
  111888. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111889. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111890. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111891. * * 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
  111892. * * When updating an instance, remember that only point positions can change, not the number of points
  111893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111894. * @param name defines the name of the mesh
  111895. * @param options defines the options used to create the mesh
  111896. * @param scene defines the hosting scene
  111897. * @returns the dashed line mesh
  111898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111899. */
  111900. static CreateDashedLines(name: string, options: {
  111901. points: Vector3[];
  111902. dashSize?: number;
  111903. gapSize?: number;
  111904. dashNb?: number;
  111905. updatable?: boolean;
  111906. instance?: LinesMesh;
  111907. }, scene?: Nullable<Scene>): LinesMesh;
  111908. }
  111909. }
  111910. declare module BABYLON {
  111911. /**
  111912. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111913. * in order to better appreciate the issue one might have.
  111914. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111915. */
  111916. export class RayHelper {
  111917. /**
  111918. * Defines the ray we are currently tryin to visualize.
  111919. */
  111920. ray: Nullable<Ray>;
  111921. private _renderPoints;
  111922. private _renderLine;
  111923. private _renderFunction;
  111924. private _scene;
  111925. private _updateToMeshFunction;
  111926. private _attachedToMesh;
  111927. private _meshSpaceDirection;
  111928. private _meshSpaceOrigin;
  111929. /**
  111930. * Helper function to create a colored helper in a scene in one line.
  111931. * @param ray Defines the ray we are currently tryin to visualize
  111932. * @param scene Defines the scene the ray is used in
  111933. * @param color Defines the color we want to see the ray in
  111934. * @returns The newly created ray helper.
  111935. */
  111936. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111937. /**
  111938. * Instantiate a new ray helper.
  111939. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111940. * in order to better appreciate the issue one might have.
  111941. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111942. * @param ray Defines the ray we are currently tryin to visualize
  111943. */
  111944. constructor(ray: Ray);
  111945. /**
  111946. * Shows the ray we are willing to debug.
  111947. * @param scene Defines the scene the ray needs to be rendered in
  111948. * @param color Defines the color the ray needs to be rendered in
  111949. */
  111950. show(scene: Scene, color?: Color3): void;
  111951. /**
  111952. * Hides the ray we are debugging.
  111953. */
  111954. hide(): void;
  111955. private _render;
  111956. /**
  111957. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111958. * @param mesh Defines the mesh we want the helper attached to
  111959. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111960. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111961. * @param length Defines the length of the ray
  111962. */
  111963. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111964. /**
  111965. * Detach the ray helper from the mesh it has previously been attached to.
  111966. */
  111967. detachFromMesh(): void;
  111968. private _updateToMesh;
  111969. /**
  111970. * Dispose the helper and release its associated resources.
  111971. */
  111972. dispose(): void;
  111973. }
  111974. }
  111975. declare module BABYLON.Debug {
  111976. /**
  111977. * Class used to render a debug view of a given skeleton
  111978. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111979. */
  111980. export class SkeletonViewer {
  111981. /** defines the skeleton to render */
  111982. skeleton: Skeleton;
  111983. /** defines the mesh attached to the skeleton */
  111984. mesh: AbstractMesh;
  111985. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111986. autoUpdateBonesMatrices: boolean;
  111987. /** defines the rendering group id to use with the viewer */
  111988. renderingGroupId: number;
  111989. /** Gets or sets the color used to render the skeleton */
  111990. color: Color3;
  111991. private _scene;
  111992. private _debugLines;
  111993. private _debugMesh;
  111994. private _isEnabled;
  111995. private _renderFunction;
  111996. private _utilityLayer;
  111997. /**
  111998. * Returns the mesh used to render the bones
  111999. */
  112000. readonly debugMesh: Nullable<LinesMesh>;
  112001. /**
  112002. * Creates a new SkeletonViewer
  112003. * @param skeleton defines the skeleton to render
  112004. * @param mesh defines the mesh attached to the skeleton
  112005. * @param scene defines the hosting scene
  112006. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112007. * @param renderingGroupId defines the rendering group id to use with the viewer
  112008. */
  112009. constructor(
  112010. /** defines the skeleton to render */
  112011. skeleton: Skeleton,
  112012. /** defines the mesh attached to the skeleton */
  112013. mesh: AbstractMesh, scene: Scene,
  112014. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112015. autoUpdateBonesMatrices?: boolean,
  112016. /** defines the rendering group id to use with the viewer */
  112017. renderingGroupId?: number);
  112018. /** Gets or sets a boolean indicating if the viewer is enabled */
  112019. isEnabled: boolean;
  112020. private _getBonePosition;
  112021. private _getLinesForBonesWithLength;
  112022. private _getLinesForBonesNoLength;
  112023. /** Update the viewer to sync with current skeleton state */
  112024. update(): void;
  112025. /** Release associated resources */
  112026. dispose(): void;
  112027. }
  112028. }
  112029. declare module BABYLON {
  112030. /**
  112031. * Options to create the null engine
  112032. */
  112033. export class NullEngineOptions {
  112034. /**
  112035. * Render width (Default: 512)
  112036. */
  112037. renderWidth: number;
  112038. /**
  112039. * Render height (Default: 256)
  112040. */
  112041. renderHeight: number;
  112042. /**
  112043. * Texture size (Default: 512)
  112044. */
  112045. textureSize: number;
  112046. /**
  112047. * If delta time between frames should be constant
  112048. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112049. */
  112050. deterministicLockstep: boolean;
  112051. /**
  112052. * Maximum about of steps between frames (Default: 4)
  112053. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112054. */
  112055. lockstepMaxSteps: number;
  112056. }
  112057. /**
  112058. * The null engine class provides support for headless version of babylon.js.
  112059. * This can be used in server side scenario or for testing purposes
  112060. */
  112061. export class NullEngine extends Engine {
  112062. private _options;
  112063. /**
  112064. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112066. * @returns true if engine is in deterministic lock step mode
  112067. */
  112068. isDeterministicLockStep(): boolean;
  112069. /**
  112070. * Gets the max steps when engine is running in deterministic lock step
  112071. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112072. * @returns the max steps
  112073. */
  112074. getLockstepMaxSteps(): number;
  112075. /**
  112076. * Gets the current hardware scaling level.
  112077. * By default the hardware scaling level is computed from the window device ratio.
  112078. * 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.
  112079. * @returns a number indicating the current hardware scaling level
  112080. */
  112081. getHardwareScalingLevel(): number;
  112082. constructor(options?: NullEngineOptions);
  112083. /**
  112084. * Creates a vertex buffer
  112085. * @param vertices the data for the vertex buffer
  112086. * @returns the new WebGL static buffer
  112087. */
  112088. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112089. /**
  112090. * Creates a new index buffer
  112091. * @param indices defines the content of the index buffer
  112092. * @param updatable defines if the index buffer must be updatable
  112093. * @returns a new webGL buffer
  112094. */
  112095. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112096. /**
  112097. * Clear the current render buffer or the current render target (if any is set up)
  112098. * @param color defines the color to use
  112099. * @param backBuffer defines if the back buffer must be cleared
  112100. * @param depth defines if the depth buffer must be cleared
  112101. * @param stencil defines if the stencil buffer must be cleared
  112102. */
  112103. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112104. /**
  112105. * Gets the current render width
  112106. * @param useScreen defines if screen size must be used (or the current render target if any)
  112107. * @returns a number defining the current render width
  112108. */
  112109. getRenderWidth(useScreen?: boolean): number;
  112110. /**
  112111. * Gets the current render height
  112112. * @param useScreen defines if screen size must be used (or the current render target if any)
  112113. * @returns a number defining the current render height
  112114. */
  112115. getRenderHeight(useScreen?: boolean): number;
  112116. /**
  112117. * Set the WebGL's viewport
  112118. * @param viewport defines the viewport element to be used
  112119. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112120. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112121. */
  112122. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112123. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112124. /**
  112125. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112126. * @param pipelineContext defines the pipeline context to use
  112127. * @param uniformsNames defines the list of uniform names
  112128. * @returns an array of webGL uniform locations
  112129. */
  112130. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112131. /**
  112132. * Gets the lsit of active attributes for a given webGL program
  112133. * @param pipelineContext defines the pipeline context to use
  112134. * @param attributesNames defines the list of attribute names to get
  112135. * @returns an array of indices indicating the offset of each attribute
  112136. */
  112137. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112138. /**
  112139. * Binds an effect to the webGL context
  112140. * @param effect defines the effect to bind
  112141. */
  112142. bindSamplers(effect: Effect): void;
  112143. /**
  112144. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112145. * @param effect defines the effect to activate
  112146. */
  112147. enableEffect(effect: Effect): void;
  112148. /**
  112149. * Set various states to the webGL context
  112150. * @param culling defines backface culling state
  112151. * @param zOffset defines the value to apply to zOffset (0 by default)
  112152. * @param force defines if states must be applied even if cache is up to date
  112153. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112154. */
  112155. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112156. /**
  112157. * Set the value of an uniform to an array of int32
  112158. * @param uniform defines the webGL uniform location where to store the value
  112159. * @param array defines the array of int32 to store
  112160. */
  112161. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112162. /**
  112163. * Set the value of an uniform to an array of int32 (stored as vec2)
  112164. * @param uniform defines the webGL uniform location where to store the value
  112165. * @param array defines the array of int32 to store
  112166. */
  112167. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112168. /**
  112169. * Set the value of an uniform to an array of int32 (stored as vec3)
  112170. * @param uniform defines the webGL uniform location where to store the value
  112171. * @param array defines the array of int32 to store
  112172. */
  112173. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112174. /**
  112175. * Set the value of an uniform to an array of int32 (stored as vec4)
  112176. * @param uniform defines the webGL uniform location where to store the value
  112177. * @param array defines the array of int32 to store
  112178. */
  112179. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112180. /**
  112181. * Set the value of an uniform to an array of float32
  112182. * @param uniform defines the webGL uniform location where to store the value
  112183. * @param array defines the array of float32 to store
  112184. */
  112185. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112186. /**
  112187. * Set the value of an uniform to an array of float32 (stored as vec2)
  112188. * @param uniform defines the webGL uniform location where to store the value
  112189. * @param array defines the array of float32 to store
  112190. */
  112191. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112192. /**
  112193. * Set the value of an uniform to an array of float32 (stored as vec3)
  112194. * @param uniform defines the webGL uniform location where to store the value
  112195. * @param array defines the array of float32 to store
  112196. */
  112197. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112198. /**
  112199. * Set the value of an uniform to an array of float32 (stored as vec4)
  112200. * @param uniform defines the webGL uniform location where to store the value
  112201. * @param array defines the array of float32 to store
  112202. */
  112203. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112204. /**
  112205. * Set the value of an uniform to an array of number
  112206. * @param uniform defines the webGL uniform location where to store the value
  112207. * @param array defines the array of number to store
  112208. */
  112209. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112210. /**
  112211. * Set the value of an uniform to an array of number (stored as vec2)
  112212. * @param uniform defines the webGL uniform location where to store the value
  112213. * @param array defines the array of number to store
  112214. */
  112215. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112216. /**
  112217. * Set the value of an uniform to an array of number (stored as vec3)
  112218. * @param uniform defines the webGL uniform location where to store the value
  112219. * @param array defines the array of number to store
  112220. */
  112221. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112222. /**
  112223. * Set the value of an uniform to an array of number (stored as vec4)
  112224. * @param uniform defines the webGL uniform location where to store the value
  112225. * @param array defines the array of number to store
  112226. */
  112227. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112228. /**
  112229. * Set the value of an uniform to an array of float32 (stored as matrices)
  112230. * @param uniform defines the webGL uniform location where to store the value
  112231. * @param matrices defines the array of float32 to store
  112232. */
  112233. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112234. /**
  112235. * Set the value of an uniform to a matrix (3x3)
  112236. * @param uniform defines the webGL uniform location where to store the value
  112237. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112238. */
  112239. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112240. /**
  112241. * Set the value of an uniform to a matrix (2x2)
  112242. * @param uniform defines the webGL uniform location where to store the value
  112243. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112244. */
  112245. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112246. /**
  112247. * Set the value of an uniform to a number (float)
  112248. * @param uniform defines the webGL uniform location where to store the value
  112249. * @param value defines the float number to store
  112250. */
  112251. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112252. /**
  112253. * Set the value of an uniform to a vec2
  112254. * @param uniform defines the webGL uniform location where to store the value
  112255. * @param x defines the 1st component of the value
  112256. * @param y defines the 2nd component of the value
  112257. */
  112258. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112259. /**
  112260. * Set the value of an uniform to a vec3
  112261. * @param uniform defines the webGL uniform location where to store the value
  112262. * @param x defines the 1st component of the value
  112263. * @param y defines the 2nd component of the value
  112264. * @param z defines the 3rd component of the value
  112265. */
  112266. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112267. /**
  112268. * Set the value of an uniform to a boolean
  112269. * @param uniform defines the webGL uniform location where to store the value
  112270. * @param bool defines the boolean to store
  112271. */
  112272. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112273. /**
  112274. * Set the value of an uniform to a vec4
  112275. * @param uniform defines the webGL uniform location where to store the value
  112276. * @param x defines the 1st component of the value
  112277. * @param y defines the 2nd component of the value
  112278. * @param z defines the 3rd component of the value
  112279. * @param w defines the 4th component of the value
  112280. */
  112281. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112282. /**
  112283. * Sets the current alpha mode
  112284. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112285. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112286. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112287. */
  112288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112289. /**
  112290. * Bind webGl buffers directly to the webGL context
  112291. * @param vertexBuffers defines the vertex buffer to bind
  112292. * @param indexBuffer defines the index buffer to bind
  112293. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112294. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112295. * @param effect defines the effect associated with the vertex buffer
  112296. */
  112297. bindBuffers(vertexBuffers: {
  112298. [key: string]: VertexBuffer;
  112299. }, indexBuffer: DataBuffer, effect: Effect): void;
  112300. /**
  112301. * Force the entire cache to be cleared
  112302. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112303. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112304. */
  112305. wipeCaches(bruteForce?: boolean): void;
  112306. /**
  112307. * Send a draw order
  112308. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112309. * @param indexStart defines the starting index
  112310. * @param indexCount defines the number of index to draw
  112311. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112312. */
  112313. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112314. /**
  112315. * Draw a list of indexed primitives
  112316. * @param fillMode defines the primitive to use
  112317. * @param indexStart defines the starting index
  112318. * @param indexCount defines the number of index to draw
  112319. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112320. */
  112321. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112322. /**
  112323. * Draw a list of unindexed primitives
  112324. * @param fillMode defines the primitive to use
  112325. * @param verticesStart defines the index of first vertex to draw
  112326. * @param verticesCount defines the count of vertices to draw
  112327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112328. */
  112329. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112330. /** @hidden */
  112331. _createTexture(): WebGLTexture;
  112332. /** @hidden */
  112333. _releaseTexture(texture: InternalTexture): void;
  112334. /**
  112335. * Usually called from Texture.ts.
  112336. * Passed information to create a WebGLTexture
  112337. * @param urlArg defines a value which contains one of the following:
  112338. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112339. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112340. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112341. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112342. * @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)
  112343. * @param scene needed for loading to the correct scene
  112344. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112345. * @param onLoad optional callback to be called upon successful completion
  112346. * @param onError optional callback to be called upon failure
  112347. * @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
  112348. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112349. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112350. * @param forcedExtension defines the extension to use to pick the right loader
  112351. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112352. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112353. */
  112354. 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;
  112355. /**
  112356. * Creates a new render target texture
  112357. * @param size defines the size of the texture
  112358. * @param options defines the options used to create the texture
  112359. * @returns a new render target texture stored in an InternalTexture
  112360. */
  112361. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112362. /**
  112363. * Update the sampling mode of a given texture
  112364. * @param samplingMode defines the required sampling mode
  112365. * @param texture defines the texture to update
  112366. */
  112367. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112368. /**
  112369. * Binds the frame buffer to the specified texture.
  112370. * @param texture The texture to render to or null for the default canvas
  112371. * @param faceIndex The face of the texture to render to in case of cube texture
  112372. * @param requiredWidth The width of the target to render to
  112373. * @param requiredHeight The height of the target to render to
  112374. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112375. * @param depthStencilTexture The depth stencil texture to use to render
  112376. * @param lodLevel defines le lod level to bind to the frame buffer
  112377. */
  112378. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112379. /**
  112380. * Unbind the current render target texture from the webGL context
  112381. * @param texture defines the render target texture to unbind
  112382. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112383. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112384. */
  112385. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112386. /**
  112387. * Creates a dynamic vertex buffer
  112388. * @param vertices the data for the dynamic vertex buffer
  112389. * @returns the new WebGL dynamic buffer
  112390. */
  112391. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112392. /**
  112393. * Update the content of a dynamic texture
  112394. * @param texture defines the texture to update
  112395. * @param canvas defines the canvas containing the source
  112396. * @param invertY defines if data must be stored with Y axis inverted
  112397. * @param premulAlpha defines if alpha is stored as premultiplied
  112398. * @param format defines the format of the data
  112399. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112400. */
  112401. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112402. /**
  112403. * Gets a boolean indicating if all created effects are ready
  112404. * @returns true if all effects are ready
  112405. */
  112406. areAllEffectsReady(): boolean;
  112407. /**
  112408. * @hidden
  112409. * Get the current error code of the webGL context
  112410. * @returns the error code
  112411. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112412. */
  112413. getError(): number;
  112414. /** @hidden */
  112415. _getUnpackAlignement(): number;
  112416. /** @hidden */
  112417. _unpackFlipY(value: boolean): void;
  112418. /**
  112419. * Update a dynamic index buffer
  112420. * @param indexBuffer defines the target index buffer
  112421. * @param indices defines the data to update
  112422. * @param offset defines the offset in the target index buffer where update should start
  112423. */
  112424. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112425. /**
  112426. * Updates a dynamic vertex buffer.
  112427. * @param vertexBuffer the vertex buffer to update
  112428. * @param vertices the data used to update the vertex buffer
  112429. * @param byteOffset the byte offset of the data (optional)
  112430. * @param byteLength the byte length of the data (optional)
  112431. */
  112432. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112433. /** @hidden */
  112434. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112435. /** @hidden */
  112436. _bindTexture(channel: number, texture: InternalTexture): void;
  112437. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112438. /**
  112439. * 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
  112440. */
  112441. releaseEffects(): void;
  112442. displayLoadingUI(): void;
  112443. hideLoadingUI(): void;
  112444. /** @hidden */
  112445. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112446. /** @hidden */
  112447. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112448. /** @hidden */
  112449. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112450. /** @hidden */
  112451. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112452. }
  112453. }
  112454. declare module BABYLON {
  112455. /** @hidden */
  112456. export class _OcclusionDataStorage {
  112457. /** @hidden */
  112458. occlusionInternalRetryCounter: number;
  112459. /** @hidden */
  112460. isOcclusionQueryInProgress: boolean;
  112461. /** @hidden */
  112462. isOccluded: boolean;
  112463. /** @hidden */
  112464. occlusionRetryCount: number;
  112465. /** @hidden */
  112466. occlusionType: number;
  112467. /** @hidden */
  112468. occlusionQueryAlgorithmType: number;
  112469. }
  112470. interface Engine {
  112471. /**
  112472. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112473. * @return the new query
  112474. */
  112475. createQuery(): WebGLQuery;
  112476. /**
  112477. * Delete and release a webGL query
  112478. * @param query defines the query to delete
  112479. * @return the current engine
  112480. */
  112481. deleteQuery(query: WebGLQuery): Engine;
  112482. /**
  112483. * Check if a given query has resolved and got its value
  112484. * @param query defines the query to check
  112485. * @returns true if the query got its value
  112486. */
  112487. isQueryResultAvailable(query: WebGLQuery): boolean;
  112488. /**
  112489. * Gets the value of a given query
  112490. * @param query defines the query to check
  112491. * @returns the value of the query
  112492. */
  112493. getQueryResult(query: WebGLQuery): number;
  112494. /**
  112495. * Initiates an occlusion query
  112496. * @param algorithmType defines the algorithm to use
  112497. * @param query defines the query to use
  112498. * @returns the current engine
  112499. * @see http://doc.babylonjs.com/features/occlusionquery
  112500. */
  112501. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112502. /**
  112503. * Ends an occlusion query
  112504. * @see http://doc.babylonjs.com/features/occlusionquery
  112505. * @param algorithmType defines the algorithm to use
  112506. * @returns the current engine
  112507. */
  112508. endOcclusionQuery(algorithmType: number): Engine;
  112509. /**
  112510. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112511. * Please note that only one query can be issued at a time
  112512. * @returns a time token used to track the time span
  112513. */
  112514. startTimeQuery(): Nullable<_TimeToken>;
  112515. /**
  112516. * Ends a time query
  112517. * @param token defines the token used to measure the time span
  112518. * @returns the time spent (in ns)
  112519. */
  112520. endTimeQuery(token: _TimeToken): int;
  112521. /** @hidden */
  112522. _currentNonTimestampToken: Nullable<_TimeToken>;
  112523. /** @hidden */
  112524. _createTimeQuery(): WebGLQuery;
  112525. /** @hidden */
  112526. _deleteTimeQuery(query: WebGLQuery): void;
  112527. /** @hidden */
  112528. _getGlAlgorithmType(algorithmType: number): number;
  112529. /** @hidden */
  112530. _getTimeQueryResult(query: WebGLQuery): any;
  112531. /** @hidden */
  112532. _getTimeQueryAvailability(query: WebGLQuery): any;
  112533. }
  112534. interface AbstractMesh {
  112535. /**
  112536. * Backing filed
  112537. * @hidden
  112538. */
  112539. __occlusionDataStorage: _OcclusionDataStorage;
  112540. /**
  112541. * Access property
  112542. * @hidden
  112543. */
  112544. _occlusionDataStorage: _OcclusionDataStorage;
  112545. /**
  112546. * 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.
  112547. * The default value is -1 which means don't break the query and wait till the result
  112548. * @see http://doc.babylonjs.com/features/occlusionquery
  112549. */
  112550. occlusionRetryCount: number;
  112551. /**
  112552. * 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:
  112553. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112554. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112555. * * 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.
  112556. * @see http://doc.babylonjs.com/features/occlusionquery
  112557. */
  112558. occlusionType: number;
  112559. /**
  112560. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112561. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112562. * * 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.
  112563. * @see http://doc.babylonjs.com/features/occlusionquery
  112564. */
  112565. occlusionQueryAlgorithmType: number;
  112566. /**
  112567. * 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
  112568. * @see http://doc.babylonjs.com/features/occlusionquery
  112569. */
  112570. isOccluded: boolean;
  112571. /**
  112572. * Flag to check the progress status of the query
  112573. * @see http://doc.babylonjs.com/features/occlusionquery
  112574. */
  112575. isOcclusionQueryInProgress: boolean;
  112576. }
  112577. }
  112578. declare module BABYLON {
  112579. /** @hidden */
  112580. export var _forceTransformFeedbackToBundle: boolean;
  112581. interface Engine {
  112582. /**
  112583. * Creates a webGL transform feedback object
  112584. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112585. * @returns the webGL transform feedback object
  112586. */
  112587. createTransformFeedback(): WebGLTransformFeedback;
  112588. /**
  112589. * Delete a webGL transform feedback object
  112590. * @param value defines the webGL transform feedback object to delete
  112591. */
  112592. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112593. /**
  112594. * Bind a webGL transform feedback object to the webgl context
  112595. * @param value defines the webGL transform feedback object to bind
  112596. */
  112597. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112598. /**
  112599. * Begins a transform feedback operation
  112600. * @param usePoints defines if points or triangles must be used
  112601. */
  112602. beginTransformFeedback(usePoints: boolean): void;
  112603. /**
  112604. * Ends a transform feedback operation
  112605. */
  112606. endTransformFeedback(): void;
  112607. /**
  112608. * Specify the varyings to use with transform feedback
  112609. * @param program defines the associated webGL program
  112610. * @param value defines the list of strings representing the varying names
  112611. */
  112612. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112613. /**
  112614. * Bind a webGL buffer for a transform feedback operation
  112615. * @param value defines the webGL buffer to bind
  112616. */
  112617. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112618. }
  112619. }
  112620. declare module BABYLON {
  112621. /**
  112622. * Creation options of the multi render target texture.
  112623. */
  112624. export interface IMultiRenderTargetOptions {
  112625. /**
  112626. * Define if the texture needs to create mip maps after render.
  112627. */
  112628. generateMipMaps?: boolean;
  112629. /**
  112630. * Define the types of all the draw buffers we want to create
  112631. */
  112632. types?: number[];
  112633. /**
  112634. * Define the sampling modes of all the draw buffers we want to create
  112635. */
  112636. samplingModes?: number[];
  112637. /**
  112638. * Define if a depth buffer is required
  112639. */
  112640. generateDepthBuffer?: boolean;
  112641. /**
  112642. * Define if a stencil buffer is required
  112643. */
  112644. generateStencilBuffer?: boolean;
  112645. /**
  112646. * Define if a depth texture is required instead of a depth buffer
  112647. */
  112648. generateDepthTexture?: boolean;
  112649. /**
  112650. * Define the number of desired draw buffers
  112651. */
  112652. textureCount?: number;
  112653. /**
  112654. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112655. */
  112656. doNotChangeAspectRatio?: boolean;
  112657. /**
  112658. * Define the default type of the buffers we are creating
  112659. */
  112660. defaultType?: number;
  112661. }
  112662. /**
  112663. * A multi render target, like a render target provides the ability to render to a texture.
  112664. * Unlike the render target, it can render to several draw buffers in one draw.
  112665. * This is specially interesting in deferred rendering or for any effects requiring more than
  112666. * just one color from a single pass.
  112667. */
  112668. export class MultiRenderTarget extends RenderTargetTexture {
  112669. private _internalTextures;
  112670. private _textures;
  112671. private _multiRenderTargetOptions;
  112672. /**
  112673. * Get if draw buffers are currently supported by the used hardware and browser.
  112674. */
  112675. readonly isSupported: boolean;
  112676. /**
  112677. * Get the list of textures generated by the multi render target.
  112678. */
  112679. readonly textures: Texture[];
  112680. /**
  112681. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112682. */
  112683. readonly depthTexture: Texture;
  112684. /**
  112685. * Set the wrapping mode on U of all the textures we are rendering to.
  112686. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112687. */
  112688. wrapU: number;
  112689. /**
  112690. * Set the wrapping mode on V of all the textures we are rendering to.
  112691. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112692. */
  112693. wrapV: number;
  112694. /**
  112695. * Instantiate a new multi render target texture.
  112696. * A multi render target, like a render target provides the ability to render to a texture.
  112697. * Unlike the render target, it can render to several draw buffers in one draw.
  112698. * This is specially interesting in deferred rendering or for any effects requiring more than
  112699. * just one color from a single pass.
  112700. * @param name Define the name of the texture
  112701. * @param size Define the size of the buffers to render to
  112702. * @param count Define the number of target we are rendering into
  112703. * @param scene Define the scene the texture belongs to
  112704. * @param options Define the options used to create the multi render target
  112705. */
  112706. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112707. /** @hidden */
  112708. _rebuild(): void;
  112709. private _createInternalTextures;
  112710. private _createTextures;
  112711. /**
  112712. * Define the number of samples used if MSAA is enabled.
  112713. */
  112714. samples: number;
  112715. /**
  112716. * Resize all the textures in the multi render target.
  112717. * Be carrefull as it will recreate all the data in the new texture.
  112718. * @param size Define the new size
  112719. */
  112720. resize(size: any): void;
  112721. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112722. /**
  112723. * Dispose the render targets and their associated resources
  112724. */
  112725. dispose(): void;
  112726. /**
  112727. * Release all the underlying texture used as draw buffers.
  112728. */
  112729. releaseInternalTextures(): void;
  112730. }
  112731. }
  112732. declare module BABYLON {
  112733. interface ThinEngine {
  112734. /**
  112735. * Unbind a list of render target textures from the webGL context
  112736. * This is used only when drawBuffer extension or webGL2 are active
  112737. * @param textures defines the render target textures to unbind
  112738. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112739. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112740. */
  112741. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112742. /**
  112743. * Create a multi render target texture
  112744. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112745. * @param size defines the size of the texture
  112746. * @param options defines the creation options
  112747. * @returns the cube texture as an InternalTexture
  112748. */
  112749. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112750. /**
  112751. * Update the sample count for a given multiple render target texture
  112752. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112753. * @param textures defines the textures to update
  112754. * @param samples defines the sample count to set
  112755. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112756. */
  112757. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112758. }
  112759. }
  112760. declare module BABYLON {
  112761. /**
  112762. * Class used to define an additional view for the engine
  112763. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112764. */
  112765. export class EngineView {
  112766. /** Defines the canvas where to render the view */
  112767. target: HTMLCanvasElement;
  112768. /** Defines an optional camera used to render the view (will use active camera else) */
  112769. camera?: Camera;
  112770. }
  112771. interface Engine {
  112772. /**
  112773. * Gets or sets the HTML element to use for attaching events
  112774. */
  112775. inputElement: Nullable<HTMLElement>;
  112776. /**
  112777. * Gets the current engine view
  112778. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112779. */
  112780. activeView: Nullable<EngineView>;
  112781. /** Gets or sets the list of views */
  112782. views: EngineView[];
  112783. /**
  112784. * Register a new child canvas
  112785. * @param canvas defines the canvas to register
  112786. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  112787. * @returns the associated view
  112788. */
  112789. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  112790. /**
  112791. * Remove a registered child canvas
  112792. * @param canvas defines the canvas to remove
  112793. * @returns the current engine
  112794. */
  112795. unRegisterView(canvas: HTMLCanvasElement): Engine;
  112796. }
  112797. }
  112798. declare module BABYLON {
  112799. /**
  112800. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112801. */
  112802. export interface CubeMapInfo {
  112803. /**
  112804. * The pixel array for the front face.
  112805. * This is stored in format, left to right, up to down format.
  112806. */
  112807. front: Nullable<ArrayBufferView>;
  112808. /**
  112809. * The pixel array for the back face.
  112810. * This is stored in format, left to right, up to down format.
  112811. */
  112812. back: Nullable<ArrayBufferView>;
  112813. /**
  112814. * The pixel array for the left face.
  112815. * This is stored in format, left to right, up to down format.
  112816. */
  112817. left: Nullable<ArrayBufferView>;
  112818. /**
  112819. * The pixel array for the right face.
  112820. * This is stored in format, left to right, up to down format.
  112821. */
  112822. right: Nullable<ArrayBufferView>;
  112823. /**
  112824. * The pixel array for the up face.
  112825. * This is stored in format, left to right, up to down format.
  112826. */
  112827. up: Nullable<ArrayBufferView>;
  112828. /**
  112829. * The pixel array for the down face.
  112830. * This is stored in format, left to right, up to down format.
  112831. */
  112832. down: Nullable<ArrayBufferView>;
  112833. /**
  112834. * The size of the cubemap stored.
  112835. *
  112836. * Each faces will be size * size pixels.
  112837. */
  112838. size: number;
  112839. /**
  112840. * The format of the texture.
  112841. *
  112842. * RGBA, RGB.
  112843. */
  112844. format: number;
  112845. /**
  112846. * The type of the texture data.
  112847. *
  112848. * UNSIGNED_INT, FLOAT.
  112849. */
  112850. type: number;
  112851. /**
  112852. * Specifies whether the texture is in gamma space.
  112853. */
  112854. gammaSpace: boolean;
  112855. }
  112856. /**
  112857. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112858. */
  112859. export class PanoramaToCubeMapTools {
  112860. private static FACE_FRONT;
  112861. private static FACE_BACK;
  112862. private static FACE_RIGHT;
  112863. private static FACE_LEFT;
  112864. private static FACE_DOWN;
  112865. private static FACE_UP;
  112866. /**
  112867. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112868. *
  112869. * @param float32Array The source data.
  112870. * @param inputWidth The width of the input panorama.
  112871. * @param inputHeight The height of the input panorama.
  112872. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112873. * @return The cubemap data
  112874. */
  112875. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112876. private static CreateCubemapTexture;
  112877. private static CalcProjectionSpherical;
  112878. }
  112879. }
  112880. declare module BABYLON {
  112881. /**
  112882. * Helper class dealing with the extraction of spherical polynomial dataArray
  112883. * from a cube map.
  112884. */
  112885. export class CubeMapToSphericalPolynomialTools {
  112886. private static FileFaces;
  112887. /**
  112888. * Converts a texture to the according Spherical Polynomial data.
  112889. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112890. *
  112891. * @param texture The texture to extract the information from.
  112892. * @return The Spherical Polynomial data.
  112893. */
  112894. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112895. /**
  112896. * Converts a cubemap to the according Spherical Polynomial data.
  112897. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112898. *
  112899. * @param cubeInfo The Cube map to extract the information from.
  112900. * @return The Spherical Polynomial data.
  112901. */
  112902. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112903. }
  112904. }
  112905. declare module BABYLON {
  112906. interface BaseTexture {
  112907. /**
  112908. * Get the polynomial representation of the texture data.
  112909. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112910. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112911. */
  112912. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112913. }
  112914. }
  112915. declare module BABYLON {
  112916. /** @hidden */
  112917. export var rgbdEncodePixelShader: {
  112918. name: string;
  112919. shader: string;
  112920. };
  112921. }
  112922. declare module BABYLON {
  112923. /** @hidden */
  112924. export var rgbdDecodePixelShader: {
  112925. name: string;
  112926. shader: string;
  112927. };
  112928. }
  112929. declare module BABYLON {
  112930. /**
  112931. * Raw texture data and descriptor sufficient for WebGL texture upload
  112932. */
  112933. export interface EnvironmentTextureInfo {
  112934. /**
  112935. * Version of the environment map
  112936. */
  112937. version: number;
  112938. /**
  112939. * Width of image
  112940. */
  112941. width: number;
  112942. /**
  112943. * Irradiance information stored in the file.
  112944. */
  112945. irradiance: any;
  112946. /**
  112947. * Specular information stored in the file.
  112948. */
  112949. specular: any;
  112950. }
  112951. /**
  112952. * Defines One Image in the file. It requires only the position in the file
  112953. * as well as the length.
  112954. */
  112955. interface BufferImageData {
  112956. /**
  112957. * Length of the image data.
  112958. */
  112959. length: number;
  112960. /**
  112961. * Position of the data from the null terminator delimiting the end of the JSON.
  112962. */
  112963. position: number;
  112964. }
  112965. /**
  112966. * Defines the specular data enclosed in the file.
  112967. * This corresponds to the version 1 of the data.
  112968. */
  112969. export interface EnvironmentTextureSpecularInfoV1 {
  112970. /**
  112971. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112972. */
  112973. specularDataPosition?: number;
  112974. /**
  112975. * This contains all the images data needed to reconstruct the cubemap.
  112976. */
  112977. mipmaps: Array<BufferImageData>;
  112978. /**
  112979. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112980. */
  112981. lodGenerationScale: number;
  112982. }
  112983. /**
  112984. * Sets of helpers addressing the serialization and deserialization of environment texture
  112985. * stored in a BabylonJS env file.
  112986. * Those files are usually stored as .env files.
  112987. */
  112988. export class EnvironmentTextureTools {
  112989. /**
  112990. * Magic number identifying the env file.
  112991. */
  112992. private static _MagicBytes;
  112993. /**
  112994. * Gets the environment info from an env file.
  112995. * @param data The array buffer containing the .env bytes.
  112996. * @returns the environment file info (the json header) if successfully parsed.
  112997. */
  112998. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112999. /**
  113000. * Creates an environment texture from a loaded cube texture.
  113001. * @param texture defines the cube texture to convert in env file
  113002. * @return a promise containing the environment data if succesfull.
  113003. */
  113004. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113005. /**
  113006. * Creates a JSON representation of the spherical data.
  113007. * @param texture defines the texture containing the polynomials
  113008. * @return the JSON representation of the spherical info
  113009. */
  113010. private static _CreateEnvTextureIrradiance;
  113011. /**
  113012. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113013. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113014. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113015. * @return the views described by info providing access to the underlying buffer
  113016. */
  113017. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113018. /**
  113019. * Uploads the texture info contained in the env file to the GPU.
  113020. * @param texture defines the internal texture to upload to
  113021. * @param arrayBuffer defines the buffer cotaining the data to load
  113022. * @param info defines the texture info retrieved through the GetEnvInfo method
  113023. * @returns a promise
  113024. */
  113025. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113026. private static _OnImageReadyAsync;
  113027. /**
  113028. * Uploads the levels of image data to the GPU.
  113029. * @param texture defines the internal texture to upload to
  113030. * @param imageData defines the array buffer views of image data [mipmap][face]
  113031. * @returns a promise
  113032. */
  113033. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113034. /**
  113035. * Uploads spherical polynomials information to the texture.
  113036. * @param texture defines the texture we are trying to upload the information to
  113037. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113038. */
  113039. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113040. /** @hidden */
  113041. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113042. }
  113043. }
  113044. declare module BABYLON {
  113045. /**
  113046. * Contains position and normal vectors for a vertex
  113047. */
  113048. export class PositionNormalVertex {
  113049. /** the position of the vertex (defaut: 0,0,0) */
  113050. position: Vector3;
  113051. /** the normal of the vertex (defaut: 0,1,0) */
  113052. normal: Vector3;
  113053. /**
  113054. * Creates a PositionNormalVertex
  113055. * @param position the position of the vertex (defaut: 0,0,0)
  113056. * @param normal the normal of the vertex (defaut: 0,1,0)
  113057. */
  113058. constructor(
  113059. /** the position of the vertex (defaut: 0,0,0) */
  113060. position?: Vector3,
  113061. /** the normal of the vertex (defaut: 0,1,0) */
  113062. normal?: Vector3);
  113063. /**
  113064. * Clones the PositionNormalVertex
  113065. * @returns the cloned PositionNormalVertex
  113066. */
  113067. clone(): PositionNormalVertex;
  113068. }
  113069. /**
  113070. * Contains position, normal and uv vectors for a vertex
  113071. */
  113072. export class PositionNormalTextureVertex {
  113073. /** the position of the vertex (defaut: 0,0,0) */
  113074. position: Vector3;
  113075. /** the normal of the vertex (defaut: 0,1,0) */
  113076. normal: Vector3;
  113077. /** the uv of the vertex (default: 0,0) */
  113078. uv: Vector2;
  113079. /**
  113080. * Creates a PositionNormalTextureVertex
  113081. * @param position the position of the vertex (defaut: 0,0,0)
  113082. * @param normal the normal of the vertex (defaut: 0,1,0)
  113083. * @param uv the uv of the vertex (default: 0,0)
  113084. */
  113085. constructor(
  113086. /** the position of the vertex (defaut: 0,0,0) */
  113087. position?: Vector3,
  113088. /** the normal of the vertex (defaut: 0,1,0) */
  113089. normal?: Vector3,
  113090. /** the uv of the vertex (default: 0,0) */
  113091. uv?: Vector2);
  113092. /**
  113093. * Clones the PositionNormalTextureVertex
  113094. * @returns the cloned PositionNormalTextureVertex
  113095. */
  113096. clone(): PositionNormalTextureVertex;
  113097. }
  113098. }
  113099. declare module BABYLON {
  113100. /** @hidden */
  113101. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113102. private _genericAttributeLocation;
  113103. private _varyingLocationCount;
  113104. private _varyingLocationMap;
  113105. private _replacements;
  113106. private _textureCount;
  113107. private _uniforms;
  113108. lineProcessor(line: string): string;
  113109. attributeProcessor(attribute: string): string;
  113110. varyingProcessor(varying: string, isFragment: boolean): string;
  113111. uniformProcessor(uniform: string): string;
  113112. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113113. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113114. }
  113115. }
  113116. declare module BABYLON {
  113117. /**
  113118. * Container for accessors for natively-stored mesh data buffers.
  113119. */
  113120. class NativeDataBuffer extends DataBuffer {
  113121. /**
  113122. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113123. */
  113124. nativeIndexBuffer?: any;
  113125. /**
  113126. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113127. */
  113128. nativeVertexBuffer?: any;
  113129. }
  113130. /** @hidden */
  113131. class NativeTexture extends InternalTexture {
  113132. getInternalTexture(): InternalTexture;
  113133. getViewCount(): number;
  113134. }
  113135. /** @hidden */
  113136. export class NativeEngine extends Engine {
  113137. private readonly _native;
  113138. getHardwareScalingLevel(): number;
  113139. constructor();
  113140. /**
  113141. * Can be used to override the current requestAnimationFrame requester.
  113142. * @hidden
  113143. */
  113144. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113145. /**
  113146. * Override default engine behavior.
  113147. * @param color
  113148. * @param backBuffer
  113149. * @param depth
  113150. * @param stencil
  113151. */
  113152. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113153. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113154. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113155. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113156. recordVertexArrayObject(vertexBuffers: {
  113157. [key: string]: VertexBuffer;
  113158. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113159. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113160. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113161. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113162. /**
  113163. * Draw a list of indexed primitives
  113164. * @param fillMode defines the primitive to use
  113165. * @param indexStart defines the starting index
  113166. * @param indexCount defines the number of index to draw
  113167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113168. */
  113169. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113170. /**
  113171. * Draw a list of unindexed primitives
  113172. * @param fillMode defines the primitive to use
  113173. * @param verticesStart defines the index of first vertex to draw
  113174. * @param verticesCount defines the count of vertices to draw
  113175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113176. */
  113177. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113178. createPipelineContext(): IPipelineContext;
  113179. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113180. /** @hidden */
  113181. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113182. /** @hidden */
  113183. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113184. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113185. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113186. protected _setProgram(program: WebGLProgram): void;
  113187. _releaseEffect(effect: Effect): void;
  113188. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113190. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113191. bindSamplers(effect: Effect): void;
  113192. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113193. getRenderWidth(useScreen?: boolean): number;
  113194. getRenderHeight(useScreen?: boolean): number;
  113195. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113196. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113197. /**
  113198. * Set the z offset to apply to current rendering
  113199. * @param value defines the offset to apply
  113200. */
  113201. setZOffset(value: number): void;
  113202. /**
  113203. * Gets the current value of the zOffset
  113204. * @returns the current zOffset state
  113205. */
  113206. getZOffset(): number;
  113207. /**
  113208. * Enable or disable depth buffering
  113209. * @param enable defines the state to set
  113210. */
  113211. setDepthBuffer(enable: boolean): void;
  113212. /**
  113213. * Gets a boolean indicating if depth writing is enabled
  113214. * @returns the current depth writing state
  113215. */
  113216. getDepthWrite(): boolean;
  113217. /**
  113218. * Enable or disable depth writing
  113219. * @param enable defines the state to set
  113220. */
  113221. setDepthWrite(enable: boolean): void;
  113222. /**
  113223. * Enable or disable color writing
  113224. * @param enable defines the state to set
  113225. */
  113226. setColorWrite(enable: boolean): void;
  113227. /**
  113228. * Gets a boolean indicating if color writing is enabled
  113229. * @returns the current color writing state
  113230. */
  113231. getColorWrite(): boolean;
  113232. /**
  113233. * Sets alpha constants used by some alpha blending modes
  113234. * @param r defines the red component
  113235. * @param g defines the green component
  113236. * @param b defines the blue component
  113237. * @param a defines the alpha component
  113238. */
  113239. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113240. /**
  113241. * Sets the current alpha mode
  113242. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113243. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113244. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113245. */
  113246. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113247. /**
  113248. * Gets the current alpha mode
  113249. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113250. * @returns the current alpha mode
  113251. */
  113252. getAlphaMode(): number;
  113253. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113254. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113255. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113256. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113257. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113258. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113259. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113260. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113261. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113262. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113263. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113264. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113265. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113266. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113267. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113268. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113269. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113270. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113271. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113272. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113273. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113274. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113275. wipeCaches(bruteForce?: boolean): void;
  113276. _createTexture(): WebGLTexture;
  113277. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113278. /**
  113279. * Usually called from BABYLON.Texture.ts.
  113280. * Passed information to create a WebGLTexture
  113281. * @param urlArg defines a value which contains one of the following:
  113282. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113283. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113284. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113286. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113287. * @param scene needed for loading to the correct scene
  113288. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113289. * @param onLoad optional callback to be called upon successful completion
  113290. * @param onError optional callback to be called upon failure
  113291. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113292. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113293. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113294. * @param forcedExtension defines the extension to use to pick the right loader
  113295. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113296. */
  113297. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  113298. /**
  113299. * Creates a cube texture
  113300. * @param rootUrl defines the url where the files to load is located
  113301. * @param scene defines the current scene
  113302. * @param files defines the list of files to load (1 per face)
  113303. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113304. * @param onLoad defines an optional callback raised when the texture is loaded
  113305. * @param onError defines an optional callback raised if there is an issue to load the texture
  113306. * @param format defines the format of the data
  113307. * @param forcedExtension defines the extension to use to pick the right loader
  113308. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113309. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113310. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113311. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113312. * @returns the cube texture as an InternalTexture
  113313. */
  113314. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  113315. private _getSamplingFilter;
  113316. private static _GetNativeTextureFormat;
  113317. createRenderTargetTexture(size: number | {
  113318. width: number;
  113319. height: number;
  113320. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113321. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113322. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113323. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113324. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113325. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113326. /**
  113327. * Updates a dynamic vertex buffer.
  113328. * @param vertexBuffer the vertex buffer to update
  113329. * @param data the data used to update the vertex buffer
  113330. * @param byteOffset the byte offset of the data (optional)
  113331. * @param byteLength the byte length of the data (optional)
  113332. */
  113333. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113334. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113335. private _updateAnisotropicLevel;
  113336. private _getAddressMode;
  113337. /** @hidden */
  113338. _bindTexture(channel: number, texture: InternalTexture): void;
  113339. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113340. releaseEffects(): void;
  113341. /** @hidden */
  113342. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113343. /** @hidden */
  113344. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113345. /** @hidden */
  113346. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113347. /** @hidden */
  113348. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113349. }
  113350. }
  113351. declare module BABYLON {
  113352. /**
  113353. * Gather the list of clipboard event types as constants.
  113354. */
  113355. export class ClipboardEventTypes {
  113356. /**
  113357. * The clipboard event is fired when a copy command is active (pressed).
  113358. */
  113359. static readonly COPY: number;
  113360. /**
  113361. * The clipboard event is fired when a cut command is active (pressed).
  113362. */
  113363. static readonly CUT: number;
  113364. /**
  113365. * The clipboard event is fired when a paste command is active (pressed).
  113366. */
  113367. static readonly PASTE: number;
  113368. }
  113369. /**
  113370. * This class is used to store clipboard related info for the onClipboardObservable event.
  113371. */
  113372. export class ClipboardInfo {
  113373. /**
  113374. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113375. */
  113376. type: number;
  113377. /**
  113378. * Defines the related dom event
  113379. */
  113380. event: ClipboardEvent;
  113381. /**
  113382. *Creates an instance of ClipboardInfo.
  113383. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113384. * @param event Defines the related dom event
  113385. */
  113386. constructor(
  113387. /**
  113388. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113389. */
  113390. type: number,
  113391. /**
  113392. * Defines the related dom event
  113393. */
  113394. event: ClipboardEvent);
  113395. /**
  113396. * Get the clipboard event's type from the keycode.
  113397. * @param keyCode Defines the keyCode for the current keyboard event.
  113398. * @return {number}
  113399. */
  113400. static GetTypeFromCharacter(keyCode: number): number;
  113401. }
  113402. }
  113403. declare module BABYLON {
  113404. /**
  113405. * Google Daydream controller
  113406. */
  113407. export class DaydreamController extends WebVRController {
  113408. /**
  113409. * Base Url for the controller model.
  113410. */
  113411. static MODEL_BASE_URL: string;
  113412. /**
  113413. * File name for the controller model.
  113414. */
  113415. static MODEL_FILENAME: string;
  113416. /**
  113417. * Gamepad Id prefix used to identify Daydream Controller.
  113418. */
  113419. static readonly GAMEPAD_ID_PREFIX: string;
  113420. /**
  113421. * Creates a new DaydreamController from a gamepad
  113422. * @param vrGamepad the gamepad that the controller should be created from
  113423. */
  113424. constructor(vrGamepad: any);
  113425. /**
  113426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113427. * @param scene scene in which to add meshes
  113428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113429. */
  113430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113431. /**
  113432. * Called once for each button that changed state since the last frame
  113433. * @param buttonIdx Which button index changed
  113434. * @param state New state of the button
  113435. * @param changes Which properties on the state changed since last frame
  113436. */
  113437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113438. }
  113439. }
  113440. declare module BABYLON {
  113441. /**
  113442. * Gear VR Controller
  113443. */
  113444. export class GearVRController extends WebVRController {
  113445. /**
  113446. * Base Url for the controller model.
  113447. */
  113448. static MODEL_BASE_URL: string;
  113449. /**
  113450. * File name for the controller model.
  113451. */
  113452. static MODEL_FILENAME: string;
  113453. /**
  113454. * Gamepad Id prefix used to identify this controller.
  113455. */
  113456. static readonly GAMEPAD_ID_PREFIX: string;
  113457. private readonly _buttonIndexToObservableNameMap;
  113458. /**
  113459. * Creates a new GearVRController from a gamepad
  113460. * @param vrGamepad the gamepad that the controller should be created from
  113461. */
  113462. constructor(vrGamepad: any);
  113463. /**
  113464. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113465. * @param scene scene in which to add meshes
  113466. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113467. */
  113468. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113469. /**
  113470. * Called once for each button that changed state since the last frame
  113471. * @param buttonIdx Which button index changed
  113472. * @param state New state of the button
  113473. * @param changes Which properties on the state changed since last frame
  113474. */
  113475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113476. }
  113477. }
  113478. declare module BABYLON {
  113479. /**
  113480. * Class containing static functions to help procedurally build meshes
  113481. */
  113482. export class PolyhedronBuilder {
  113483. /**
  113484. * Creates a polyhedron mesh
  113485. * * 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
  113486. * * The parameter `size` (positive float, default 1) sets the polygon size
  113487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113488. * * 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`
  113489. * * 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
  113490. * * 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)`)
  113491. * * 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
  113492. * * 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
  113493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113496. * @param name defines the name of the mesh
  113497. * @param options defines the options used to create the mesh
  113498. * @param scene defines the hosting scene
  113499. * @returns the polyhedron mesh
  113500. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113501. */
  113502. static CreatePolyhedron(name: string, options: {
  113503. type?: number;
  113504. size?: number;
  113505. sizeX?: number;
  113506. sizeY?: number;
  113507. sizeZ?: number;
  113508. custom?: any;
  113509. faceUV?: Vector4[];
  113510. faceColors?: Color4[];
  113511. flat?: boolean;
  113512. updatable?: boolean;
  113513. sideOrientation?: number;
  113514. frontUVs?: Vector4;
  113515. backUVs?: Vector4;
  113516. }, scene?: Nullable<Scene>): Mesh;
  113517. }
  113518. }
  113519. declare module BABYLON {
  113520. /**
  113521. * Gizmo that enables scaling a mesh along 3 axis
  113522. */
  113523. export class ScaleGizmo extends Gizmo {
  113524. /**
  113525. * Internal gizmo used for interactions on the x axis
  113526. */
  113527. xGizmo: AxisScaleGizmo;
  113528. /**
  113529. * Internal gizmo used for interactions on the y axis
  113530. */
  113531. yGizmo: AxisScaleGizmo;
  113532. /**
  113533. * Internal gizmo used for interactions on the z axis
  113534. */
  113535. zGizmo: AxisScaleGizmo;
  113536. /**
  113537. * Internal gizmo used to scale all axis equally
  113538. */
  113539. uniformScaleGizmo: AxisScaleGizmo;
  113540. private _meshAttached;
  113541. private _updateGizmoRotationToMatchAttachedMesh;
  113542. private _snapDistance;
  113543. private _scaleRatio;
  113544. private _uniformScalingMesh;
  113545. private _octahedron;
  113546. /** Fires an event when any of it's sub gizmos are dragged */
  113547. onDragStartObservable: Observable<unknown>;
  113548. /** Fires an event when any of it's sub gizmos are released from dragging */
  113549. onDragEndObservable: Observable<unknown>;
  113550. attachedMesh: Nullable<AbstractMesh>;
  113551. /**
  113552. * Creates a ScaleGizmo
  113553. * @param gizmoLayer The utility layer the gizmo will be added to
  113554. */
  113555. constructor(gizmoLayer?: UtilityLayerRenderer);
  113556. updateGizmoRotationToMatchAttachedMesh: boolean;
  113557. /**
  113558. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113559. */
  113560. snapDistance: number;
  113561. /**
  113562. * Ratio for the scale of the gizmo (Default: 1)
  113563. */
  113564. scaleRatio: number;
  113565. /**
  113566. * Disposes of the gizmo
  113567. */
  113568. dispose(): void;
  113569. }
  113570. }
  113571. declare module BABYLON {
  113572. /**
  113573. * Single axis scale gizmo
  113574. */
  113575. export class AxisScaleGizmo extends Gizmo {
  113576. /**
  113577. * Drag behavior responsible for the gizmos dragging interactions
  113578. */
  113579. dragBehavior: PointerDragBehavior;
  113580. private _pointerObserver;
  113581. /**
  113582. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113583. */
  113584. snapDistance: number;
  113585. /**
  113586. * Event that fires each time the gizmo snaps to a new location.
  113587. * * snapDistance is the the change in distance
  113588. */
  113589. onSnapObservable: Observable<{
  113590. snapDistance: number;
  113591. }>;
  113592. /**
  113593. * If the scaling operation should be done on all axis (default: false)
  113594. */
  113595. uniformScaling: boolean;
  113596. private _isEnabled;
  113597. private _parent;
  113598. private _arrow;
  113599. private _coloredMaterial;
  113600. private _hoverMaterial;
  113601. /**
  113602. * Creates an AxisScaleGizmo
  113603. * @param gizmoLayer The utility layer the gizmo will be added to
  113604. * @param dragAxis The axis which the gizmo will be able to scale on
  113605. * @param color The color of the gizmo
  113606. */
  113607. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113608. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113609. /**
  113610. * If the gizmo is enabled
  113611. */
  113612. isEnabled: boolean;
  113613. /**
  113614. * Disposes of the gizmo
  113615. */
  113616. dispose(): void;
  113617. /**
  113618. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113619. * @param mesh The mesh to replace the default mesh of the gizmo
  113620. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113621. */
  113622. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113623. }
  113624. }
  113625. declare module BABYLON {
  113626. /**
  113627. * Bounding box gizmo
  113628. */
  113629. export class BoundingBoxGizmo extends Gizmo {
  113630. private _lineBoundingBox;
  113631. private _rotateSpheresParent;
  113632. private _scaleBoxesParent;
  113633. private _boundingDimensions;
  113634. private _renderObserver;
  113635. private _pointerObserver;
  113636. private _scaleDragSpeed;
  113637. private _tmpQuaternion;
  113638. private _tmpVector;
  113639. private _tmpRotationMatrix;
  113640. /**
  113641. * 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)
  113642. */
  113643. ignoreChildren: boolean;
  113644. /**
  113645. * 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)
  113646. */
  113647. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113648. /**
  113649. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113650. */
  113651. rotationSphereSize: number;
  113652. /**
  113653. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113654. */
  113655. scaleBoxSize: number;
  113656. /**
  113657. * 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)
  113658. */
  113659. fixedDragMeshScreenSize: boolean;
  113660. /**
  113661. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113662. */
  113663. fixedDragMeshScreenSizeDistanceFactor: number;
  113664. /**
  113665. * Fired when a rotation sphere or scale box is dragged
  113666. */
  113667. onDragStartObservable: Observable<{}>;
  113668. /**
  113669. * Fired when a scale box is dragged
  113670. */
  113671. onScaleBoxDragObservable: Observable<{}>;
  113672. /**
  113673. * Fired when a scale box drag is ended
  113674. */
  113675. onScaleBoxDragEndObservable: Observable<{}>;
  113676. /**
  113677. * Fired when a rotation sphere is dragged
  113678. */
  113679. onRotationSphereDragObservable: Observable<{}>;
  113680. /**
  113681. * Fired when a rotation sphere drag is ended
  113682. */
  113683. onRotationSphereDragEndObservable: Observable<{}>;
  113684. /**
  113685. * 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)
  113686. */
  113687. scalePivot: Nullable<Vector3>;
  113688. /**
  113689. * Mesh used as a pivot to rotate the attached mesh
  113690. */
  113691. private _anchorMesh;
  113692. private _existingMeshScale;
  113693. private _dragMesh;
  113694. private pointerDragBehavior;
  113695. private coloredMaterial;
  113696. private hoverColoredMaterial;
  113697. /**
  113698. * Sets the color of the bounding box gizmo
  113699. * @param color the color to set
  113700. */
  113701. setColor(color: Color3): void;
  113702. /**
  113703. * Creates an BoundingBoxGizmo
  113704. * @param gizmoLayer The utility layer the gizmo will be added to
  113705. * @param color The color of the gizmo
  113706. */
  113707. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113708. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113709. private _selectNode;
  113710. /**
  113711. * Updates the bounding box information for the Gizmo
  113712. */
  113713. updateBoundingBox(): void;
  113714. private _updateRotationSpheres;
  113715. private _updateScaleBoxes;
  113716. /**
  113717. * Enables rotation on the specified axis and disables rotation on the others
  113718. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113719. */
  113720. setEnabledRotationAxis(axis: string): void;
  113721. /**
  113722. * Enables/disables scaling
  113723. * @param enable if scaling should be enabled
  113724. */
  113725. setEnabledScaling(enable: boolean): void;
  113726. private _updateDummy;
  113727. /**
  113728. * Enables a pointer drag behavior on the bounding box of the gizmo
  113729. */
  113730. enableDragBehavior(): void;
  113731. /**
  113732. * Disposes of the gizmo
  113733. */
  113734. dispose(): void;
  113735. /**
  113736. * 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)
  113737. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113738. * @returns the bounding box mesh with the passed in mesh as a child
  113739. */
  113740. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113741. /**
  113742. * CustomMeshes are not supported by this gizmo
  113743. * @param mesh The mesh to replace the default mesh of the gizmo
  113744. */
  113745. setCustomMesh(mesh: Mesh): void;
  113746. }
  113747. }
  113748. declare module BABYLON {
  113749. /**
  113750. * Single plane rotation gizmo
  113751. */
  113752. export class PlaneRotationGizmo extends Gizmo {
  113753. /**
  113754. * Drag behavior responsible for the gizmos dragging interactions
  113755. */
  113756. dragBehavior: PointerDragBehavior;
  113757. private _pointerObserver;
  113758. /**
  113759. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113760. */
  113761. snapDistance: number;
  113762. /**
  113763. * Event that fires each time the gizmo snaps to a new location.
  113764. * * snapDistance is the the change in distance
  113765. */
  113766. onSnapObservable: Observable<{
  113767. snapDistance: number;
  113768. }>;
  113769. private _isEnabled;
  113770. private _parent;
  113771. /**
  113772. * Creates a PlaneRotationGizmo
  113773. * @param gizmoLayer The utility layer the gizmo will be added to
  113774. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113775. * @param color The color of the gizmo
  113776. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113777. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113778. */
  113779. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113780. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113781. /**
  113782. * If the gizmo is enabled
  113783. */
  113784. isEnabled: boolean;
  113785. /**
  113786. * Disposes of the gizmo
  113787. */
  113788. dispose(): void;
  113789. }
  113790. }
  113791. declare module BABYLON {
  113792. /**
  113793. * Gizmo that enables rotating a mesh along 3 axis
  113794. */
  113795. export class RotationGizmo extends Gizmo {
  113796. /**
  113797. * Internal gizmo used for interactions on the x axis
  113798. */
  113799. xGizmo: PlaneRotationGizmo;
  113800. /**
  113801. * Internal gizmo used for interactions on the y axis
  113802. */
  113803. yGizmo: PlaneRotationGizmo;
  113804. /**
  113805. * Internal gizmo used for interactions on the z axis
  113806. */
  113807. zGizmo: PlaneRotationGizmo;
  113808. /** Fires an event when any of it's sub gizmos are dragged */
  113809. onDragStartObservable: Observable<unknown>;
  113810. /** Fires an event when any of it's sub gizmos are released from dragging */
  113811. onDragEndObservable: Observable<unknown>;
  113812. private _meshAttached;
  113813. attachedMesh: Nullable<AbstractMesh>;
  113814. /**
  113815. * Creates a RotationGizmo
  113816. * @param gizmoLayer The utility layer the gizmo will be added to
  113817. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113818. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113819. */
  113820. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113821. updateGizmoRotationToMatchAttachedMesh: boolean;
  113822. /**
  113823. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113824. */
  113825. snapDistance: number;
  113826. /**
  113827. * Ratio for the scale of the gizmo (Default: 1)
  113828. */
  113829. scaleRatio: number;
  113830. /**
  113831. * Disposes of the gizmo
  113832. */
  113833. dispose(): void;
  113834. /**
  113835. * CustomMeshes are not supported by this gizmo
  113836. * @param mesh The mesh to replace the default mesh of the gizmo
  113837. */
  113838. setCustomMesh(mesh: Mesh): void;
  113839. }
  113840. }
  113841. declare module BABYLON {
  113842. /**
  113843. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113844. */
  113845. export class GizmoManager implements IDisposable {
  113846. private scene;
  113847. /**
  113848. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113849. */
  113850. gizmos: {
  113851. positionGizmo: Nullable<PositionGizmo>;
  113852. rotationGizmo: Nullable<RotationGizmo>;
  113853. scaleGizmo: Nullable<ScaleGizmo>;
  113854. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113855. };
  113856. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113857. clearGizmoOnEmptyPointerEvent: boolean;
  113858. /** Fires an event when the manager is attached to a mesh */
  113859. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113860. private _gizmosEnabled;
  113861. private _pointerObserver;
  113862. private _attachedMesh;
  113863. private _boundingBoxColor;
  113864. private _defaultUtilityLayer;
  113865. private _defaultKeepDepthUtilityLayer;
  113866. /**
  113867. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113868. */
  113869. boundingBoxDragBehavior: SixDofDragBehavior;
  113870. /**
  113871. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113872. */
  113873. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113874. /**
  113875. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113876. */
  113877. usePointerToAttachGizmos: boolean;
  113878. /**
  113879. * Utility layer that the bounding box gizmo belongs to
  113880. */
  113881. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113882. /**
  113883. * Utility layer that all gizmos besides bounding box belong to
  113884. */
  113885. readonly utilityLayer: UtilityLayerRenderer;
  113886. /**
  113887. * Instatiates a gizmo manager
  113888. * @param scene the scene to overlay the gizmos on top of
  113889. */
  113890. constructor(scene: Scene);
  113891. /**
  113892. * Attaches a set of gizmos to the specified mesh
  113893. * @param mesh The mesh the gizmo's should be attached to
  113894. */
  113895. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113896. /**
  113897. * If the position gizmo is enabled
  113898. */
  113899. positionGizmoEnabled: boolean;
  113900. /**
  113901. * If the rotation gizmo is enabled
  113902. */
  113903. rotationGizmoEnabled: boolean;
  113904. /**
  113905. * If the scale gizmo is enabled
  113906. */
  113907. scaleGizmoEnabled: boolean;
  113908. /**
  113909. * If the boundingBox gizmo is enabled
  113910. */
  113911. boundingBoxGizmoEnabled: boolean;
  113912. /**
  113913. * Disposes of the gizmo manager
  113914. */
  113915. dispose(): void;
  113916. }
  113917. }
  113918. declare module BABYLON {
  113919. /**
  113920. * A directional light is defined by a direction (what a surprise!).
  113921. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113922. * 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.
  113923. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113924. */
  113925. export class DirectionalLight extends ShadowLight {
  113926. private _shadowFrustumSize;
  113927. /**
  113928. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113929. */
  113930. /**
  113931. * Specifies a fix frustum size for the shadow generation.
  113932. */
  113933. shadowFrustumSize: number;
  113934. private _shadowOrthoScale;
  113935. /**
  113936. * Gets the shadow projection scale against the optimal computed one.
  113937. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113938. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113939. */
  113940. /**
  113941. * Sets the shadow projection scale against the optimal computed one.
  113942. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113943. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113944. */
  113945. shadowOrthoScale: number;
  113946. /**
  113947. * Automatically compute the projection matrix to best fit (including all the casters)
  113948. * on each frame.
  113949. */
  113950. autoUpdateExtends: boolean;
  113951. private _orthoLeft;
  113952. private _orthoRight;
  113953. private _orthoTop;
  113954. private _orthoBottom;
  113955. /**
  113956. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113957. * The directional light is emitted from everywhere in the given direction.
  113958. * It can cast shadows.
  113959. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113960. * @param name The friendly name of the light
  113961. * @param direction The direction of the light
  113962. * @param scene The scene the light belongs to
  113963. */
  113964. constructor(name: string, direction: Vector3, scene: Scene);
  113965. /**
  113966. * Returns the string "DirectionalLight".
  113967. * @return The class name
  113968. */
  113969. getClassName(): string;
  113970. /**
  113971. * Returns the integer 1.
  113972. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113973. */
  113974. getTypeID(): number;
  113975. /**
  113976. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113977. * Returns the DirectionalLight Shadow projection matrix.
  113978. */
  113979. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113980. /**
  113981. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113982. * Returns the DirectionalLight Shadow projection matrix.
  113983. */
  113984. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113985. /**
  113986. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113987. * Returns the DirectionalLight Shadow projection matrix.
  113988. */
  113989. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113990. protected _buildUniformLayout(): void;
  113991. /**
  113992. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113993. * @param effect The effect to update
  113994. * @param lightIndex The index of the light in the effect to update
  113995. * @returns The directional light
  113996. */
  113997. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113998. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113999. /**
  114000. * Gets the minZ used for shadow according to both the scene and the light.
  114001. *
  114002. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114003. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114004. * @param activeCamera The camera we are returning the min for
  114005. * @returns the depth min z
  114006. */
  114007. getDepthMinZ(activeCamera: Camera): number;
  114008. /**
  114009. * Gets the maxZ used for shadow according to both the scene and the light.
  114010. *
  114011. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114012. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114013. * @param activeCamera The camera we are returning the max for
  114014. * @returns the depth max z
  114015. */
  114016. getDepthMaxZ(activeCamera: Camera): number;
  114017. /**
  114018. * Prepares the list of defines specific to the light type.
  114019. * @param defines the list of defines
  114020. * @param lightIndex defines the index of the light for the effect
  114021. */
  114022. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114023. }
  114024. }
  114025. declare module BABYLON {
  114026. /**
  114027. * Class containing static functions to help procedurally build meshes
  114028. */
  114029. export class HemisphereBuilder {
  114030. /**
  114031. * Creates a hemisphere mesh
  114032. * @param name defines the name of the mesh
  114033. * @param options defines the options used to create the mesh
  114034. * @param scene defines the hosting scene
  114035. * @returns the hemisphere mesh
  114036. */
  114037. static CreateHemisphere(name: string, options: {
  114038. segments?: number;
  114039. diameter?: number;
  114040. sideOrientation?: number;
  114041. }, scene: any): Mesh;
  114042. }
  114043. }
  114044. declare module BABYLON {
  114045. /**
  114046. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114047. * These values define a cone of light starting from the position, emitting toward the direction.
  114048. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114049. * and the exponent defines the speed of the decay of the light with distance (reach).
  114050. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114051. */
  114052. export class SpotLight extends ShadowLight {
  114053. private _angle;
  114054. private _innerAngle;
  114055. private _cosHalfAngle;
  114056. private _lightAngleScale;
  114057. private _lightAngleOffset;
  114058. /**
  114059. * Gets the cone angle of the spot light in Radians.
  114060. */
  114061. /**
  114062. * Sets the cone angle of the spot light in Radians.
  114063. */
  114064. angle: number;
  114065. /**
  114066. * Only used in gltf falloff mode, this defines the angle where
  114067. * the directional falloff will start before cutting at angle which could be seen
  114068. * as outer angle.
  114069. */
  114070. /**
  114071. * Only used in gltf falloff mode, this defines the angle where
  114072. * the directional falloff will start before cutting at angle which could be seen
  114073. * as outer angle.
  114074. */
  114075. innerAngle: number;
  114076. private _shadowAngleScale;
  114077. /**
  114078. * Allows scaling the angle of the light for shadow generation only.
  114079. */
  114080. /**
  114081. * Allows scaling the angle of the light for shadow generation only.
  114082. */
  114083. shadowAngleScale: number;
  114084. /**
  114085. * The light decay speed with the distance from the emission spot.
  114086. */
  114087. exponent: number;
  114088. private _projectionTextureMatrix;
  114089. /**
  114090. * Allows reading the projecton texture
  114091. */
  114092. readonly projectionTextureMatrix: Matrix;
  114093. protected _projectionTextureLightNear: number;
  114094. /**
  114095. * Gets the near clip of the Spotlight for texture projection.
  114096. */
  114097. /**
  114098. * Sets the near clip of the Spotlight for texture projection.
  114099. */
  114100. projectionTextureLightNear: number;
  114101. protected _projectionTextureLightFar: number;
  114102. /**
  114103. * Gets the far clip of the Spotlight for texture projection.
  114104. */
  114105. /**
  114106. * Sets the far clip of the Spotlight for texture projection.
  114107. */
  114108. projectionTextureLightFar: number;
  114109. protected _projectionTextureUpDirection: Vector3;
  114110. /**
  114111. * Gets the Up vector of the Spotlight for texture projection.
  114112. */
  114113. /**
  114114. * Sets the Up vector of the Spotlight for texture projection.
  114115. */
  114116. projectionTextureUpDirection: Vector3;
  114117. private _projectionTexture;
  114118. /**
  114119. * Gets the projection texture of the light.
  114120. */
  114121. /**
  114122. * Sets the projection texture of the light.
  114123. */
  114124. projectionTexture: Nullable<BaseTexture>;
  114125. private _projectionTextureViewLightDirty;
  114126. private _projectionTextureProjectionLightDirty;
  114127. private _projectionTextureDirty;
  114128. private _projectionTextureViewTargetVector;
  114129. private _projectionTextureViewLightMatrix;
  114130. private _projectionTextureProjectionLightMatrix;
  114131. private _projectionTextureScalingMatrix;
  114132. /**
  114133. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114134. * It can cast shadows.
  114135. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114136. * @param name The light friendly name
  114137. * @param position The position of the spot light in the scene
  114138. * @param direction The direction of the light in the scene
  114139. * @param angle The cone angle of the light in Radians
  114140. * @param exponent The light decay speed with the distance from the emission spot
  114141. * @param scene The scene the lights belongs to
  114142. */
  114143. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114144. /**
  114145. * Returns the string "SpotLight".
  114146. * @returns the class name
  114147. */
  114148. getClassName(): string;
  114149. /**
  114150. * Returns the integer 2.
  114151. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114152. */
  114153. getTypeID(): number;
  114154. /**
  114155. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114156. */
  114157. protected _setDirection(value: Vector3): void;
  114158. /**
  114159. * Overrides the position setter to recompute the projection texture view light Matrix.
  114160. */
  114161. protected _setPosition(value: Vector3): void;
  114162. /**
  114163. * 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.
  114164. * Returns the SpotLight.
  114165. */
  114166. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114167. protected _computeProjectionTextureViewLightMatrix(): void;
  114168. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114169. /**
  114170. * Main function for light texture projection matrix computing.
  114171. */
  114172. protected _computeProjectionTextureMatrix(): void;
  114173. protected _buildUniformLayout(): void;
  114174. private _computeAngleValues;
  114175. /**
  114176. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114177. * @param effect The effect to update
  114178. * @param lightIndex The index of the light in the effect to update
  114179. * @returns The spot light
  114180. */
  114181. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114182. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114183. /**
  114184. * Disposes the light and the associated resources.
  114185. */
  114186. dispose(): void;
  114187. /**
  114188. * Prepares the list of defines specific to the light type.
  114189. * @param defines the list of defines
  114190. * @param lightIndex defines the index of the light for the effect
  114191. */
  114192. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114193. }
  114194. }
  114195. declare module BABYLON {
  114196. /**
  114197. * Gizmo that enables viewing a light
  114198. */
  114199. export class LightGizmo extends Gizmo {
  114200. private _lightMesh;
  114201. private _material;
  114202. private cachedPosition;
  114203. private cachedForward;
  114204. /**
  114205. * Creates a LightGizmo
  114206. * @param gizmoLayer The utility layer the gizmo will be added to
  114207. */
  114208. constructor(gizmoLayer?: UtilityLayerRenderer);
  114209. private _light;
  114210. /**
  114211. * The light that the gizmo is attached to
  114212. */
  114213. light: Nullable<Light>;
  114214. /**
  114215. * Gets the material used to render the light gizmo
  114216. */
  114217. readonly material: StandardMaterial;
  114218. /**
  114219. * @hidden
  114220. * Updates the gizmo to match the attached mesh's position/rotation
  114221. */
  114222. protected _update(): void;
  114223. private static _Scale;
  114224. /**
  114225. * Creates the lines for a light mesh
  114226. */
  114227. private static _createLightLines;
  114228. /**
  114229. * Disposes of the light gizmo
  114230. */
  114231. dispose(): void;
  114232. private static _CreateHemisphericLightMesh;
  114233. private static _CreatePointLightMesh;
  114234. private static _CreateSpotLightMesh;
  114235. private static _CreateDirectionalLightMesh;
  114236. }
  114237. }
  114238. declare module BABYLON {
  114239. /** @hidden */
  114240. export var backgroundFragmentDeclaration: {
  114241. name: string;
  114242. shader: string;
  114243. };
  114244. }
  114245. declare module BABYLON {
  114246. /** @hidden */
  114247. export var backgroundUboDeclaration: {
  114248. name: string;
  114249. shader: string;
  114250. };
  114251. }
  114252. declare module BABYLON {
  114253. /** @hidden */
  114254. export var backgroundPixelShader: {
  114255. name: string;
  114256. shader: string;
  114257. };
  114258. }
  114259. declare module BABYLON {
  114260. /** @hidden */
  114261. export var backgroundVertexDeclaration: {
  114262. name: string;
  114263. shader: string;
  114264. };
  114265. }
  114266. declare module BABYLON {
  114267. /** @hidden */
  114268. export var backgroundVertexShader: {
  114269. name: string;
  114270. shader: string;
  114271. };
  114272. }
  114273. declare module BABYLON {
  114274. /**
  114275. * Background material used to create an efficient environement around your scene.
  114276. */
  114277. export class BackgroundMaterial extends PushMaterial {
  114278. /**
  114279. * Standard reflectance value at parallel view angle.
  114280. */
  114281. static StandardReflectance0: number;
  114282. /**
  114283. * Standard reflectance value at grazing angle.
  114284. */
  114285. static StandardReflectance90: number;
  114286. protected _primaryColor: Color3;
  114287. /**
  114288. * Key light Color (multiply against the environement texture)
  114289. */
  114290. primaryColor: Color3;
  114291. protected __perceptualColor: Nullable<Color3>;
  114292. /**
  114293. * Experimental Internal Use Only.
  114294. *
  114295. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114296. * This acts as a helper to set the primary color to a more "human friendly" value.
  114297. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114298. * output color as close as possible from the chosen value.
  114299. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114300. * part of lighting setup.)
  114301. */
  114302. _perceptualColor: Nullable<Color3>;
  114303. protected _primaryColorShadowLevel: float;
  114304. /**
  114305. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114306. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114307. */
  114308. primaryColorShadowLevel: float;
  114309. protected _primaryColorHighlightLevel: float;
  114310. /**
  114311. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114312. * The primary color is used at the level chosen to define what the white area would look.
  114313. */
  114314. primaryColorHighlightLevel: float;
  114315. protected _reflectionTexture: Nullable<BaseTexture>;
  114316. /**
  114317. * Reflection Texture used in the material.
  114318. * Should be author in a specific way for the best result (refer to the documentation).
  114319. */
  114320. reflectionTexture: Nullable<BaseTexture>;
  114321. protected _reflectionBlur: float;
  114322. /**
  114323. * Reflection Texture level of blur.
  114324. *
  114325. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114326. * texture twice.
  114327. */
  114328. reflectionBlur: float;
  114329. protected _diffuseTexture: Nullable<BaseTexture>;
  114330. /**
  114331. * Diffuse Texture used in the material.
  114332. * Should be author in a specific way for the best result (refer to the documentation).
  114333. */
  114334. diffuseTexture: Nullable<BaseTexture>;
  114335. protected _shadowLights: Nullable<IShadowLight[]>;
  114336. /**
  114337. * Specify the list of lights casting shadow on the material.
  114338. * All scene shadow lights will be included if null.
  114339. */
  114340. shadowLights: Nullable<IShadowLight[]>;
  114341. protected _shadowLevel: float;
  114342. /**
  114343. * Helps adjusting the shadow to a softer level if required.
  114344. * 0 means black shadows and 1 means no shadows.
  114345. */
  114346. shadowLevel: float;
  114347. protected _sceneCenter: Vector3;
  114348. /**
  114349. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114350. * It is usually zero but might be interesting to modify according to your setup.
  114351. */
  114352. sceneCenter: Vector3;
  114353. protected _opacityFresnel: boolean;
  114354. /**
  114355. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114356. * This helps ensuring a nice transition when the camera goes under the ground.
  114357. */
  114358. opacityFresnel: boolean;
  114359. protected _reflectionFresnel: boolean;
  114360. /**
  114361. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114362. * This helps adding a mirror texture on the ground.
  114363. */
  114364. reflectionFresnel: boolean;
  114365. protected _reflectionFalloffDistance: number;
  114366. /**
  114367. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114368. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114369. */
  114370. reflectionFalloffDistance: number;
  114371. protected _reflectionAmount: number;
  114372. /**
  114373. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114374. */
  114375. reflectionAmount: number;
  114376. protected _reflectionReflectance0: number;
  114377. /**
  114378. * This specifies the weight of the reflection at grazing angle.
  114379. */
  114380. reflectionReflectance0: number;
  114381. protected _reflectionReflectance90: number;
  114382. /**
  114383. * This specifies the weight of the reflection at a perpendicular point of view.
  114384. */
  114385. reflectionReflectance90: number;
  114386. /**
  114387. * Sets the reflection reflectance fresnel values according to the default standard
  114388. * empirically know to work well :-)
  114389. */
  114390. reflectionStandardFresnelWeight: number;
  114391. protected _useRGBColor: boolean;
  114392. /**
  114393. * Helps to directly use the maps channels instead of their level.
  114394. */
  114395. useRGBColor: boolean;
  114396. protected _enableNoise: boolean;
  114397. /**
  114398. * This helps reducing the banding effect that could occur on the background.
  114399. */
  114400. enableNoise: boolean;
  114401. /**
  114402. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114403. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114404. * Recommended to be keep at 1.0 except for special cases.
  114405. */
  114406. fovMultiplier: number;
  114407. private _fovMultiplier;
  114408. /**
  114409. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114410. */
  114411. useEquirectangularFOV: boolean;
  114412. private _maxSimultaneousLights;
  114413. /**
  114414. * Number of Simultaneous lights allowed on the material.
  114415. */
  114416. maxSimultaneousLights: int;
  114417. /**
  114418. * Default configuration related to image processing available in the Background Material.
  114419. */
  114420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114421. /**
  114422. * Keep track of the image processing observer to allow dispose and replace.
  114423. */
  114424. private _imageProcessingObserver;
  114425. /**
  114426. * Attaches a new image processing configuration to the PBR Material.
  114427. * @param configuration (if null the scene configuration will be use)
  114428. */
  114429. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114430. /**
  114431. * Gets the image processing configuration used either in this material.
  114432. */
  114433. /**
  114434. * Sets the Default image processing configuration used either in the this material.
  114435. *
  114436. * If sets to null, the scene one is in use.
  114437. */
  114438. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114439. /**
  114440. * Gets wether the color curves effect is enabled.
  114441. */
  114442. /**
  114443. * Sets wether the color curves effect is enabled.
  114444. */
  114445. cameraColorCurvesEnabled: boolean;
  114446. /**
  114447. * Gets wether the color grading effect is enabled.
  114448. */
  114449. /**
  114450. * Gets wether the color grading effect is enabled.
  114451. */
  114452. cameraColorGradingEnabled: boolean;
  114453. /**
  114454. * Gets wether tonemapping is enabled or not.
  114455. */
  114456. /**
  114457. * Sets wether tonemapping is enabled or not
  114458. */
  114459. cameraToneMappingEnabled: boolean;
  114460. /**
  114461. * The camera exposure used on this material.
  114462. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114463. * This corresponds to a photographic exposure.
  114464. */
  114465. /**
  114466. * The camera exposure used on this material.
  114467. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114468. * This corresponds to a photographic exposure.
  114469. */
  114470. cameraExposure: float;
  114471. /**
  114472. * Gets The camera contrast used on this material.
  114473. */
  114474. /**
  114475. * Sets The camera contrast used on this material.
  114476. */
  114477. cameraContrast: float;
  114478. /**
  114479. * Gets the Color Grading 2D Lookup Texture.
  114480. */
  114481. /**
  114482. * Sets the Color Grading 2D Lookup Texture.
  114483. */
  114484. cameraColorGradingTexture: Nullable<BaseTexture>;
  114485. /**
  114486. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114487. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114488. * 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;
  114489. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114490. */
  114491. /**
  114492. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114493. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114494. * 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;
  114495. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114496. */
  114497. cameraColorCurves: Nullable<ColorCurves>;
  114498. /**
  114499. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114500. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114501. */
  114502. switchToBGR: boolean;
  114503. private _renderTargets;
  114504. private _reflectionControls;
  114505. private _white;
  114506. private _primaryShadowColor;
  114507. private _primaryHighlightColor;
  114508. /**
  114509. * Instantiates a Background Material in the given scene
  114510. * @param name The friendly name of the material
  114511. * @param scene The scene to add the material to
  114512. */
  114513. constructor(name: string, scene: Scene);
  114514. /**
  114515. * Gets a boolean indicating that current material needs to register RTT
  114516. */
  114517. readonly hasRenderTargetTextures: boolean;
  114518. /**
  114519. * The entire material has been created in order to prevent overdraw.
  114520. * @returns false
  114521. */
  114522. needAlphaTesting(): boolean;
  114523. /**
  114524. * The entire material has been created in order to prevent overdraw.
  114525. * @returns true if blending is enable
  114526. */
  114527. needAlphaBlending(): boolean;
  114528. /**
  114529. * Checks wether the material is ready to be rendered for a given mesh.
  114530. * @param mesh The mesh to render
  114531. * @param subMesh The submesh to check against
  114532. * @param useInstances Specify wether or not the material is used with instances
  114533. * @returns true if all the dependencies are ready (Textures, Effects...)
  114534. */
  114535. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114536. /**
  114537. * Compute the primary color according to the chosen perceptual color.
  114538. */
  114539. private _computePrimaryColorFromPerceptualColor;
  114540. /**
  114541. * Compute the highlights and shadow colors according to their chosen levels.
  114542. */
  114543. private _computePrimaryColors;
  114544. /**
  114545. * Build the uniform buffer used in the material.
  114546. */
  114547. buildUniformLayout(): void;
  114548. /**
  114549. * Unbind the material.
  114550. */
  114551. unbind(): void;
  114552. /**
  114553. * Bind only the world matrix to the material.
  114554. * @param world The world matrix to bind.
  114555. */
  114556. bindOnlyWorldMatrix(world: Matrix): void;
  114557. /**
  114558. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114559. * @param world The world matrix to bind.
  114560. * @param subMesh The submesh to bind for.
  114561. */
  114562. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114563. /**
  114564. * Checks to see if a texture is used in the material.
  114565. * @param texture - Base texture to use.
  114566. * @returns - Boolean specifying if a texture is used in the material.
  114567. */
  114568. hasTexture(texture: BaseTexture): boolean;
  114569. /**
  114570. * Dispose the material.
  114571. * @param forceDisposeEffect Force disposal of the associated effect.
  114572. * @param forceDisposeTextures Force disposal of the associated textures.
  114573. */
  114574. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114575. /**
  114576. * Clones the material.
  114577. * @param name The cloned name.
  114578. * @returns The cloned material.
  114579. */
  114580. clone(name: string): BackgroundMaterial;
  114581. /**
  114582. * Serializes the current material to its JSON representation.
  114583. * @returns The JSON representation.
  114584. */
  114585. serialize(): any;
  114586. /**
  114587. * Gets the class name of the material
  114588. * @returns "BackgroundMaterial"
  114589. */
  114590. getClassName(): string;
  114591. /**
  114592. * Parse a JSON input to create back a background material.
  114593. * @param source The JSON data to parse
  114594. * @param scene The scene to create the parsed material in
  114595. * @param rootUrl The root url of the assets the material depends upon
  114596. * @returns the instantiated BackgroundMaterial.
  114597. */
  114598. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114599. }
  114600. }
  114601. declare module BABYLON {
  114602. /**
  114603. * Represents the different options available during the creation of
  114604. * a Environment helper.
  114605. *
  114606. * This can control the default ground, skybox and image processing setup of your scene.
  114607. */
  114608. export interface IEnvironmentHelperOptions {
  114609. /**
  114610. * Specifies wether or not to create a ground.
  114611. * True by default.
  114612. */
  114613. createGround: boolean;
  114614. /**
  114615. * Specifies the ground size.
  114616. * 15 by default.
  114617. */
  114618. groundSize: number;
  114619. /**
  114620. * The texture used on the ground for the main color.
  114621. * Comes from the BabylonJS CDN by default.
  114622. *
  114623. * Remarks: Can be either a texture or a url.
  114624. */
  114625. groundTexture: string | BaseTexture;
  114626. /**
  114627. * The color mixed in the ground texture by default.
  114628. * BabylonJS clearColor by default.
  114629. */
  114630. groundColor: Color3;
  114631. /**
  114632. * Specifies the ground opacity.
  114633. * 1 by default.
  114634. */
  114635. groundOpacity: number;
  114636. /**
  114637. * Enables the ground to receive shadows.
  114638. * True by default.
  114639. */
  114640. enableGroundShadow: boolean;
  114641. /**
  114642. * Helps preventing the shadow to be fully black on the ground.
  114643. * 0.5 by default.
  114644. */
  114645. groundShadowLevel: number;
  114646. /**
  114647. * Creates a mirror texture attach to the ground.
  114648. * false by default.
  114649. */
  114650. enableGroundMirror: boolean;
  114651. /**
  114652. * Specifies the ground mirror size ratio.
  114653. * 0.3 by default as the default kernel is 64.
  114654. */
  114655. groundMirrorSizeRatio: number;
  114656. /**
  114657. * Specifies the ground mirror blur kernel size.
  114658. * 64 by default.
  114659. */
  114660. groundMirrorBlurKernel: number;
  114661. /**
  114662. * Specifies the ground mirror visibility amount.
  114663. * 1 by default
  114664. */
  114665. groundMirrorAmount: number;
  114666. /**
  114667. * Specifies the ground mirror reflectance weight.
  114668. * This uses the standard weight of the background material to setup the fresnel effect
  114669. * of the mirror.
  114670. * 1 by default.
  114671. */
  114672. groundMirrorFresnelWeight: number;
  114673. /**
  114674. * Specifies the ground mirror Falloff distance.
  114675. * This can helps reducing the size of the reflection.
  114676. * 0 by Default.
  114677. */
  114678. groundMirrorFallOffDistance: number;
  114679. /**
  114680. * Specifies the ground mirror texture type.
  114681. * Unsigned Int by Default.
  114682. */
  114683. groundMirrorTextureType: number;
  114684. /**
  114685. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114686. * the shown objects.
  114687. */
  114688. groundYBias: number;
  114689. /**
  114690. * Specifies wether or not to create a skybox.
  114691. * True by default.
  114692. */
  114693. createSkybox: boolean;
  114694. /**
  114695. * Specifies the skybox size.
  114696. * 20 by default.
  114697. */
  114698. skyboxSize: number;
  114699. /**
  114700. * The texture used on the skybox for the main color.
  114701. * Comes from the BabylonJS CDN by default.
  114702. *
  114703. * Remarks: Can be either a texture or a url.
  114704. */
  114705. skyboxTexture: string | BaseTexture;
  114706. /**
  114707. * The color mixed in the skybox texture by default.
  114708. * BabylonJS clearColor by default.
  114709. */
  114710. skyboxColor: Color3;
  114711. /**
  114712. * The background rotation around the Y axis of the scene.
  114713. * This helps aligning the key lights of your scene with the background.
  114714. * 0 by default.
  114715. */
  114716. backgroundYRotation: number;
  114717. /**
  114718. * Compute automatically the size of the elements to best fit with the scene.
  114719. */
  114720. sizeAuto: boolean;
  114721. /**
  114722. * Default position of the rootMesh if autoSize is not true.
  114723. */
  114724. rootPosition: Vector3;
  114725. /**
  114726. * Sets up the image processing in the scene.
  114727. * true by default.
  114728. */
  114729. setupImageProcessing: boolean;
  114730. /**
  114731. * The texture used as your environment texture in the scene.
  114732. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114733. *
  114734. * Remarks: Can be either a texture or a url.
  114735. */
  114736. environmentTexture: string | BaseTexture;
  114737. /**
  114738. * The value of the exposure to apply to the scene.
  114739. * 0.6 by default if setupImageProcessing is true.
  114740. */
  114741. cameraExposure: number;
  114742. /**
  114743. * The value of the contrast to apply to the scene.
  114744. * 1.6 by default if setupImageProcessing is true.
  114745. */
  114746. cameraContrast: number;
  114747. /**
  114748. * Specifies wether or not tonemapping should be enabled in the scene.
  114749. * true by default if setupImageProcessing is true.
  114750. */
  114751. toneMappingEnabled: boolean;
  114752. }
  114753. /**
  114754. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114755. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114756. * It also helps with the default setup of your imageProcessing configuration.
  114757. */
  114758. export class EnvironmentHelper {
  114759. /**
  114760. * Default ground texture URL.
  114761. */
  114762. private static _groundTextureCDNUrl;
  114763. /**
  114764. * Default skybox texture URL.
  114765. */
  114766. private static _skyboxTextureCDNUrl;
  114767. /**
  114768. * Default environment texture URL.
  114769. */
  114770. private static _environmentTextureCDNUrl;
  114771. /**
  114772. * Creates the default options for the helper.
  114773. */
  114774. private static _getDefaultOptions;
  114775. private _rootMesh;
  114776. /**
  114777. * Gets the root mesh created by the helper.
  114778. */
  114779. readonly rootMesh: Mesh;
  114780. private _skybox;
  114781. /**
  114782. * Gets the skybox created by the helper.
  114783. */
  114784. readonly skybox: Nullable<Mesh>;
  114785. private _skyboxTexture;
  114786. /**
  114787. * Gets the skybox texture created by the helper.
  114788. */
  114789. readonly skyboxTexture: Nullable<BaseTexture>;
  114790. private _skyboxMaterial;
  114791. /**
  114792. * Gets the skybox material created by the helper.
  114793. */
  114794. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114795. private _ground;
  114796. /**
  114797. * Gets the ground mesh created by the helper.
  114798. */
  114799. readonly ground: Nullable<Mesh>;
  114800. private _groundTexture;
  114801. /**
  114802. * Gets the ground texture created by the helper.
  114803. */
  114804. readonly groundTexture: Nullable<BaseTexture>;
  114805. private _groundMirror;
  114806. /**
  114807. * Gets the ground mirror created by the helper.
  114808. */
  114809. readonly groundMirror: Nullable<MirrorTexture>;
  114810. /**
  114811. * Gets the ground mirror render list to helps pushing the meshes
  114812. * you wish in the ground reflection.
  114813. */
  114814. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114815. private _groundMaterial;
  114816. /**
  114817. * Gets the ground material created by the helper.
  114818. */
  114819. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114820. /**
  114821. * Stores the creation options.
  114822. */
  114823. private readonly _scene;
  114824. private _options;
  114825. /**
  114826. * This observable will be notified with any error during the creation of the environment,
  114827. * mainly texture creation errors.
  114828. */
  114829. onErrorObservable: Observable<{
  114830. message?: string;
  114831. exception?: any;
  114832. }>;
  114833. /**
  114834. * constructor
  114835. * @param options Defines the options we want to customize the helper
  114836. * @param scene The scene to add the material to
  114837. */
  114838. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114839. /**
  114840. * Updates the background according to the new options
  114841. * @param options
  114842. */
  114843. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114844. /**
  114845. * Sets the primary color of all the available elements.
  114846. * @param color the main color to affect to the ground and the background
  114847. */
  114848. setMainColor(color: Color3): void;
  114849. /**
  114850. * Setup the image processing according to the specified options.
  114851. */
  114852. private _setupImageProcessing;
  114853. /**
  114854. * Setup the environment texture according to the specified options.
  114855. */
  114856. private _setupEnvironmentTexture;
  114857. /**
  114858. * Setup the background according to the specified options.
  114859. */
  114860. private _setupBackground;
  114861. /**
  114862. * Get the scene sizes according to the setup.
  114863. */
  114864. private _getSceneSize;
  114865. /**
  114866. * Setup the ground according to the specified options.
  114867. */
  114868. private _setupGround;
  114869. /**
  114870. * Setup the ground material according to the specified options.
  114871. */
  114872. private _setupGroundMaterial;
  114873. /**
  114874. * Setup the ground diffuse texture according to the specified options.
  114875. */
  114876. private _setupGroundDiffuseTexture;
  114877. /**
  114878. * Setup the ground mirror texture according to the specified options.
  114879. */
  114880. private _setupGroundMirrorTexture;
  114881. /**
  114882. * Setup the ground to receive the mirror texture.
  114883. */
  114884. private _setupMirrorInGroundMaterial;
  114885. /**
  114886. * Setup the skybox according to the specified options.
  114887. */
  114888. private _setupSkybox;
  114889. /**
  114890. * Setup the skybox material according to the specified options.
  114891. */
  114892. private _setupSkyboxMaterial;
  114893. /**
  114894. * Setup the skybox reflection texture according to the specified options.
  114895. */
  114896. private _setupSkyboxReflectionTexture;
  114897. private _errorHandler;
  114898. /**
  114899. * Dispose all the elements created by the Helper.
  114900. */
  114901. dispose(): void;
  114902. }
  114903. }
  114904. declare module BABYLON {
  114905. /**
  114906. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114907. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114908. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114909. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114910. */
  114911. export class PhotoDome extends TransformNode {
  114912. /**
  114913. * Define the image as a Monoscopic panoramic 360 image.
  114914. */
  114915. static readonly MODE_MONOSCOPIC: number;
  114916. /**
  114917. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114918. */
  114919. static readonly MODE_TOPBOTTOM: number;
  114920. /**
  114921. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114922. */
  114923. static readonly MODE_SIDEBYSIDE: number;
  114924. private _useDirectMapping;
  114925. /**
  114926. * The texture being displayed on the sphere
  114927. */
  114928. protected _photoTexture: Texture;
  114929. /**
  114930. * Gets or sets the texture being displayed on the sphere
  114931. */
  114932. photoTexture: Texture;
  114933. /**
  114934. * Observable raised when an error occured while loading the 360 image
  114935. */
  114936. onLoadErrorObservable: Observable<string>;
  114937. /**
  114938. * The skybox material
  114939. */
  114940. protected _material: BackgroundMaterial;
  114941. /**
  114942. * The surface used for the skybox
  114943. */
  114944. protected _mesh: Mesh;
  114945. /**
  114946. * Gets the mesh used for the skybox.
  114947. */
  114948. readonly mesh: Mesh;
  114949. /**
  114950. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114951. * Also see the options.resolution property.
  114952. */
  114953. fovMultiplier: number;
  114954. private _imageMode;
  114955. /**
  114956. * Gets or set the current video mode for the video. It can be:
  114957. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114958. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114959. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114960. */
  114961. imageMode: number;
  114962. /**
  114963. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114964. * @param name Element's name, child elements will append suffixes for their own names.
  114965. * @param urlsOfPhoto defines the url of the photo to display
  114966. * @param options defines an object containing optional or exposed sub element properties
  114967. * @param onError defines a callback called when an error occured while loading the texture
  114968. */
  114969. constructor(name: string, urlOfPhoto: string, options: {
  114970. resolution?: number;
  114971. size?: number;
  114972. useDirectMapping?: boolean;
  114973. faceForward?: boolean;
  114974. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114975. private _onBeforeCameraRenderObserver;
  114976. private _changeImageMode;
  114977. /**
  114978. * Releases resources associated with this node.
  114979. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114980. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114981. */
  114982. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114983. }
  114984. }
  114985. declare module BABYLON {
  114986. /**
  114987. * Class used to host RGBD texture specific utilities
  114988. */
  114989. export class RGBDTextureTools {
  114990. /**
  114991. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114992. * @param texture the texture to expand.
  114993. */
  114994. static ExpandRGBDTexture(texture: Texture): void;
  114995. }
  114996. }
  114997. declare module BABYLON {
  114998. /**
  114999. * Class used to host texture specific utilities
  115000. */
  115001. export class BRDFTextureTools {
  115002. /**
  115003. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115004. * @param scene defines the hosting scene
  115005. * @returns the environment BRDF texture
  115006. */
  115007. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115008. private static _environmentBRDFBase64Texture;
  115009. }
  115010. }
  115011. declare module BABYLON {
  115012. /**
  115013. * @hidden
  115014. */
  115015. export interface IMaterialClearCoatDefines {
  115016. CLEARCOAT: boolean;
  115017. CLEARCOAT_DEFAULTIOR: boolean;
  115018. CLEARCOAT_TEXTURE: boolean;
  115019. CLEARCOAT_TEXTUREDIRECTUV: number;
  115020. CLEARCOAT_BUMP: boolean;
  115021. CLEARCOAT_BUMPDIRECTUV: number;
  115022. CLEARCOAT_TINT: boolean;
  115023. CLEARCOAT_TINT_TEXTURE: boolean;
  115024. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115025. /** @hidden */
  115026. _areTexturesDirty: boolean;
  115027. }
  115028. /**
  115029. * Define the code related to the clear coat parameters of the pbr material.
  115030. */
  115031. export class PBRClearCoatConfiguration {
  115032. /**
  115033. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115034. * The default fits with a polyurethane material.
  115035. */
  115036. private static readonly _DefaultIndexOfRefraction;
  115037. private _isEnabled;
  115038. /**
  115039. * Defines if the clear coat is enabled in the material.
  115040. */
  115041. isEnabled: boolean;
  115042. /**
  115043. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115044. */
  115045. intensity: number;
  115046. /**
  115047. * Defines the clear coat layer roughness.
  115048. */
  115049. roughness: number;
  115050. private _indexOfRefraction;
  115051. /**
  115052. * Defines the index of refraction of the clear coat.
  115053. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115054. * The default fits with a polyurethane material.
  115055. * Changing the default value is more performance intensive.
  115056. */
  115057. indexOfRefraction: number;
  115058. private _texture;
  115059. /**
  115060. * Stores the clear coat values in a texture.
  115061. */
  115062. texture: Nullable<BaseTexture>;
  115063. private _bumpTexture;
  115064. /**
  115065. * Define the clear coat specific bump texture.
  115066. */
  115067. bumpTexture: Nullable<BaseTexture>;
  115068. private _isTintEnabled;
  115069. /**
  115070. * Defines if the clear coat tint is enabled in the material.
  115071. */
  115072. isTintEnabled: boolean;
  115073. /**
  115074. * Defines the clear coat tint of the material.
  115075. * This is only use if tint is enabled
  115076. */
  115077. tintColor: Color3;
  115078. /**
  115079. * Defines the distance at which the tint color should be found in the
  115080. * clear coat media.
  115081. * This is only use if tint is enabled
  115082. */
  115083. tintColorAtDistance: number;
  115084. /**
  115085. * Defines the clear coat layer thickness.
  115086. * This is only use if tint is enabled
  115087. */
  115088. tintThickness: number;
  115089. private _tintTexture;
  115090. /**
  115091. * Stores the clear tint values in a texture.
  115092. * rgb is tint
  115093. * a is a thickness factor
  115094. */
  115095. tintTexture: Nullable<BaseTexture>;
  115096. /** @hidden */
  115097. private _internalMarkAllSubMeshesAsTexturesDirty;
  115098. /** @hidden */
  115099. _markAllSubMeshesAsTexturesDirty(): void;
  115100. /**
  115101. * Instantiate a new istance of clear coat configuration.
  115102. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115103. */
  115104. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115105. /**
  115106. * Gets wehter the submesh is ready to be used or not.
  115107. * @param defines the list of "defines" to update.
  115108. * @param scene defines the scene the material belongs to.
  115109. * @param engine defines the engine the material belongs to.
  115110. * @param disableBumpMap defines wether the material disables bump or not.
  115111. * @returns - boolean indicating that the submesh is ready or not.
  115112. */
  115113. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115114. /**
  115115. * Checks to see if a texture is used in the material.
  115116. * @param defines the list of "defines" to update.
  115117. * @param scene defines the scene to the material belongs to.
  115118. */
  115119. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115120. /**
  115121. * Binds the material data.
  115122. * @param uniformBuffer defines the Uniform buffer to fill in.
  115123. * @param scene defines the scene the material belongs to.
  115124. * @param engine defines the engine the material belongs to.
  115125. * @param disableBumpMap defines wether the material disables bump or not.
  115126. * @param isFrozen defines wether the material is frozen or not.
  115127. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115128. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115129. */
  115130. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115131. /**
  115132. * Checks to see if a texture is used in the material.
  115133. * @param texture - Base texture to use.
  115134. * @returns - Boolean specifying if a texture is used in the material.
  115135. */
  115136. hasTexture(texture: BaseTexture): boolean;
  115137. /**
  115138. * Returns an array of the actively used textures.
  115139. * @param activeTextures Array of BaseTextures
  115140. */
  115141. getActiveTextures(activeTextures: BaseTexture[]): void;
  115142. /**
  115143. * Returns the animatable textures.
  115144. * @param animatables Array of animatable textures.
  115145. */
  115146. getAnimatables(animatables: IAnimatable[]): void;
  115147. /**
  115148. * Disposes the resources of the material.
  115149. * @param forceDisposeTextures - Forces the disposal of all textures.
  115150. */
  115151. dispose(forceDisposeTextures?: boolean): void;
  115152. /**
  115153. * Get the current class name of the texture useful for serialization or dynamic coding.
  115154. * @returns "PBRClearCoatConfiguration"
  115155. */
  115156. getClassName(): string;
  115157. /**
  115158. * Add fallbacks to the effect fallbacks list.
  115159. * @param defines defines the Base texture to use.
  115160. * @param fallbacks defines the current fallback list.
  115161. * @param currentRank defines the current fallback rank.
  115162. * @returns the new fallback rank.
  115163. */
  115164. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115165. /**
  115166. * Add the required uniforms to the current list.
  115167. * @param uniforms defines the current uniform list.
  115168. */
  115169. static AddUniforms(uniforms: string[]): void;
  115170. /**
  115171. * Add the required samplers to the current list.
  115172. * @param samplers defines the current sampler list.
  115173. */
  115174. static AddSamplers(samplers: string[]): void;
  115175. /**
  115176. * Add the required uniforms to the current buffer.
  115177. * @param uniformBuffer defines the current uniform buffer.
  115178. */
  115179. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115180. /**
  115181. * Makes a duplicate of the current configuration into another one.
  115182. * @param clearCoatConfiguration define the config where to copy the info
  115183. */
  115184. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115185. /**
  115186. * Serializes this clear coat configuration.
  115187. * @returns - An object with the serialized config.
  115188. */
  115189. serialize(): any;
  115190. /**
  115191. * Parses a anisotropy Configuration from a serialized object.
  115192. * @param source - Serialized object.
  115193. * @param scene Defines the scene we are parsing for
  115194. * @param rootUrl Defines the rootUrl to load from
  115195. */
  115196. parse(source: any, scene: Scene, rootUrl: string): void;
  115197. }
  115198. }
  115199. declare module BABYLON {
  115200. /**
  115201. * @hidden
  115202. */
  115203. export interface IMaterialAnisotropicDefines {
  115204. ANISOTROPIC: boolean;
  115205. ANISOTROPIC_TEXTURE: boolean;
  115206. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115207. MAINUV1: boolean;
  115208. _areTexturesDirty: boolean;
  115209. _needUVs: boolean;
  115210. }
  115211. /**
  115212. * Define the code related to the anisotropic parameters of the pbr material.
  115213. */
  115214. export class PBRAnisotropicConfiguration {
  115215. private _isEnabled;
  115216. /**
  115217. * Defines if the anisotropy is enabled in the material.
  115218. */
  115219. isEnabled: boolean;
  115220. /**
  115221. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115222. */
  115223. intensity: number;
  115224. /**
  115225. * Defines if the effect is along the tangents, bitangents or in between.
  115226. * By default, the effect is "strectching" the highlights along the tangents.
  115227. */
  115228. direction: Vector2;
  115229. private _texture;
  115230. /**
  115231. * Stores the anisotropy values in a texture.
  115232. * rg is direction (like normal from -1 to 1)
  115233. * b is a intensity
  115234. */
  115235. texture: Nullable<BaseTexture>;
  115236. /** @hidden */
  115237. private _internalMarkAllSubMeshesAsTexturesDirty;
  115238. /** @hidden */
  115239. _markAllSubMeshesAsTexturesDirty(): void;
  115240. /**
  115241. * Instantiate a new istance of anisotropy configuration.
  115242. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115243. */
  115244. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115245. /**
  115246. * Specifies that the submesh is ready to be used.
  115247. * @param defines the list of "defines" to update.
  115248. * @param scene defines the scene the material belongs to.
  115249. * @returns - boolean indicating that the submesh is ready or not.
  115250. */
  115251. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115252. /**
  115253. * Checks to see if a texture is used in the material.
  115254. * @param defines the list of "defines" to update.
  115255. * @param mesh the mesh we are preparing the defines for.
  115256. * @param scene defines the scene the material belongs to.
  115257. */
  115258. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115259. /**
  115260. * Binds the material data.
  115261. * @param uniformBuffer defines the Uniform buffer to fill in.
  115262. * @param scene defines the scene the material belongs to.
  115263. * @param isFrozen defines wether the material is frozen or not.
  115264. */
  115265. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115266. /**
  115267. * Checks to see if a texture is used in the material.
  115268. * @param texture - Base texture to use.
  115269. * @returns - Boolean specifying if a texture is used in the material.
  115270. */
  115271. hasTexture(texture: BaseTexture): boolean;
  115272. /**
  115273. * Returns an array of the actively used textures.
  115274. * @param activeTextures Array of BaseTextures
  115275. */
  115276. getActiveTextures(activeTextures: BaseTexture[]): void;
  115277. /**
  115278. * Returns the animatable textures.
  115279. * @param animatables Array of animatable textures.
  115280. */
  115281. getAnimatables(animatables: IAnimatable[]): void;
  115282. /**
  115283. * Disposes the resources of the material.
  115284. * @param forceDisposeTextures - Forces the disposal of all textures.
  115285. */
  115286. dispose(forceDisposeTextures?: boolean): void;
  115287. /**
  115288. * Get the current class name of the texture useful for serialization or dynamic coding.
  115289. * @returns "PBRAnisotropicConfiguration"
  115290. */
  115291. getClassName(): string;
  115292. /**
  115293. * Add fallbacks to the effect fallbacks list.
  115294. * @param defines defines the Base texture to use.
  115295. * @param fallbacks defines the current fallback list.
  115296. * @param currentRank defines the current fallback rank.
  115297. * @returns the new fallback rank.
  115298. */
  115299. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115300. /**
  115301. * Add the required uniforms to the current list.
  115302. * @param uniforms defines the current uniform list.
  115303. */
  115304. static AddUniforms(uniforms: string[]): void;
  115305. /**
  115306. * Add the required uniforms to the current buffer.
  115307. * @param uniformBuffer defines the current uniform buffer.
  115308. */
  115309. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115310. /**
  115311. * Add the required samplers to the current list.
  115312. * @param samplers defines the current sampler list.
  115313. */
  115314. static AddSamplers(samplers: string[]): void;
  115315. /**
  115316. * Makes a duplicate of the current configuration into another one.
  115317. * @param anisotropicConfiguration define the config where to copy the info
  115318. */
  115319. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115320. /**
  115321. * Serializes this anisotropy configuration.
  115322. * @returns - An object with the serialized config.
  115323. */
  115324. serialize(): any;
  115325. /**
  115326. * Parses a anisotropy Configuration from a serialized object.
  115327. * @param source - Serialized object.
  115328. * @param scene Defines the scene we are parsing for
  115329. * @param rootUrl Defines the rootUrl to load from
  115330. */
  115331. parse(source: any, scene: Scene, rootUrl: string): void;
  115332. }
  115333. }
  115334. declare module BABYLON {
  115335. /**
  115336. * @hidden
  115337. */
  115338. export interface IMaterialBRDFDefines {
  115339. BRDF_V_HEIGHT_CORRELATED: boolean;
  115340. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115341. SPHERICAL_HARMONICS: boolean;
  115342. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115343. /** @hidden */
  115344. _areMiscDirty: boolean;
  115345. }
  115346. /**
  115347. * Define the code related to the BRDF parameters of the pbr material.
  115348. */
  115349. export class PBRBRDFConfiguration {
  115350. /**
  115351. * Default value used for the energy conservation.
  115352. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115353. */
  115354. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115355. /**
  115356. * Default value used for the Smith Visibility Height Correlated mode.
  115357. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115358. */
  115359. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115360. /**
  115361. * Default value used for the IBL diffuse part.
  115362. * This can help switching back to the polynomials mode globally which is a tiny bit
  115363. * less GPU intensive at the drawback of a lower quality.
  115364. */
  115365. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115366. /**
  115367. * Default value used for activating energy conservation for the specular workflow.
  115368. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115369. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115370. */
  115371. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115372. private _useEnergyConservation;
  115373. /**
  115374. * Defines if the material uses energy conservation.
  115375. */
  115376. useEnergyConservation: boolean;
  115377. private _useSmithVisibilityHeightCorrelated;
  115378. /**
  115379. * LEGACY Mode set to false
  115380. * Defines if the material uses height smith correlated visibility term.
  115381. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115382. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115383. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115384. * Not relying on height correlated will also disable energy conservation.
  115385. */
  115386. useSmithVisibilityHeightCorrelated: boolean;
  115387. private _useSphericalHarmonics;
  115388. /**
  115389. * LEGACY Mode set to false
  115390. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115391. * diffuse part of the IBL.
  115392. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115393. * to the ground truth.
  115394. */
  115395. useSphericalHarmonics: boolean;
  115396. private _useSpecularGlossinessInputEnergyConservation;
  115397. /**
  115398. * Defines if the material uses energy conservation, when the specular workflow is active.
  115399. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115400. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115401. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115402. */
  115403. useSpecularGlossinessInputEnergyConservation: boolean;
  115404. /** @hidden */
  115405. private _internalMarkAllSubMeshesAsMiscDirty;
  115406. /** @hidden */
  115407. _markAllSubMeshesAsMiscDirty(): void;
  115408. /**
  115409. * Instantiate a new istance of clear coat configuration.
  115410. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115411. */
  115412. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115413. /**
  115414. * Checks to see if a texture is used in the material.
  115415. * @param defines the list of "defines" to update.
  115416. */
  115417. prepareDefines(defines: IMaterialBRDFDefines): void;
  115418. /**
  115419. * Get the current class name of the texture useful for serialization or dynamic coding.
  115420. * @returns "PBRClearCoatConfiguration"
  115421. */
  115422. getClassName(): string;
  115423. /**
  115424. * Makes a duplicate of the current configuration into another one.
  115425. * @param brdfConfiguration define the config where to copy the info
  115426. */
  115427. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115428. /**
  115429. * Serializes this BRDF configuration.
  115430. * @returns - An object with the serialized config.
  115431. */
  115432. serialize(): any;
  115433. /**
  115434. * Parses a anisotropy Configuration from a serialized object.
  115435. * @param source - Serialized object.
  115436. * @param scene Defines the scene we are parsing for
  115437. * @param rootUrl Defines the rootUrl to load from
  115438. */
  115439. parse(source: any, scene: Scene, rootUrl: string): void;
  115440. }
  115441. }
  115442. declare module BABYLON {
  115443. /**
  115444. * @hidden
  115445. */
  115446. export interface IMaterialSheenDefines {
  115447. SHEEN: boolean;
  115448. SHEEN_TEXTURE: boolean;
  115449. SHEEN_TEXTUREDIRECTUV: number;
  115450. SHEEN_LINKWITHALBEDO: boolean;
  115451. /** @hidden */
  115452. _areTexturesDirty: boolean;
  115453. }
  115454. /**
  115455. * Define the code related to the Sheen parameters of the pbr material.
  115456. */
  115457. export class PBRSheenConfiguration {
  115458. private _isEnabled;
  115459. /**
  115460. * Defines if the material uses sheen.
  115461. */
  115462. isEnabled: boolean;
  115463. private _linkSheenWithAlbedo;
  115464. /**
  115465. * Defines if the sheen is linked to the sheen color.
  115466. */
  115467. linkSheenWithAlbedo: boolean;
  115468. /**
  115469. * Defines the sheen intensity.
  115470. */
  115471. intensity: number;
  115472. /**
  115473. * Defines the sheen color.
  115474. */
  115475. color: Color3;
  115476. private _texture;
  115477. /**
  115478. * Stores the sheen tint values in a texture.
  115479. * rgb is tint
  115480. * a is a intensity
  115481. */
  115482. texture: Nullable<BaseTexture>;
  115483. /** @hidden */
  115484. private _internalMarkAllSubMeshesAsTexturesDirty;
  115485. /** @hidden */
  115486. _markAllSubMeshesAsTexturesDirty(): void;
  115487. /**
  115488. * Instantiate a new istance of clear coat configuration.
  115489. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115490. */
  115491. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115492. /**
  115493. * Specifies that the submesh is ready to be used.
  115494. * @param defines the list of "defines" to update.
  115495. * @param scene defines the scene the material belongs to.
  115496. * @returns - boolean indicating that the submesh is ready or not.
  115497. */
  115498. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115499. /**
  115500. * Checks to see if a texture is used in the material.
  115501. * @param defines the list of "defines" to update.
  115502. * @param scene defines the scene the material belongs to.
  115503. */
  115504. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115505. /**
  115506. * Binds the material data.
  115507. * @param uniformBuffer defines the Uniform buffer to fill in.
  115508. * @param scene defines the scene the material belongs to.
  115509. * @param isFrozen defines wether the material is frozen or not.
  115510. */
  115511. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115512. /**
  115513. * Checks to see if a texture is used in the material.
  115514. * @param texture - Base texture to use.
  115515. * @returns - Boolean specifying if a texture is used in the material.
  115516. */
  115517. hasTexture(texture: BaseTexture): boolean;
  115518. /**
  115519. * Returns an array of the actively used textures.
  115520. * @param activeTextures Array of BaseTextures
  115521. */
  115522. getActiveTextures(activeTextures: BaseTexture[]): void;
  115523. /**
  115524. * Returns the animatable textures.
  115525. * @param animatables Array of animatable textures.
  115526. */
  115527. getAnimatables(animatables: IAnimatable[]): void;
  115528. /**
  115529. * Disposes the resources of the material.
  115530. * @param forceDisposeTextures - Forces the disposal of all textures.
  115531. */
  115532. dispose(forceDisposeTextures?: boolean): void;
  115533. /**
  115534. * Get the current class name of the texture useful for serialization or dynamic coding.
  115535. * @returns "PBRSheenConfiguration"
  115536. */
  115537. getClassName(): string;
  115538. /**
  115539. * Add fallbacks to the effect fallbacks list.
  115540. * @param defines defines the Base texture to use.
  115541. * @param fallbacks defines the current fallback list.
  115542. * @param currentRank defines the current fallback rank.
  115543. * @returns the new fallback rank.
  115544. */
  115545. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115546. /**
  115547. * Add the required uniforms to the current list.
  115548. * @param uniforms defines the current uniform list.
  115549. */
  115550. static AddUniforms(uniforms: string[]): void;
  115551. /**
  115552. * Add the required uniforms to the current buffer.
  115553. * @param uniformBuffer defines the current uniform buffer.
  115554. */
  115555. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115556. /**
  115557. * Add the required samplers to the current list.
  115558. * @param samplers defines the current sampler list.
  115559. */
  115560. static AddSamplers(samplers: string[]): void;
  115561. /**
  115562. * Makes a duplicate of the current configuration into another one.
  115563. * @param sheenConfiguration define the config where to copy the info
  115564. */
  115565. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115566. /**
  115567. * Serializes this BRDF configuration.
  115568. * @returns - An object with the serialized config.
  115569. */
  115570. serialize(): any;
  115571. /**
  115572. * Parses a anisotropy Configuration from a serialized object.
  115573. * @param source - Serialized object.
  115574. * @param scene Defines the scene we are parsing for
  115575. * @param rootUrl Defines the rootUrl to load from
  115576. */
  115577. parse(source: any, scene: Scene, rootUrl: string): void;
  115578. }
  115579. }
  115580. declare module BABYLON {
  115581. /**
  115582. * @hidden
  115583. */
  115584. export interface IMaterialSubSurfaceDefines {
  115585. SUBSURFACE: boolean;
  115586. SS_REFRACTION: boolean;
  115587. SS_TRANSLUCENCY: boolean;
  115588. SS_SCATERRING: boolean;
  115589. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115590. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115591. SS_REFRACTIONMAP_3D: boolean;
  115592. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115593. SS_LODINREFRACTIONALPHA: boolean;
  115594. SS_GAMMAREFRACTION: boolean;
  115595. SS_RGBDREFRACTION: boolean;
  115596. SS_LINEARSPECULARREFRACTION: boolean;
  115597. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115598. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115599. /** @hidden */
  115600. _areTexturesDirty: boolean;
  115601. }
  115602. /**
  115603. * Define the code related to the sub surface parameters of the pbr material.
  115604. */
  115605. export class PBRSubSurfaceConfiguration {
  115606. private _isRefractionEnabled;
  115607. /**
  115608. * Defines if the refraction is enabled in the material.
  115609. */
  115610. isRefractionEnabled: boolean;
  115611. private _isTranslucencyEnabled;
  115612. /**
  115613. * Defines if the translucency is enabled in the material.
  115614. */
  115615. isTranslucencyEnabled: boolean;
  115616. private _isScatteringEnabled;
  115617. /**
  115618. * Defines the refraction intensity of the material.
  115619. * The refraction when enabled replaces the Diffuse part of the material.
  115620. * The intensity helps transitionning between diffuse and refraction.
  115621. */
  115622. refractionIntensity: number;
  115623. /**
  115624. * Defines the translucency intensity of the material.
  115625. * When translucency has been enabled, this defines how much of the "translucency"
  115626. * is addded to the diffuse part of the material.
  115627. */
  115628. translucencyIntensity: number;
  115629. /**
  115630. * Defines the scattering intensity of the material.
  115631. * When scattering has been enabled, this defines how much of the "scattered light"
  115632. * is addded to the diffuse part of the material.
  115633. */
  115634. scatteringIntensity: number;
  115635. private _thicknessTexture;
  115636. /**
  115637. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115638. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115639. * 0 would mean minimumThickness
  115640. * 1 would mean maximumThickness
  115641. * The other channels might be use as a mask to vary the different effects intensity.
  115642. */
  115643. thicknessTexture: Nullable<BaseTexture>;
  115644. private _refractionTexture;
  115645. /**
  115646. * Defines the texture to use for refraction.
  115647. */
  115648. refractionTexture: Nullable<BaseTexture>;
  115649. private _indexOfRefraction;
  115650. /**
  115651. * Defines the index of refraction used in the material.
  115652. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115653. */
  115654. indexOfRefraction: number;
  115655. private _invertRefractionY;
  115656. /**
  115657. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115658. */
  115659. invertRefractionY: boolean;
  115660. private _linkRefractionWithTransparency;
  115661. /**
  115662. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115663. * Materials half opaque for instance using refraction could benefit from this control.
  115664. */
  115665. linkRefractionWithTransparency: boolean;
  115666. /**
  115667. * Defines the minimum thickness stored in the thickness map.
  115668. * If no thickness map is defined, this value will be used to simulate thickness.
  115669. */
  115670. minimumThickness: number;
  115671. /**
  115672. * Defines the maximum thickness stored in the thickness map.
  115673. */
  115674. maximumThickness: number;
  115675. /**
  115676. * Defines the volume tint of the material.
  115677. * This is used for both translucency and scattering.
  115678. */
  115679. tintColor: Color3;
  115680. /**
  115681. * Defines the distance at which the tint color should be found in the media.
  115682. * This is used for refraction only.
  115683. */
  115684. tintColorAtDistance: number;
  115685. /**
  115686. * Defines how far each channel transmit through the media.
  115687. * It is defined as a color to simplify it selection.
  115688. */
  115689. diffusionDistance: Color3;
  115690. private _useMaskFromThicknessTexture;
  115691. /**
  115692. * Stores the intensity of the different subsurface effects in the thickness texture.
  115693. * * the green channel is the translucency intensity.
  115694. * * the blue channel is the scattering intensity.
  115695. * * the alpha channel is the refraction intensity.
  115696. */
  115697. useMaskFromThicknessTexture: boolean;
  115698. /** @hidden */
  115699. private _internalMarkAllSubMeshesAsTexturesDirty;
  115700. /** @hidden */
  115701. _markAllSubMeshesAsTexturesDirty(): void;
  115702. /**
  115703. * Instantiate a new istance of sub surface configuration.
  115704. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115705. */
  115706. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115707. /**
  115708. * Gets wehter the submesh is ready to be used or not.
  115709. * @param defines the list of "defines" to update.
  115710. * @param scene defines the scene the material belongs to.
  115711. * @returns - boolean indicating that the submesh is ready or not.
  115712. */
  115713. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115714. /**
  115715. * Checks to see if a texture is used in the material.
  115716. * @param defines the list of "defines" to update.
  115717. * @param scene defines the scene to the material belongs to.
  115718. */
  115719. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115720. /**
  115721. * Binds the material data.
  115722. * @param uniformBuffer defines the Uniform buffer to fill in.
  115723. * @param scene defines the scene the material belongs to.
  115724. * @param engine defines the engine the material belongs to.
  115725. * @param isFrozen defines wether the material is frozen or not.
  115726. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115727. */
  115728. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115729. /**
  115730. * Unbinds the material from the mesh.
  115731. * @param activeEffect defines the effect that should be unbound from.
  115732. * @returns true if unbound, otherwise false
  115733. */
  115734. unbind(activeEffect: Effect): boolean;
  115735. /**
  115736. * Returns the texture used for refraction or null if none is used.
  115737. * @param scene defines the scene the material belongs to.
  115738. * @returns - Refraction texture if present. If no refraction texture and refraction
  115739. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115740. */
  115741. private _getRefractionTexture;
  115742. /**
  115743. * Returns true if alpha blending should be disabled.
  115744. */
  115745. readonly disableAlphaBlending: boolean;
  115746. /**
  115747. * Fills the list of render target textures.
  115748. * @param renderTargets the list of render targets to update
  115749. */
  115750. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115751. /**
  115752. * Checks to see if a texture is used in the material.
  115753. * @param texture - Base texture to use.
  115754. * @returns - Boolean specifying if a texture is used in the material.
  115755. */
  115756. hasTexture(texture: BaseTexture): boolean;
  115757. /**
  115758. * Gets a boolean indicating that current material needs to register RTT
  115759. * @returns true if this uses a render target otherwise false.
  115760. */
  115761. hasRenderTargetTextures(): boolean;
  115762. /**
  115763. * Returns an array of the actively used textures.
  115764. * @param activeTextures Array of BaseTextures
  115765. */
  115766. getActiveTextures(activeTextures: BaseTexture[]): void;
  115767. /**
  115768. * Returns the animatable textures.
  115769. * @param animatables Array of animatable textures.
  115770. */
  115771. getAnimatables(animatables: IAnimatable[]): void;
  115772. /**
  115773. * Disposes the resources of the material.
  115774. * @param forceDisposeTextures - Forces the disposal of all textures.
  115775. */
  115776. dispose(forceDisposeTextures?: boolean): void;
  115777. /**
  115778. * Get the current class name of the texture useful for serialization or dynamic coding.
  115779. * @returns "PBRSubSurfaceConfiguration"
  115780. */
  115781. getClassName(): string;
  115782. /**
  115783. * Add fallbacks to the effect fallbacks list.
  115784. * @param defines defines the Base texture to use.
  115785. * @param fallbacks defines the current fallback list.
  115786. * @param currentRank defines the current fallback rank.
  115787. * @returns the new fallback rank.
  115788. */
  115789. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115790. /**
  115791. * Add the required uniforms to the current list.
  115792. * @param uniforms defines the current uniform list.
  115793. */
  115794. static AddUniforms(uniforms: string[]): void;
  115795. /**
  115796. * Add the required samplers to the current list.
  115797. * @param samplers defines the current sampler list.
  115798. */
  115799. static AddSamplers(samplers: string[]): void;
  115800. /**
  115801. * Add the required uniforms to the current buffer.
  115802. * @param uniformBuffer defines the current uniform buffer.
  115803. */
  115804. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115805. /**
  115806. * Makes a duplicate of the current configuration into another one.
  115807. * @param configuration define the config where to copy the info
  115808. */
  115809. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115810. /**
  115811. * Serializes this Sub Surface configuration.
  115812. * @returns - An object with the serialized config.
  115813. */
  115814. serialize(): any;
  115815. /**
  115816. * Parses a anisotropy Configuration from a serialized object.
  115817. * @param source - Serialized object.
  115818. * @param scene Defines the scene we are parsing for
  115819. * @param rootUrl Defines the rootUrl to load from
  115820. */
  115821. parse(source: any, scene: Scene, rootUrl: string): void;
  115822. }
  115823. }
  115824. declare module BABYLON {
  115825. /** @hidden */
  115826. export var pbrFragmentDeclaration: {
  115827. name: string;
  115828. shader: string;
  115829. };
  115830. }
  115831. declare module BABYLON {
  115832. /** @hidden */
  115833. export var pbrUboDeclaration: {
  115834. name: string;
  115835. shader: string;
  115836. };
  115837. }
  115838. declare module BABYLON {
  115839. /** @hidden */
  115840. export var pbrFragmentExtraDeclaration: {
  115841. name: string;
  115842. shader: string;
  115843. };
  115844. }
  115845. declare module BABYLON {
  115846. /** @hidden */
  115847. export var pbrFragmentSamplersDeclaration: {
  115848. name: string;
  115849. shader: string;
  115850. };
  115851. }
  115852. declare module BABYLON {
  115853. /** @hidden */
  115854. export var pbrHelperFunctions: {
  115855. name: string;
  115856. shader: string;
  115857. };
  115858. }
  115859. declare module BABYLON {
  115860. /** @hidden */
  115861. export var harmonicsFunctions: {
  115862. name: string;
  115863. shader: string;
  115864. };
  115865. }
  115866. declare module BABYLON {
  115867. /** @hidden */
  115868. export var pbrDirectLightingSetupFunctions: {
  115869. name: string;
  115870. shader: string;
  115871. };
  115872. }
  115873. declare module BABYLON {
  115874. /** @hidden */
  115875. export var pbrDirectLightingFalloffFunctions: {
  115876. name: string;
  115877. shader: string;
  115878. };
  115879. }
  115880. declare module BABYLON {
  115881. /** @hidden */
  115882. export var pbrBRDFFunctions: {
  115883. name: string;
  115884. shader: string;
  115885. };
  115886. }
  115887. declare module BABYLON {
  115888. /** @hidden */
  115889. export var pbrDirectLightingFunctions: {
  115890. name: string;
  115891. shader: string;
  115892. };
  115893. }
  115894. declare module BABYLON {
  115895. /** @hidden */
  115896. export var pbrIBLFunctions: {
  115897. name: string;
  115898. shader: string;
  115899. };
  115900. }
  115901. declare module BABYLON {
  115902. /** @hidden */
  115903. export var pbrDebug: {
  115904. name: string;
  115905. shader: string;
  115906. };
  115907. }
  115908. declare module BABYLON {
  115909. /** @hidden */
  115910. export var pbrPixelShader: {
  115911. name: string;
  115912. shader: string;
  115913. };
  115914. }
  115915. declare module BABYLON {
  115916. /** @hidden */
  115917. export var pbrVertexDeclaration: {
  115918. name: string;
  115919. shader: string;
  115920. };
  115921. }
  115922. declare module BABYLON {
  115923. /** @hidden */
  115924. export var pbrVertexShader: {
  115925. name: string;
  115926. shader: string;
  115927. };
  115928. }
  115929. declare module BABYLON {
  115930. /**
  115931. * Manages the defines for the PBR Material.
  115932. * @hidden
  115933. */
  115934. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115935. PBR: boolean;
  115936. MAINUV1: boolean;
  115937. MAINUV2: boolean;
  115938. UV1: boolean;
  115939. UV2: boolean;
  115940. ALBEDO: boolean;
  115941. ALBEDODIRECTUV: number;
  115942. VERTEXCOLOR: boolean;
  115943. AMBIENT: boolean;
  115944. AMBIENTDIRECTUV: number;
  115945. AMBIENTINGRAYSCALE: boolean;
  115946. OPACITY: boolean;
  115947. VERTEXALPHA: boolean;
  115948. OPACITYDIRECTUV: number;
  115949. OPACITYRGB: boolean;
  115950. ALPHATEST: boolean;
  115951. DEPTHPREPASS: boolean;
  115952. ALPHABLEND: boolean;
  115953. ALPHAFROMALBEDO: boolean;
  115954. ALPHATESTVALUE: string;
  115955. SPECULAROVERALPHA: boolean;
  115956. RADIANCEOVERALPHA: boolean;
  115957. ALPHAFRESNEL: boolean;
  115958. LINEARALPHAFRESNEL: boolean;
  115959. PREMULTIPLYALPHA: boolean;
  115960. EMISSIVE: boolean;
  115961. EMISSIVEDIRECTUV: number;
  115962. REFLECTIVITY: boolean;
  115963. REFLECTIVITYDIRECTUV: number;
  115964. SPECULARTERM: boolean;
  115965. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115966. MICROSURFACEAUTOMATIC: boolean;
  115967. LODBASEDMICROSFURACE: boolean;
  115968. MICROSURFACEMAP: boolean;
  115969. MICROSURFACEMAPDIRECTUV: number;
  115970. METALLICWORKFLOW: boolean;
  115971. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115972. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115973. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115974. AOSTOREINMETALMAPRED: boolean;
  115975. METALLICF0FACTORFROMMETALLICMAP: boolean;
  115976. ENVIRONMENTBRDF: boolean;
  115977. ENVIRONMENTBRDF_RGBD: boolean;
  115978. NORMAL: boolean;
  115979. TANGENT: boolean;
  115980. BUMP: boolean;
  115981. BUMPDIRECTUV: number;
  115982. OBJECTSPACE_NORMALMAP: boolean;
  115983. PARALLAX: boolean;
  115984. PARALLAXOCCLUSION: boolean;
  115985. NORMALXYSCALE: boolean;
  115986. LIGHTMAP: boolean;
  115987. LIGHTMAPDIRECTUV: number;
  115988. USELIGHTMAPASSHADOWMAP: boolean;
  115989. GAMMALIGHTMAP: boolean;
  115990. RGBDLIGHTMAP: boolean;
  115991. REFLECTION: boolean;
  115992. REFLECTIONMAP_3D: boolean;
  115993. REFLECTIONMAP_SPHERICAL: boolean;
  115994. REFLECTIONMAP_PLANAR: boolean;
  115995. REFLECTIONMAP_CUBIC: boolean;
  115996. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115997. REFLECTIONMAP_PROJECTION: boolean;
  115998. REFLECTIONMAP_SKYBOX: boolean;
  115999. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116000. REFLECTIONMAP_EXPLICIT: boolean;
  116001. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116002. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116003. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116004. INVERTCUBICMAP: boolean;
  116005. USESPHERICALFROMREFLECTIONMAP: boolean;
  116006. USEIRRADIANCEMAP: boolean;
  116007. SPHERICAL_HARMONICS: boolean;
  116008. USESPHERICALINVERTEX: boolean;
  116009. REFLECTIONMAP_OPPOSITEZ: boolean;
  116010. LODINREFLECTIONALPHA: boolean;
  116011. GAMMAREFLECTION: boolean;
  116012. RGBDREFLECTION: boolean;
  116013. LINEARSPECULARREFLECTION: boolean;
  116014. RADIANCEOCCLUSION: boolean;
  116015. HORIZONOCCLUSION: boolean;
  116016. INSTANCES: boolean;
  116017. NUM_BONE_INFLUENCERS: number;
  116018. BonesPerMesh: number;
  116019. BONETEXTURE: boolean;
  116020. NONUNIFORMSCALING: boolean;
  116021. MORPHTARGETS: boolean;
  116022. MORPHTARGETS_NORMAL: boolean;
  116023. MORPHTARGETS_TANGENT: boolean;
  116024. MORPHTARGETS_UV: boolean;
  116025. NUM_MORPH_INFLUENCERS: number;
  116026. IMAGEPROCESSING: boolean;
  116027. VIGNETTE: boolean;
  116028. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116029. VIGNETTEBLENDMODEOPAQUE: boolean;
  116030. TONEMAPPING: boolean;
  116031. TONEMAPPING_ACES: boolean;
  116032. CONTRAST: boolean;
  116033. COLORCURVES: boolean;
  116034. COLORGRADING: boolean;
  116035. COLORGRADING3D: boolean;
  116036. SAMPLER3DGREENDEPTH: boolean;
  116037. SAMPLER3DBGRMAP: boolean;
  116038. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116039. EXPOSURE: boolean;
  116040. MULTIVIEW: boolean;
  116041. USEPHYSICALLIGHTFALLOFF: boolean;
  116042. USEGLTFLIGHTFALLOFF: boolean;
  116043. TWOSIDEDLIGHTING: boolean;
  116044. SHADOWFLOAT: boolean;
  116045. CLIPPLANE: boolean;
  116046. CLIPPLANE2: boolean;
  116047. CLIPPLANE3: boolean;
  116048. CLIPPLANE4: boolean;
  116049. POINTSIZE: boolean;
  116050. FOG: boolean;
  116051. LOGARITHMICDEPTH: boolean;
  116052. FORCENORMALFORWARD: boolean;
  116053. SPECULARAA: boolean;
  116054. CLEARCOAT: boolean;
  116055. CLEARCOAT_DEFAULTIOR: boolean;
  116056. CLEARCOAT_TEXTURE: boolean;
  116057. CLEARCOAT_TEXTUREDIRECTUV: number;
  116058. CLEARCOAT_BUMP: boolean;
  116059. CLEARCOAT_BUMPDIRECTUV: number;
  116060. CLEARCOAT_TINT: boolean;
  116061. CLEARCOAT_TINT_TEXTURE: boolean;
  116062. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116063. ANISOTROPIC: boolean;
  116064. ANISOTROPIC_TEXTURE: boolean;
  116065. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116066. BRDF_V_HEIGHT_CORRELATED: boolean;
  116067. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116068. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116069. SHEEN: boolean;
  116070. SHEEN_TEXTURE: boolean;
  116071. SHEEN_TEXTUREDIRECTUV: number;
  116072. SHEEN_LINKWITHALBEDO: boolean;
  116073. SUBSURFACE: boolean;
  116074. SS_REFRACTION: boolean;
  116075. SS_TRANSLUCENCY: boolean;
  116076. SS_SCATERRING: boolean;
  116077. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116078. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116079. SS_REFRACTIONMAP_3D: boolean;
  116080. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116081. SS_LODINREFRACTIONALPHA: boolean;
  116082. SS_GAMMAREFRACTION: boolean;
  116083. SS_RGBDREFRACTION: boolean;
  116084. SS_LINEARSPECULARREFRACTION: boolean;
  116085. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116086. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116087. UNLIT: boolean;
  116088. DEBUGMODE: number;
  116089. /**
  116090. * Initializes the PBR Material defines.
  116091. */
  116092. constructor();
  116093. /**
  116094. * Resets the PBR Material defines.
  116095. */
  116096. reset(): void;
  116097. }
  116098. /**
  116099. * The Physically based material base class of BJS.
  116100. *
  116101. * This offers the main features of a standard PBR material.
  116102. * For more information, please refer to the documentation :
  116103. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116104. */
  116105. export abstract class PBRBaseMaterial extends PushMaterial {
  116106. /**
  116107. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116108. */
  116109. static readonly PBRMATERIAL_OPAQUE: number;
  116110. /**
  116111. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116112. */
  116113. static readonly PBRMATERIAL_ALPHATEST: number;
  116114. /**
  116115. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116116. */
  116117. static readonly PBRMATERIAL_ALPHABLEND: number;
  116118. /**
  116119. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116120. * They are also discarded below the alpha cutoff threshold to improve performances.
  116121. */
  116122. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116123. /**
  116124. * Defines the default value of how much AO map is occluding the analytical lights
  116125. * (point spot...).
  116126. */
  116127. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116128. /**
  116129. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116130. */
  116131. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116132. /**
  116133. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116134. * to enhance interoperability with other engines.
  116135. */
  116136. static readonly LIGHTFALLOFF_GLTF: number;
  116137. /**
  116138. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116139. * to enhance interoperability with other materials.
  116140. */
  116141. static readonly LIGHTFALLOFF_STANDARD: number;
  116142. /**
  116143. * Intensity of the direct lights e.g. the four lights available in your scene.
  116144. * This impacts both the direct diffuse and specular highlights.
  116145. */
  116146. protected _directIntensity: number;
  116147. /**
  116148. * Intensity of the emissive part of the material.
  116149. * This helps controlling the emissive effect without modifying the emissive color.
  116150. */
  116151. protected _emissiveIntensity: number;
  116152. /**
  116153. * Intensity of the environment e.g. how much the environment will light the object
  116154. * either through harmonics for rough material or through the refelction for shiny ones.
  116155. */
  116156. protected _environmentIntensity: number;
  116157. /**
  116158. * This is a special control allowing the reduction of the specular highlights coming from the
  116159. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116160. */
  116161. protected _specularIntensity: number;
  116162. /**
  116163. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116164. */
  116165. private _lightingInfos;
  116166. /**
  116167. * Debug Control allowing disabling the bump map on this material.
  116168. */
  116169. protected _disableBumpMap: boolean;
  116170. /**
  116171. * AKA Diffuse Texture in standard nomenclature.
  116172. */
  116173. protected _albedoTexture: Nullable<BaseTexture>;
  116174. /**
  116175. * AKA Occlusion Texture in other nomenclature.
  116176. */
  116177. protected _ambientTexture: Nullable<BaseTexture>;
  116178. /**
  116179. * AKA Occlusion Texture Intensity in other nomenclature.
  116180. */
  116181. protected _ambientTextureStrength: number;
  116182. /**
  116183. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116184. * 1 means it completely occludes it
  116185. * 0 mean it has no impact
  116186. */
  116187. protected _ambientTextureImpactOnAnalyticalLights: number;
  116188. /**
  116189. * Stores the alpha values in a texture.
  116190. */
  116191. protected _opacityTexture: Nullable<BaseTexture>;
  116192. /**
  116193. * Stores the reflection values in a texture.
  116194. */
  116195. protected _reflectionTexture: Nullable<BaseTexture>;
  116196. /**
  116197. * Stores the emissive values in a texture.
  116198. */
  116199. protected _emissiveTexture: Nullable<BaseTexture>;
  116200. /**
  116201. * AKA Specular texture in other nomenclature.
  116202. */
  116203. protected _reflectivityTexture: Nullable<BaseTexture>;
  116204. /**
  116205. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116206. */
  116207. protected _metallicTexture: Nullable<BaseTexture>;
  116208. /**
  116209. * Specifies the metallic scalar of the metallic/roughness workflow.
  116210. * Can also be used to scale the metalness values of the metallic texture.
  116211. */
  116212. protected _metallic: Nullable<number>;
  116213. /**
  116214. * Specifies the roughness scalar of the metallic/roughness workflow.
  116215. * Can also be used to scale the roughness values of the metallic texture.
  116216. */
  116217. protected _roughness: Nullable<number>;
  116218. /**
  116219. * Specifies the an F0 factor to help configuring the material F0.
  116220. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116221. * to 0.5 the previously hard coded value stays the same.
  116222. * Can also be used to scale the F0 values of the metallic texture.
  116223. */
  116224. protected _metallicF0Factor: number;
  116225. /**
  116226. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116227. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116228. * your expectation as it multiplies with the texture data.
  116229. */
  116230. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116231. /**
  116232. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116233. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116234. */
  116235. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116236. /**
  116237. * Stores surface normal data used to displace a mesh in a texture.
  116238. */
  116239. protected _bumpTexture: Nullable<BaseTexture>;
  116240. /**
  116241. * Stores the pre-calculated light information of a mesh in a texture.
  116242. */
  116243. protected _lightmapTexture: Nullable<BaseTexture>;
  116244. /**
  116245. * The color of a material in ambient lighting.
  116246. */
  116247. protected _ambientColor: Color3;
  116248. /**
  116249. * AKA Diffuse Color in other nomenclature.
  116250. */
  116251. protected _albedoColor: Color3;
  116252. /**
  116253. * AKA Specular Color in other nomenclature.
  116254. */
  116255. protected _reflectivityColor: Color3;
  116256. /**
  116257. * The color applied when light is reflected from a material.
  116258. */
  116259. protected _reflectionColor: Color3;
  116260. /**
  116261. * The color applied when light is emitted from a material.
  116262. */
  116263. protected _emissiveColor: Color3;
  116264. /**
  116265. * AKA Glossiness in other nomenclature.
  116266. */
  116267. protected _microSurface: number;
  116268. /**
  116269. * Specifies that the material will use the light map as a show map.
  116270. */
  116271. protected _useLightmapAsShadowmap: boolean;
  116272. /**
  116273. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116274. * makes the reflect vector face the model (under horizon).
  116275. */
  116276. protected _useHorizonOcclusion: boolean;
  116277. /**
  116278. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116279. * too much the area relying on ambient texture to define their ambient occlusion.
  116280. */
  116281. protected _useRadianceOcclusion: boolean;
  116282. /**
  116283. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116284. */
  116285. protected _useAlphaFromAlbedoTexture: boolean;
  116286. /**
  116287. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116288. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116289. */
  116290. protected _useSpecularOverAlpha: boolean;
  116291. /**
  116292. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116293. */
  116294. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116295. /**
  116296. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116297. */
  116298. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116299. /**
  116300. * Specifies if the metallic texture contains the roughness information in its green channel.
  116301. */
  116302. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116303. /**
  116304. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116305. */
  116306. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116307. /**
  116308. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116309. */
  116310. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116311. /**
  116312. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116313. */
  116314. protected _useAmbientInGrayScale: boolean;
  116315. /**
  116316. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116317. * The material will try to infer what glossiness each pixel should be.
  116318. */
  116319. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116320. /**
  116321. * Defines the falloff type used in this material.
  116322. * It by default is Physical.
  116323. */
  116324. protected _lightFalloff: number;
  116325. /**
  116326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116328. */
  116329. protected _useRadianceOverAlpha: boolean;
  116330. /**
  116331. * Allows using an object space normal map (instead of tangent space).
  116332. */
  116333. protected _useObjectSpaceNormalMap: boolean;
  116334. /**
  116335. * Allows using the bump map in parallax mode.
  116336. */
  116337. protected _useParallax: boolean;
  116338. /**
  116339. * Allows using the bump map in parallax occlusion mode.
  116340. */
  116341. protected _useParallaxOcclusion: boolean;
  116342. /**
  116343. * Controls the scale bias of the parallax mode.
  116344. */
  116345. protected _parallaxScaleBias: number;
  116346. /**
  116347. * If sets to true, disables all the lights affecting the material.
  116348. */
  116349. protected _disableLighting: boolean;
  116350. /**
  116351. * Number of Simultaneous lights allowed on the material.
  116352. */
  116353. protected _maxSimultaneousLights: number;
  116354. /**
  116355. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116356. */
  116357. protected _invertNormalMapX: boolean;
  116358. /**
  116359. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116360. */
  116361. protected _invertNormalMapY: boolean;
  116362. /**
  116363. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116364. */
  116365. protected _twoSidedLighting: boolean;
  116366. /**
  116367. * Defines the alpha limits in alpha test mode.
  116368. */
  116369. protected _alphaCutOff: number;
  116370. /**
  116371. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116372. */
  116373. protected _forceAlphaTest: boolean;
  116374. /**
  116375. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116376. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116377. */
  116378. protected _useAlphaFresnel: boolean;
  116379. /**
  116380. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116381. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116382. */
  116383. protected _useLinearAlphaFresnel: boolean;
  116384. /**
  116385. * The transparency mode of the material.
  116386. */
  116387. protected _transparencyMode: Nullable<number>;
  116388. /**
  116389. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116390. * from cos thetav and roughness:
  116391. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116392. */
  116393. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116394. /**
  116395. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116396. */
  116397. protected _forceIrradianceInFragment: boolean;
  116398. /**
  116399. * Force normal to face away from face.
  116400. */
  116401. protected _forceNormalForward: boolean;
  116402. /**
  116403. * Enables specular anti aliasing in the PBR shader.
  116404. * It will both interacts on the Geometry for analytical and IBL lighting.
  116405. * It also prefilter the roughness map based on the bump values.
  116406. */
  116407. protected _enableSpecularAntiAliasing: boolean;
  116408. /**
  116409. * Default configuration related to image processing available in the PBR Material.
  116410. */
  116411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116412. /**
  116413. * Keep track of the image processing observer to allow dispose and replace.
  116414. */
  116415. private _imageProcessingObserver;
  116416. /**
  116417. * Attaches a new image processing configuration to the PBR Material.
  116418. * @param configuration
  116419. */
  116420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116421. /**
  116422. * Stores the available render targets.
  116423. */
  116424. private _renderTargets;
  116425. /**
  116426. * Sets the global ambient color for the material used in lighting calculations.
  116427. */
  116428. private _globalAmbientColor;
  116429. /**
  116430. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116431. */
  116432. private _useLogarithmicDepth;
  116433. /**
  116434. * If set to true, no lighting calculations will be applied.
  116435. */
  116436. private _unlit;
  116437. private _debugMode;
  116438. /**
  116439. * @hidden
  116440. * This is reserved for the inspector.
  116441. * Defines the material debug mode.
  116442. * It helps seeing only some components of the material while troubleshooting.
  116443. */
  116444. debugMode: number;
  116445. /**
  116446. * @hidden
  116447. * This is reserved for the inspector.
  116448. * Specify from where on screen the debug mode should start.
  116449. * The value goes from -1 (full screen) to 1 (not visible)
  116450. * It helps with side by side comparison against the final render
  116451. * This defaults to -1
  116452. */
  116453. private debugLimit;
  116454. /**
  116455. * @hidden
  116456. * This is reserved for the inspector.
  116457. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116458. * You can use the factor to better multiply the final value.
  116459. */
  116460. private debugFactor;
  116461. /**
  116462. * Defines the clear coat layer parameters for the material.
  116463. */
  116464. readonly clearCoat: PBRClearCoatConfiguration;
  116465. /**
  116466. * Defines the anisotropic parameters for the material.
  116467. */
  116468. readonly anisotropy: PBRAnisotropicConfiguration;
  116469. /**
  116470. * Defines the BRDF parameters for the material.
  116471. */
  116472. readonly brdf: PBRBRDFConfiguration;
  116473. /**
  116474. * Defines the Sheen parameters for the material.
  116475. */
  116476. readonly sheen: PBRSheenConfiguration;
  116477. /**
  116478. * Defines the SubSurface parameters for the material.
  116479. */
  116480. readonly subSurface: PBRSubSurfaceConfiguration;
  116481. /**
  116482. * Custom callback helping to override the default shader used in the material.
  116483. */
  116484. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116485. protected _rebuildInParallel: boolean;
  116486. /**
  116487. * Instantiates a new PBRMaterial instance.
  116488. *
  116489. * @param name The material name
  116490. * @param scene The scene the material will be use in.
  116491. */
  116492. constructor(name: string, scene: Scene);
  116493. /**
  116494. * Gets a boolean indicating that current material needs to register RTT
  116495. */
  116496. readonly hasRenderTargetTextures: boolean;
  116497. /**
  116498. * Gets the name of the material class.
  116499. */
  116500. getClassName(): string;
  116501. /**
  116502. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116503. */
  116504. /**
  116505. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116506. */
  116507. useLogarithmicDepth: boolean;
  116508. /**
  116509. * Gets the current transparency mode.
  116510. */
  116511. /**
  116512. * Sets the transparency mode of the material.
  116513. *
  116514. * | Value | Type | Description |
  116515. * | ----- | ----------------------------------- | ----------- |
  116516. * | 0 | OPAQUE | |
  116517. * | 1 | ALPHATEST | |
  116518. * | 2 | ALPHABLEND | |
  116519. * | 3 | ALPHATESTANDBLEND | |
  116520. *
  116521. */
  116522. transparencyMode: Nullable<number>;
  116523. /**
  116524. * Returns true if alpha blending should be disabled.
  116525. */
  116526. private readonly _disableAlphaBlending;
  116527. /**
  116528. * Specifies whether or not this material should be rendered in alpha blend mode.
  116529. */
  116530. needAlphaBlending(): boolean;
  116531. /**
  116532. * Specifies if the mesh will require alpha blending.
  116533. * @param mesh - BJS mesh.
  116534. */
  116535. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116536. /**
  116537. * Specifies whether or not this material should be rendered in alpha test mode.
  116538. */
  116539. needAlphaTesting(): boolean;
  116540. /**
  116541. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116542. */
  116543. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116544. /**
  116545. * Gets the texture used for the alpha test.
  116546. */
  116547. getAlphaTestTexture(): Nullable<BaseTexture>;
  116548. /**
  116549. * Specifies that the submesh is ready to be used.
  116550. * @param mesh - BJS mesh.
  116551. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116552. * @param useInstances - Specifies that instances should be used.
  116553. * @returns - boolean indicating that the submesh is ready or not.
  116554. */
  116555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116556. /**
  116557. * Specifies if the material uses metallic roughness workflow.
  116558. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116559. */
  116560. isMetallicWorkflow(): boolean;
  116561. private _prepareEffect;
  116562. private _prepareDefines;
  116563. /**
  116564. * Force shader compilation
  116565. */
  116566. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116567. /**
  116568. * Initializes the uniform buffer layout for the shader.
  116569. */
  116570. buildUniformLayout(): void;
  116571. /**
  116572. * Unbinds the material from the mesh
  116573. */
  116574. unbind(): void;
  116575. /**
  116576. * Binds the submesh data.
  116577. * @param world - The world matrix.
  116578. * @param mesh - The BJS mesh.
  116579. * @param subMesh - A submesh of the BJS mesh.
  116580. */
  116581. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116582. /**
  116583. * Returns the animatable textures.
  116584. * @returns - Array of animatable textures.
  116585. */
  116586. getAnimatables(): IAnimatable[];
  116587. /**
  116588. * Returns the texture used for reflections.
  116589. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116590. */
  116591. private _getReflectionTexture;
  116592. /**
  116593. * Returns an array of the actively used textures.
  116594. * @returns - Array of BaseTextures
  116595. */
  116596. getActiveTextures(): BaseTexture[];
  116597. /**
  116598. * Checks to see if a texture is used in the material.
  116599. * @param texture - Base texture to use.
  116600. * @returns - Boolean specifying if a texture is used in the material.
  116601. */
  116602. hasTexture(texture: BaseTexture): boolean;
  116603. /**
  116604. * Disposes the resources of the material.
  116605. * @param forceDisposeEffect - Forces the disposal of effects.
  116606. * @param forceDisposeTextures - Forces the disposal of all textures.
  116607. */
  116608. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116609. }
  116610. }
  116611. declare module BABYLON {
  116612. /**
  116613. * The Physically based material of BJS.
  116614. *
  116615. * This offers the main features of a standard PBR material.
  116616. * For more information, please refer to the documentation :
  116617. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116618. */
  116619. export class PBRMaterial extends PBRBaseMaterial {
  116620. /**
  116621. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116622. */
  116623. static readonly PBRMATERIAL_OPAQUE: number;
  116624. /**
  116625. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116626. */
  116627. static readonly PBRMATERIAL_ALPHATEST: number;
  116628. /**
  116629. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116630. */
  116631. static readonly PBRMATERIAL_ALPHABLEND: number;
  116632. /**
  116633. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116634. * They are also discarded below the alpha cutoff threshold to improve performances.
  116635. */
  116636. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116637. /**
  116638. * Defines the default value of how much AO map is occluding the analytical lights
  116639. * (point spot...).
  116640. */
  116641. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116642. /**
  116643. * Intensity of the direct lights e.g. the four lights available in your scene.
  116644. * This impacts both the direct diffuse and specular highlights.
  116645. */
  116646. directIntensity: number;
  116647. /**
  116648. * Intensity of the emissive part of the material.
  116649. * This helps controlling the emissive effect without modifying the emissive color.
  116650. */
  116651. emissiveIntensity: number;
  116652. /**
  116653. * Intensity of the environment e.g. how much the environment will light the object
  116654. * either through harmonics for rough material or through the refelction for shiny ones.
  116655. */
  116656. environmentIntensity: number;
  116657. /**
  116658. * This is a special control allowing the reduction of the specular highlights coming from the
  116659. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116660. */
  116661. specularIntensity: number;
  116662. /**
  116663. * Debug Control allowing disabling the bump map on this material.
  116664. */
  116665. disableBumpMap: boolean;
  116666. /**
  116667. * AKA Diffuse Texture in standard nomenclature.
  116668. */
  116669. albedoTexture: BaseTexture;
  116670. /**
  116671. * AKA Occlusion Texture in other nomenclature.
  116672. */
  116673. ambientTexture: BaseTexture;
  116674. /**
  116675. * AKA Occlusion Texture Intensity in other nomenclature.
  116676. */
  116677. ambientTextureStrength: number;
  116678. /**
  116679. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116680. * 1 means it completely occludes it
  116681. * 0 mean it has no impact
  116682. */
  116683. ambientTextureImpactOnAnalyticalLights: number;
  116684. /**
  116685. * Stores the alpha values in a texture.
  116686. */
  116687. opacityTexture: BaseTexture;
  116688. /**
  116689. * Stores the reflection values in a texture.
  116690. */
  116691. reflectionTexture: Nullable<BaseTexture>;
  116692. /**
  116693. * Stores the emissive values in a texture.
  116694. */
  116695. emissiveTexture: BaseTexture;
  116696. /**
  116697. * AKA Specular texture in other nomenclature.
  116698. */
  116699. reflectivityTexture: BaseTexture;
  116700. /**
  116701. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116702. */
  116703. metallicTexture: BaseTexture;
  116704. /**
  116705. * Specifies the metallic scalar of the metallic/roughness workflow.
  116706. * Can also be used to scale the metalness values of the metallic texture.
  116707. */
  116708. metallic: Nullable<number>;
  116709. /**
  116710. * Specifies the roughness scalar of the metallic/roughness workflow.
  116711. * Can also be used to scale the roughness values of the metallic texture.
  116712. */
  116713. roughness: Nullable<number>;
  116714. /**
  116715. * Specifies the an F0 factor to help configuring the material F0.
  116716. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116717. * to 0.5 the previously hard coded value stays the same.
  116718. * Can also be used to scale the F0 values of the metallic texture.
  116719. */
  116720. metallicF0Factor: number;
  116721. /**
  116722. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116723. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116724. * your expectation as it multiplies with the texture data.
  116725. */
  116726. useMetallicF0FactorFromMetallicTexture: boolean;
  116727. /**
  116728. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116729. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116730. */
  116731. microSurfaceTexture: BaseTexture;
  116732. /**
  116733. * Stores surface normal data used to displace a mesh in a texture.
  116734. */
  116735. bumpTexture: BaseTexture;
  116736. /**
  116737. * Stores the pre-calculated light information of a mesh in a texture.
  116738. */
  116739. lightmapTexture: BaseTexture;
  116740. /**
  116741. * Stores the refracted light information in a texture.
  116742. */
  116743. refractionTexture: Nullable<BaseTexture>;
  116744. /**
  116745. * The color of a material in ambient lighting.
  116746. */
  116747. ambientColor: Color3;
  116748. /**
  116749. * AKA Diffuse Color in other nomenclature.
  116750. */
  116751. albedoColor: Color3;
  116752. /**
  116753. * AKA Specular Color in other nomenclature.
  116754. */
  116755. reflectivityColor: Color3;
  116756. /**
  116757. * The color reflected from the material.
  116758. */
  116759. reflectionColor: Color3;
  116760. /**
  116761. * The color emitted from the material.
  116762. */
  116763. emissiveColor: Color3;
  116764. /**
  116765. * AKA Glossiness in other nomenclature.
  116766. */
  116767. microSurface: number;
  116768. /**
  116769. * source material index of refraction (IOR)' / 'destination material IOR.
  116770. */
  116771. indexOfRefraction: number;
  116772. /**
  116773. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116774. */
  116775. invertRefractionY: boolean;
  116776. /**
  116777. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116778. * Materials half opaque for instance using refraction could benefit from this control.
  116779. */
  116780. linkRefractionWithTransparency: boolean;
  116781. /**
  116782. * If true, the light map contains occlusion information instead of lighting info.
  116783. */
  116784. useLightmapAsShadowmap: boolean;
  116785. /**
  116786. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116787. */
  116788. useAlphaFromAlbedoTexture: boolean;
  116789. /**
  116790. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116791. */
  116792. forceAlphaTest: boolean;
  116793. /**
  116794. * Defines the alpha limits in alpha test mode.
  116795. */
  116796. alphaCutOff: number;
  116797. /**
  116798. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116799. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116800. */
  116801. useSpecularOverAlpha: boolean;
  116802. /**
  116803. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116804. */
  116805. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116806. /**
  116807. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116808. */
  116809. useRoughnessFromMetallicTextureAlpha: boolean;
  116810. /**
  116811. * Specifies if the metallic texture contains the roughness information in its green channel.
  116812. */
  116813. useRoughnessFromMetallicTextureGreen: boolean;
  116814. /**
  116815. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116816. */
  116817. useMetallnessFromMetallicTextureBlue: boolean;
  116818. /**
  116819. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116820. */
  116821. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116822. /**
  116823. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116824. */
  116825. useAmbientInGrayScale: boolean;
  116826. /**
  116827. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116828. * The material will try to infer what glossiness each pixel should be.
  116829. */
  116830. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116831. /**
  116832. * BJS is using an harcoded light falloff based on a manually sets up range.
  116833. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116834. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116835. */
  116836. /**
  116837. * BJS is using an harcoded light falloff based on a manually sets up range.
  116838. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116839. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116840. */
  116841. usePhysicalLightFalloff: boolean;
  116842. /**
  116843. * In order to support the falloff compatibility with gltf, a special mode has been added
  116844. * to reproduce the gltf light falloff.
  116845. */
  116846. /**
  116847. * In order to support the falloff compatibility with gltf, a special mode has been added
  116848. * to reproduce the gltf light falloff.
  116849. */
  116850. useGLTFLightFalloff: boolean;
  116851. /**
  116852. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116853. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116854. */
  116855. useRadianceOverAlpha: boolean;
  116856. /**
  116857. * Allows using an object space normal map (instead of tangent space).
  116858. */
  116859. useObjectSpaceNormalMap: boolean;
  116860. /**
  116861. * Allows using the bump map in parallax mode.
  116862. */
  116863. useParallax: boolean;
  116864. /**
  116865. * Allows using the bump map in parallax occlusion mode.
  116866. */
  116867. useParallaxOcclusion: boolean;
  116868. /**
  116869. * Controls the scale bias of the parallax mode.
  116870. */
  116871. parallaxScaleBias: number;
  116872. /**
  116873. * If sets to true, disables all the lights affecting the material.
  116874. */
  116875. disableLighting: boolean;
  116876. /**
  116877. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116878. */
  116879. forceIrradianceInFragment: boolean;
  116880. /**
  116881. * Number of Simultaneous lights allowed on the material.
  116882. */
  116883. maxSimultaneousLights: number;
  116884. /**
  116885. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116886. */
  116887. invertNormalMapX: boolean;
  116888. /**
  116889. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116890. */
  116891. invertNormalMapY: boolean;
  116892. /**
  116893. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116894. */
  116895. twoSidedLighting: boolean;
  116896. /**
  116897. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116898. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116899. */
  116900. useAlphaFresnel: boolean;
  116901. /**
  116902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116903. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116904. */
  116905. useLinearAlphaFresnel: boolean;
  116906. /**
  116907. * Let user defines the brdf lookup texture used for IBL.
  116908. * A default 8bit version is embedded but you could point at :
  116909. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116910. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116911. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116912. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116913. */
  116914. environmentBRDFTexture: Nullable<BaseTexture>;
  116915. /**
  116916. * Force normal to face away from face.
  116917. */
  116918. forceNormalForward: boolean;
  116919. /**
  116920. * Enables specular anti aliasing in the PBR shader.
  116921. * It will both interacts on the Geometry for analytical and IBL lighting.
  116922. * It also prefilter the roughness map based on the bump values.
  116923. */
  116924. enableSpecularAntiAliasing: boolean;
  116925. /**
  116926. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116927. * makes the reflect vector face the model (under horizon).
  116928. */
  116929. useHorizonOcclusion: boolean;
  116930. /**
  116931. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116932. * too much the area relying on ambient texture to define their ambient occlusion.
  116933. */
  116934. useRadianceOcclusion: boolean;
  116935. /**
  116936. * If set to true, no lighting calculations will be applied.
  116937. */
  116938. unlit: boolean;
  116939. /**
  116940. * Gets the image processing configuration used either in this material.
  116941. */
  116942. /**
  116943. * Sets the Default image processing configuration used either in the this material.
  116944. *
  116945. * If sets to null, the scene one is in use.
  116946. */
  116947. imageProcessingConfiguration: ImageProcessingConfiguration;
  116948. /**
  116949. * Gets wether the color curves effect is enabled.
  116950. */
  116951. /**
  116952. * Sets wether the color curves effect is enabled.
  116953. */
  116954. cameraColorCurvesEnabled: boolean;
  116955. /**
  116956. * Gets wether the color grading effect is enabled.
  116957. */
  116958. /**
  116959. * Gets wether the color grading effect is enabled.
  116960. */
  116961. cameraColorGradingEnabled: boolean;
  116962. /**
  116963. * Gets wether tonemapping is enabled or not.
  116964. */
  116965. /**
  116966. * Sets wether tonemapping is enabled or not
  116967. */
  116968. cameraToneMappingEnabled: boolean;
  116969. /**
  116970. * The camera exposure used on this material.
  116971. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116972. * This corresponds to a photographic exposure.
  116973. */
  116974. /**
  116975. * The camera exposure used on this material.
  116976. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116977. * This corresponds to a photographic exposure.
  116978. */
  116979. cameraExposure: number;
  116980. /**
  116981. * Gets The camera contrast used on this material.
  116982. */
  116983. /**
  116984. * Sets The camera contrast used on this material.
  116985. */
  116986. cameraContrast: number;
  116987. /**
  116988. * Gets the Color Grading 2D Lookup Texture.
  116989. */
  116990. /**
  116991. * Sets the Color Grading 2D Lookup Texture.
  116992. */
  116993. cameraColorGradingTexture: Nullable<BaseTexture>;
  116994. /**
  116995. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116996. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116997. * 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;
  116998. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116999. */
  117000. /**
  117001. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117002. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117003. * 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;
  117004. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117005. */
  117006. cameraColorCurves: Nullable<ColorCurves>;
  117007. /**
  117008. * Instantiates a new PBRMaterial instance.
  117009. *
  117010. * @param name The material name
  117011. * @param scene The scene the material will be use in.
  117012. */
  117013. constructor(name: string, scene: Scene);
  117014. /**
  117015. * Returns the name of this material class.
  117016. */
  117017. getClassName(): string;
  117018. /**
  117019. * Makes a duplicate of the current material.
  117020. * @param name - name to use for the new material.
  117021. */
  117022. clone(name: string): PBRMaterial;
  117023. /**
  117024. * Serializes this PBR Material.
  117025. * @returns - An object with the serialized material.
  117026. */
  117027. serialize(): any;
  117028. /**
  117029. * Parses a PBR Material from a serialized object.
  117030. * @param source - Serialized object.
  117031. * @param scene - BJS scene instance.
  117032. * @param rootUrl - url for the scene object
  117033. * @returns - PBRMaterial
  117034. */
  117035. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117036. }
  117037. }
  117038. declare module BABYLON {
  117039. /**
  117040. * Direct draw surface info
  117041. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117042. */
  117043. export interface DDSInfo {
  117044. /**
  117045. * Width of the texture
  117046. */
  117047. width: number;
  117048. /**
  117049. * Width of the texture
  117050. */
  117051. height: number;
  117052. /**
  117053. * Number of Mipmaps for the texture
  117054. * @see https://en.wikipedia.org/wiki/Mipmap
  117055. */
  117056. mipmapCount: number;
  117057. /**
  117058. * If the textures format is a known fourCC format
  117059. * @see https://www.fourcc.org/
  117060. */
  117061. isFourCC: boolean;
  117062. /**
  117063. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117064. */
  117065. isRGB: boolean;
  117066. /**
  117067. * If the texture is a lumincance format
  117068. */
  117069. isLuminance: boolean;
  117070. /**
  117071. * If this is a cube texture
  117072. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117073. */
  117074. isCube: boolean;
  117075. /**
  117076. * If the texture is a compressed format eg. FOURCC_DXT1
  117077. */
  117078. isCompressed: boolean;
  117079. /**
  117080. * The dxgiFormat of the texture
  117081. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117082. */
  117083. dxgiFormat: number;
  117084. /**
  117085. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117086. */
  117087. textureType: number;
  117088. /**
  117089. * Sphericle polynomial created for the dds texture
  117090. */
  117091. sphericalPolynomial?: SphericalPolynomial;
  117092. }
  117093. /**
  117094. * Class used to provide DDS decompression tools
  117095. */
  117096. export class DDSTools {
  117097. /**
  117098. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117099. */
  117100. static StoreLODInAlphaChannel: boolean;
  117101. /**
  117102. * Gets DDS information from an array buffer
  117103. * @param arrayBuffer defines the array buffer to read data from
  117104. * @returns the DDS information
  117105. */
  117106. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117107. private static _FloatView;
  117108. private static _Int32View;
  117109. private static _ToHalfFloat;
  117110. private static _FromHalfFloat;
  117111. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117112. private static _GetHalfFloatRGBAArrayBuffer;
  117113. private static _GetFloatRGBAArrayBuffer;
  117114. private static _GetFloatAsUIntRGBAArrayBuffer;
  117115. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117116. private static _GetRGBAArrayBuffer;
  117117. private static _ExtractLongWordOrder;
  117118. private static _GetRGBArrayBuffer;
  117119. private static _GetLuminanceArrayBuffer;
  117120. /**
  117121. * Uploads DDS Levels to a Babylon Texture
  117122. * @hidden
  117123. */
  117124. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117125. }
  117126. interface ThinEngine {
  117127. /**
  117128. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117129. * @param rootUrl defines the url where the file to load is located
  117130. * @param scene defines the current scene
  117131. * @param lodScale defines scale to apply to the mip map selection
  117132. * @param lodOffset defines offset to apply to the mip map selection
  117133. * @param onLoad defines an optional callback raised when the texture is loaded
  117134. * @param onError defines an optional callback raised if there is an issue to load the texture
  117135. * @param format defines the format of the data
  117136. * @param forcedExtension defines the extension to use to pick the right loader
  117137. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117138. * @returns the cube texture as an InternalTexture
  117139. */
  117140. 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;
  117141. }
  117142. }
  117143. declare module BABYLON {
  117144. /**
  117145. * Implementation of the DDS Texture Loader.
  117146. * @hidden
  117147. */
  117148. export class _DDSTextureLoader implements IInternalTextureLoader {
  117149. /**
  117150. * Defines wether the loader supports cascade loading the different faces.
  117151. */
  117152. readonly supportCascades: boolean;
  117153. /**
  117154. * This returns if the loader support the current file information.
  117155. * @param extension defines the file extension of the file being loaded
  117156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117157. * @param fallback defines the fallback internal texture if any
  117158. * @param isBase64 defines whether the texture is encoded as a base64
  117159. * @param isBuffer defines whether the texture data are stored as a buffer
  117160. * @returns true if the loader can load the specified file
  117161. */
  117162. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117163. /**
  117164. * Transform the url before loading if required.
  117165. * @param rootUrl the url of the texture
  117166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117167. * @returns the transformed texture
  117168. */
  117169. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117170. /**
  117171. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117172. * @param rootUrl the url of the texture
  117173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117174. * @returns the fallback texture
  117175. */
  117176. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117177. /**
  117178. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117179. * @param data contains the texture data
  117180. * @param texture defines the BabylonJS internal texture
  117181. * @param createPolynomials will be true if polynomials have been requested
  117182. * @param onLoad defines the callback to trigger once the texture is ready
  117183. * @param onError defines the callback to trigger in case of error
  117184. */
  117185. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117186. /**
  117187. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117188. * @param data contains the texture data
  117189. * @param texture defines the BabylonJS internal texture
  117190. * @param callback defines the method to call once ready to upload
  117191. */
  117192. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117193. }
  117194. }
  117195. declare module BABYLON {
  117196. /**
  117197. * Implementation of the ENV Texture Loader.
  117198. * @hidden
  117199. */
  117200. export class _ENVTextureLoader implements IInternalTextureLoader {
  117201. /**
  117202. * Defines wether the loader supports cascade loading the different faces.
  117203. */
  117204. readonly supportCascades: boolean;
  117205. /**
  117206. * This returns if the loader support the current file information.
  117207. * @param extension defines the file extension of the file being loaded
  117208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117209. * @param fallback defines the fallback internal texture if any
  117210. * @param isBase64 defines whether the texture is encoded as a base64
  117211. * @param isBuffer defines whether the texture data are stored as a buffer
  117212. * @returns true if the loader can load the specified file
  117213. */
  117214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117215. /**
  117216. * Transform the url before loading if required.
  117217. * @param rootUrl the url of the texture
  117218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117219. * @returns the transformed texture
  117220. */
  117221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117222. /**
  117223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117224. * @param rootUrl the url of the texture
  117225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117226. * @returns the fallback texture
  117227. */
  117228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117229. /**
  117230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117231. * @param data contains the texture data
  117232. * @param texture defines the BabylonJS internal texture
  117233. * @param createPolynomials will be true if polynomials have been requested
  117234. * @param onLoad defines the callback to trigger once the texture is ready
  117235. * @param onError defines the callback to trigger in case of error
  117236. */
  117237. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117238. /**
  117239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117240. * @param data contains the texture data
  117241. * @param texture defines the BabylonJS internal texture
  117242. * @param callback defines the method to call once ready to upload
  117243. */
  117244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117245. }
  117246. }
  117247. declare module BABYLON {
  117248. /**
  117249. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117250. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117251. */
  117252. export class KhronosTextureContainer {
  117253. /** contents of the KTX container file */
  117254. arrayBuffer: any;
  117255. private static HEADER_LEN;
  117256. private static COMPRESSED_2D;
  117257. private static COMPRESSED_3D;
  117258. private static TEX_2D;
  117259. private static TEX_3D;
  117260. /**
  117261. * Gets the openGL type
  117262. */
  117263. glType: number;
  117264. /**
  117265. * Gets the openGL type size
  117266. */
  117267. glTypeSize: number;
  117268. /**
  117269. * Gets the openGL format
  117270. */
  117271. glFormat: number;
  117272. /**
  117273. * Gets the openGL internal format
  117274. */
  117275. glInternalFormat: number;
  117276. /**
  117277. * Gets the base internal format
  117278. */
  117279. glBaseInternalFormat: number;
  117280. /**
  117281. * Gets image width in pixel
  117282. */
  117283. pixelWidth: number;
  117284. /**
  117285. * Gets image height in pixel
  117286. */
  117287. pixelHeight: number;
  117288. /**
  117289. * Gets image depth in pixels
  117290. */
  117291. pixelDepth: number;
  117292. /**
  117293. * Gets the number of array elements
  117294. */
  117295. numberOfArrayElements: number;
  117296. /**
  117297. * Gets the number of faces
  117298. */
  117299. numberOfFaces: number;
  117300. /**
  117301. * Gets the number of mipmap levels
  117302. */
  117303. numberOfMipmapLevels: number;
  117304. /**
  117305. * Gets the bytes of key value data
  117306. */
  117307. bytesOfKeyValueData: number;
  117308. /**
  117309. * Gets the load type
  117310. */
  117311. loadType: number;
  117312. /**
  117313. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117314. */
  117315. isInvalid: boolean;
  117316. /**
  117317. * Creates a new KhronosTextureContainer
  117318. * @param arrayBuffer contents of the KTX container file
  117319. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117320. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117321. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117322. */
  117323. constructor(
  117324. /** contents of the KTX container file */
  117325. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117326. /**
  117327. * Uploads KTX content to a Babylon Texture.
  117328. * It is assumed that the texture has already been created & is currently bound
  117329. * @hidden
  117330. */
  117331. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117332. private _upload2DCompressedLevels;
  117333. }
  117334. }
  117335. declare module BABYLON {
  117336. /**
  117337. * Implementation of the KTX Texture Loader.
  117338. * @hidden
  117339. */
  117340. export class _KTXTextureLoader implements IInternalTextureLoader {
  117341. /**
  117342. * Defines wether the loader supports cascade loading the different faces.
  117343. */
  117344. readonly supportCascades: boolean;
  117345. /**
  117346. * This returns if the loader support the current file information.
  117347. * @param extension defines the file extension of the file being loaded
  117348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117349. * @param fallback defines the fallback internal texture if any
  117350. * @param isBase64 defines whether the texture is encoded as a base64
  117351. * @param isBuffer defines whether the texture data are stored as a buffer
  117352. * @returns true if the loader can load the specified file
  117353. */
  117354. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117355. /**
  117356. * Transform the url before loading if required.
  117357. * @param rootUrl the url of the texture
  117358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117359. * @returns the transformed texture
  117360. */
  117361. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117362. /**
  117363. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117364. * @param rootUrl the url of the texture
  117365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117366. * @returns the fallback texture
  117367. */
  117368. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117369. /**
  117370. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117371. * @param data contains the texture data
  117372. * @param texture defines the BabylonJS internal texture
  117373. * @param createPolynomials will be true if polynomials have been requested
  117374. * @param onLoad defines the callback to trigger once the texture is ready
  117375. * @param onError defines the callback to trigger in case of error
  117376. */
  117377. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117378. /**
  117379. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117380. * @param data contains the texture data
  117381. * @param texture defines the BabylonJS internal texture
  117382. * @param callback defines the method to call once ready to upload
  117383. */
  117384. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117385. }
  117386. }
  117387. declare module BABYLON {
  117388. /**
  117389. * Options for the default xr helper
  117390. */
  117391. export class WebXRDefaultExperienceOptions {
  117392. /**
  117393. * Floor meshes that should be used for teleporting
  117394. */
  117395. floorMeshes: Array<AbstractMesh>;
  117396. /**
  117397. * Enable or disable default UI to enter XR
  117398. */
  117399. disableDefaultUI: boolean;
  117400. }
  117401. /**
  117402. * Default experience which provides a similar setup to the previous webVRExperience
  117403. */
  117404. export class WebXRDefaultExperience {
  117405. /**
  117406. * Base experience
  117407. */
  117408. baseExperience: WebXRExperienceHelper;
  117409. /**
  117410. * Input experience extension
  117411. */
  117412. input: WebXRInput;
  117413. /**
  117414. * Loads the controller models
  117415. */
  117416. controllerModelLoader: WebXRControllerModelLoader;
  117417. /**
  117418. * Enables laser pointer and selection
  117419. */
  117420. pointerSelection: WebXRControllerPointerSelection;
  117421. /**
  117422. * Enables teleportation
  117423. */
  117424. teleportation: WebXRControllerTeleportation;
  117425. /**
  117426. * Enables ui for enetering/exiting xr
  117427. */
  117428. enterExitUI: WebXREnterExitUI;
  117429. /**
  117430. * Default target xr should render to
  117431. */
  117432. renderTarget: WebXRRenderTarget;
  117433. /**
  117434. * Creates the default xr experience
  117435. * @param scene scene
  117436. * @param options options for basic configuration
  117437. * @returns resulting WebXRDefaultExperience
  117438. */
  117439. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117440. private constructor();
  117441. /**
  117442. * DIsposes of the experience helper
  117443. */
  117444. dispose(): void;
  117445. }
  117446. }
  117447. declare module BABYLON {
  117448. /** @hidden */
  117449. export var _forceSceneHelpersToBundle: boolean;
  117450. interface Scene {
  117451. /**
  117452. * Creates a default light for the scene.
  117453. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117454. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117455. */
  117456. createDefaultLight(replace?: boolean): void;
  117457. /**
  117458. * Creates a default camera for the scene.
  117459. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117460. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117461. * @param replace has default false, when true replaces the active camera in the scene
  117462. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117463. */
  117464. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117465. /**
  117466. * Creates a default camera and a default light.
  117467. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117468. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117469. * @param replace has the default false, when true replaces the active camera/light in the scene
  117470. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117471. */
  117472. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117473. /**
  117474. * Creates a new sky box
  117475. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117476. * @param environmentTexture defines the texture to use as environment texture
  117477. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117478. * @param scale defines the overall scale of the skybox
  117479. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117480. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117481. * @returns a new mesh holding the sky box
  117482. */
  117483. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117484. /**
  117485. * Creates a new environment
  117486. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117487. * @param options defines the options you can use to configure the environment
  117488. * @returns the new EnvironmentHelper
  117489. */
  117490. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117491. /**
  117492. * Creates a new VREXperienceHelper
  117493. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117494. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117495. * @returns a new VREXperienceHelper
  117496. */
  117497. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117498. /**
  117499. * Creates a new WebXRDefaultExperience
  117500. * @see http://doc.babylonjs.com/how_to/webxr
  117501. * @param options experience options
  117502. * @returns a promise for a new WebXRDefaultExperience
  117503. */
  117504. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117505. }
  117506. }
  117507. declare module BABYLON {
  117508. /**
  117509. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117510. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117511. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117512. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117513. */
  117514. export class VideoDome extends TransformNode {
  117515. /**
  117516. * Define the video source as a Monoscopic panoramic 360 video.
  117517. */
  117518. static readonly MODE_MONOSCOPIC: number;
  117519. /**
  117520. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117521. */
  117522. static readonly MODE_TOPBOTTOM: number;
  117523. /**
  117524. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117525. */
  117526. static readonly MODE_SIDEBYSIDE: number;
  117527. private _halfDome;
  117528. private _useDirectMapping;
  117529. /**
  117530. * The video texture being displayed on the sphere
  117531. */
  117532. protected _videoTexture: VideoTexture;
  117533. /**
  117534. * Gets the video texture being displayed on the sphere
  117535. */
  117536. readonly videoTexture: VideoTexture;
  117537. /**
  117538. * The skybox material
  117539. */
  117540. protected _material: BackgroundMaterial;
  117541. /**
  117542. * The surface used for the skybox
  117543. */
  117544. protected _mesh: Mesh;
  117545. /**
  117546. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117547. */
  117548. private _halfDomeMask;
  117549. /**
  117550. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117551. * Also see the options.resolution property.
  117552. */
  117553. fovMultiplier: number;
  117554. private _videoMode;
  117555. /**
  117556. * Gets or set the current video mode for the video. It can be:
  117557. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117558. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117559. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117560. */
  117561. videoMode: number;
  117562. /**
  117563. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117564. *
  117565. */
  117566. /**
  117567. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117568. */
  117569. halfDome: boolean;
  117570. /**
  117571. * Oberserver used in Stereoscopic VR Mode.
  117572. */
  117573. private _onBeforeCameraRenderObserver;
  117574. /**
  117575. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117576. * @param name Element's name, child elements will append suffixes for their own names.
  117577. * @param urlsOrVideo defines the url(s) or the video element to use
  117578. * @param options An object containing optional or exposed sub element properties
  117579. */
  117580. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117581. resolution?: number;
  117582. clickToPlay?: boolean;
  117583. autoPlay?: boolean;
  117584. loop?: boolean;
  117585. size?: number;
  117586. poster?: string;
  117587. faceForward?: boolean;
  117588. useDirectMapping?: boolean;
  117589. halfDomeMode?: boolean;
  117590. }, scene: Scene);
  117591. private _changeVideoMode;
  117592. /**
  117593. * Releases resources associated with this node.
  117594. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117595. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117596. */
  117597. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117598. }
  117599. }
  117600. declare module BABYLON {
  117601. /**
  117602. * This class can be used to get instrumentation data from a Babylon engine
  117603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117604. */
  117605. export class EngineInstrumentation implements IDisposable {
  117606. /**
  117607. * Define the instrumented engine.
  117608. */
  117609. engine: Engine;
  117610. private _captureGPUFrameTime;
  117611. private _gpuFrameTimeToken;
  117612. private _gpuFrameTime;
  117613. private _captureShaderCompilationTime;
  117614. private _shaderCompilationTime;
  117615. private _onBeginFrameObserver;
  117616. private _onEndFrameObserver;
  117617. private _onBeforeShaderCompilationObserver;
  117618. private _onAfterShaderCompilationObserver;
  117619. /**
  117620. * Gets the perf counter used for GPU frame time
  117621. */
  117622. readonly gpuFrameTimeCounter: PerfCounter;
  117623. /**
  117624. * Gets the GPU frame time capture status
  117625. */
  117626. /**
  117627. * Enable or disable the GPU frame time capture
  117628. */
  117629. captureGPUFrameTime: boolean;
  117630. /**
  117631. * Gets the perf counter used for shader compilation time
  117632. */
  117633. readonly shaderCompilationTimeCounter: PerfCounter;
  117634. /**
  117635. * Gets the shader compilation time capture status
  117636. */
  117637. /**
  117638. * Enable or disable the shader compilation time capture
  117639. */
  117640. captureShaderCompilationTime: boolean;
  117641. /**
  117642. * Instantiates a new engine instrumentation.
  117643. * This class can be used to get instrumentation data from a Babylon engine
  117644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117645. * @param engine Defines the engine to instrument
  117646. */
  117647. constructor(
  117648. /**
  117649. * Define the instrumented engine.
  117650. */
  117651. engine: Engine);
  117652. /**
  117653. * Dispose and release associated resources.
  117654. */
  117655. dispose(): void;
  117656. }
  117657. }
  117658. declare module BABYLON {
  117659. /**
  117660. * This class can be used to get instrumentation data from a Babylon engine
  117661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117662. */
  117663. export class SceneInstrumentation implements IDisposable {
  117664. /**
  117665. * Defines the scene to instrument
  117666. */
  117667. scene: Scene;
  117668. private _captureActiveMeshesEvaluationTime;
  117669. private _activeMeshesEvaluationTime;
  117670. private _captureRenderTargetsRenderTime;
  117671. private _renderTargetsRenderTime;
  117672. private _captureFrameTime;
  117673. private _frameTime;
  117674. private _captureRenderTime;
  117675. private _renderTime;
  117676. private _captureInterFrameTime;
  117677. private _interFrameTime;
  117678. private _captureParticlesRenderTime;
  117679. private _particlesRenderTime;
  117680. private _captureSpritesRenderTime;
  117681. private _spritesRenderTime;
  117682. private _capturePhysicsTime;
  117683. private _physicsTime;
  117684. private _captureAnimationsTime;
  117685. private _animationsTime;
  117686. private _captureCameraRenderTime;
  117687. private _cameraRenderTime;
  117688. private _onBeforeActiveMeshesEvaluationObserver;
  117689. private _onAfterActiveMeshesEvaluationObserver;
  117690. private _onBeforeRenderTargetsRenderObserver;
  117691. private _onAfterRenderTargetsRenderObserver;
  117692. private _onAfterRenderObserver;
  117693. private _onBeforeDrawPhaseObserver;
  117694. private _onAfterDrawPhaseObserver;
  117695. private _onBeforeAnimationsObserver;
  117696. private _onBeforeParticlesRenderingObserver;
  117697. private _onAfterParticlesRenderingObserver;
  117698. private _onBeforeSpritesRenderingObserver;
  117699. private _onAfterSpritesRenderingObserver;
  117700. private _onBeforePhysicsObserver;
  117701. private _onAfterPhysicsObserver;
  117702. private _onAfterAnimationsObserver;
  117703. private _onBeforeCameraRenderObserver;
  117704. private _onAfterCameraRenderObserver;
  117705. /**
  117706. * Gets the perf counter used for active meshes evaluation time
  117707. */
  117708. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117709. /**
  117710. * Gets the active meshes evaluation time capture status
  117711. */
  117712. /**
  117713. * Enable or disable the active meshes evaluation time capture
  117714. */
  117715. captureActiveMeshesEvaluationTime: boolean;
  117716. /**
  117717. * Gets the perf counter used for render targets render time
  117718. */
  117719. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117720. /**
  117721. * Gets the render targets render time capture status
  117722. */
  117723. /**
  117724. * Enable or disable the render targets render time capture
  117725. */
  117726. captureRenderTargetsRenderTime: boolean;
  117727. /**
  117728. * Gets the perf counter used for particles render time
  117729. */
  117730. readonly particlesRenderTimeCounter: PerfCounter;
  117731. /**
  117732. * Gets the particles render time capture status
  117733. */
  117734. /**
  117735. * Enable or disable the particles render time capture
  117736. */
  117737. captureParticlesRenderTime: boolean;
  117738. /**
  117739. * Gets the perf counter used for sprites render time
  117740. */
  117741. readonly spritesRenderTimeCounter: PerfCounter;
  117742. /**
  117743. * Gets the sprites render time capture status
  117744. */
  117745. /**
  117746. * Enable or disable the sprites render time capture
  117747. */
  117748. captureSpritesRenderTime: boolean;
  117749. /**
  117750. * Gets the perf counter used for physics time
  117751. */
  117752. readonly physicsTimeCounter: PerfCounter;
  117753. /**
  117754. * Gets the physics time capture status
  117755. */
  117756. /**
  117757. * Enable or disable the physics time capture
  117758. */
  117759. capturePhysicsTime: boolean;
  117760. /**
  117761. * Gets the perf counter used for animations time
  117762. */
  117763. readonly animationsTimeCounter: PerfCounter;
  117764. /**
  117765. * Gets the animations time capture status
  117766. */
  117767. /**
  117768. * Enable or disable the animations time capture
  117769. */
  117770. captureAnimationsTime: boolean;
  117771. /**
  117772. * Gets the perf counter used for frame time capture
  117773. */
  117774. readonly frameTimeCounter: PerfCounter;
  117775. /**
  117776. * Gets the frame time capture status
  117777. */
  117778. /**
  117779. * Enable or disable the frame time capture
  117780. */
  117781. captureFrameTime: boolean;
  117782. /**
  117783. * Gets the perf counter used for inter-frames time capture
  117784. */
  117785. readonly interFrameTimeCounter: PerfCounter;
  117786. /**
  117787. * Gets the inter-frames time capture status
  117788. */
  117789. /**
  117790. * Enable or disable the inter-frames time capture
  117791. */
  117792. captureInterFrameTime: boolean;
  117793. /**
  117794. * Gets the perf counter used for render time capture
  117795. */
  117796. readonly renderTimeCounter: PerfCounter;
  117797. /**
  117798. * Gets the render time capture status
  117799. */
  117800. /**
  117801. * Enable or disable the render time capture
  117802. */
  117803. captureRenderTime: boolean;
  117804. /**
  117805. * Gets the perf counter used for camera render time capture
  117806. */
  117807. readonly cameraRenderTimeCounter: PerfCounter;
  117808. /**
  117809. * Gets the camera render time capture status
  117810. */
  117811. /**
  117812. * Enable or disable the camera render time capture
  117813. */
  117814. captureCameraRenderTime: boolean;
  117815. /**
  117816. * Gets the perf counter used for draw calls
  117817. */
  117818. readonly drawCallsCounter: PerfCounter;
  117819. /**
  117820. * Instantiates a new scene instrumentation.
  117821. * This class can be used to get instrumentation data from a Babylon engine
  117822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117823. * @param scene Defines the scene to instrument
  117824. */
  117825. constructor(
  117826. /**
  117827. * Defines the scene to instrument
  117828. */
  117829. scene: Scene);
  117830. /**
  117831. * Dispose and release associated resources.
  117832. */
  117833. dispose(): void;
  117834. }
  117835. }
  117836. declare module BABYLON {
  117837. /** @hidden */
  117838. export var glowMapGenerationPixelShader: {
  117839. name: string;
  117840. shader: string;
  117841. };
  117842. }
  117843. declare module BABYLON {
  117844. /** @hidden */
  117845. export var glowMapGenerationVertexShader: {
  117846. name: string;
  117847. shader: string;
  117848. };
  117849. }
  117850. declare module BABYLON {
  117851. /**
  117852. * Effect layer options. This helps customizing the behaviour
  117853. * of the effect layer.
  117854. */
  117855. export interface IEffectLayerOptions {
  117856. /**
  117857. * Multiplication factor apply to the canvas size to compute the render target size
  117858. * used to generated the objects (the smaller the faster).
  117859. */
  117860. mainTextureRatio: number;
  117861. /**
  117862. * Enforces a fixed size texture to ensure effect stability across devices.
  117863. */
  117864. mainTextureFixedSize?: number;
  117865. /**
  117866. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117867. */
  117868. alphaBlendingMode: number;
  117869. /**
  117870. * The camera attached to the layer.
  117871. */
  117872. camera: Nullable<Camera>;
  117873. /**
  117874. * The rendering group to draw the layer in.
  117875. */
  117876. renderingGroupId: number;
  117877. }
  117878. /**
  117879. * The effect layer Helps adding post process effect blended with the main pass.
  117880. *
  117881. * This can be for instance use to generate glow or higlight effects on the scene.
  117882. *
  117883. * The effect layer class can not be used directly and is intented to inherited from to be
  117884. * customized per effects.
  117885. */
  117886. export abstract class EffectLayer {
  117887. private _vertexBuffers;
  117888. private _indexBuffer;
  117889. private _cachedDefines;
  117890. private _effectLayerMapGenerationEffect;
  117891. private _effectLayerOptions;
  117892. private _mergeEffect;
  117893. protected _scene: Scene;
  117894. protected _engine: Engine;
  117895. protected _maxSize: number;
  117896. protected _mainTextureDesiredSize: ISize;
  117897. protected _mainTexture: RenderTargetTexture;
  117898. protected _shouldRender: boolean;
  117899. protected _postProcesses: PostProcess[];
  117900. protected _textures: BaseTexture[];
  117901. protected _emissiveTextureAndColor: {
  117902. texture: Nullable<BaseTexture>;
  117903. color: Color4;
  117904. };
  117905. /**
  117906. * The name of the layer
  117907. */
  117908. name: string;
  117909. /**
  117910. * The clear color of the texture used to generate the glow map.
  117911. */
  117912. neutralColor: Color4;
  117913. /**
  117914. * Specifies wether the highlight layer is enabled or not.
  117915. */
  117916. isEnabled: boolean;
  117917. /**
  117918. * Gets the camera attached to the layer.
  117919. */
  117920. readonly camera: Nullable<Camera>;
  117921. /**
  117922. * Gets the rendering group id the layer should render in.
  117923. */
  117924. renderingGroupId: number;
  117925. /**
  117926. * An event triggered when the effect layer has been disposed.
  117927. */
  117928. onDisposeObservable: Observable<EffectLayer>;
  117929. /**
  117930. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117931. */
  117932. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117933. /**
  117934. * An event triggered when the generated texture is being merged in the scene.
  117935. */
  117936. onBeforeComposeObservable: Observable<EffectLayer>;
  117937. /**
  117938. * An event triggered when the mesh is rendered into the effect render target.
  117939. */
  117940. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117941. /**
  117942. * An event triggered after the mesh has been rendered into the effect render target.
  117943. */
  117944. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117945. /**
  117946. * An event triggered when the generated texture has been merged in the scene.
  117947. */
  117948. onAfterComposeObservable: Observable<EffectLayer>;
  117949. /**
  117950. * An event triggered when the efffect layer changes its size.
  117951. */
  117952. onSizeChangedObservable: Observable<EffectLayer>;
  117953. /** @hidden */
  117954. static _SceneComponentInitialization: (scene: Scene) => void;
  117955. /**
  117956. * Instantiates a new effect Layer and references it in the scene.
  117957. * @param name The name of the layer
  117958. * @param scene The scene to use the layer in
  117959. */
  117960. constructor(
  117961. /** The Friendly of the effect in the scene */
  117962. name: string, scene: Scene);
  117963. /**
  117964. * Get the effect name of the layer.
  117965. * @return The effect name
  117966. */
  117967. abstract getEffectName(): string;
  117968. /**
  117969. * Checks for the readiness of the element composing the layer.
  117970. * @param subMesh the mesh to check for
  117971. * @param useInstances specify wether or not to use instances to render the mesh
  117972. * @return true if ready otherwise, false
  117973. */
  117974. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117975. /**
  117976. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117977. * @returns true if the effect requires stencil during the main canvas render pass.
  117978. */
  117979. abstract needStencil(): boolean;
  117980. /**
  117981. * Create the merge effect. This is the shader use to blit the information back
  117982. * to the main canvas at the end of the scene rendering.
  117983. * @returns The effect containing the shader used to merge the effect on the main canvas
  117984. */
  117985. protected abstract _createMergeEffect(): Effect;
  117986. /**
  117987. * Creates the render target textures and post processes used in the effect layer.
  117988. */
  117989. protected abstract _createTextureAndPostProcesses(): void;
  117990. /**
  117991. * Implementation specific of rendering the generating effect on the main canvas.
  117992. * @param effect The effect used to render through
  117993. */
  117994. protected abstract _internalRender(effect: Effect): void;
  117995. /**
  117996. * Sets the required values for both the emissive texture and and the main color.
  117997. */
  117998. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117999. /**
  118000. * Free any resources and references associated to a mesh.
  118001. * Internal use
  118002. * @param mesh The mesh to free.
  118003. */
  118004. abstract _disposeMesh(mesh: Mesh): void;
  118005. /**
  118006. * Serializes this layer (Glow or Highlight for example)
  118007. * @returns a serialized layer object
  118008. */
  118009. abstract serialize?(): any;
  118010. /**
  118011. * Initializes the effect layer with the required options.
  118012. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118013. */
  118014. protected _init(options: Partial<IEffectLayerOptions>): void;
  118015. /**
  118016. * Generates the index buffer of the full screen quad blending to the main canvas.
  118017. */
  118018. private _generateIndexBuffer;
  118019. /**
  118020. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118021. */
  118022. private _generateVertexBuffer;
  118023. /**
  118024. * Sets the main texture desired size which is the closest power of two
  118025. * of the engine canvas size.
  118026. */
  118027. private _setMainTextureSize;
  118028. /**
  118029. * Creates the main texture for the effect layer.
  118030. */
  118031. protected _createMainTexture(): void;
  118032. /**
  118033. * Adds specific effects defines.
  118034. * @param defines The defines to add specifics to.
  118035. */
  118036. protected _addCustomEffectDefines(defines: string[]): void;
  118037. /**
  118038. * Checks for the readiness of the element composing the layer.
  118039. * @param subMesh the mesh to check for
  118040. * @param useInstances specify wether or not to use instances to render the mesh
  118041. * @param emissiveTexture the associated emissive texture used to generate the glow
  118042. * @return true if ready otherwise, false
  118043. */
  118044. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118045. /**
  118046. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118047. */
  118048. render(): void;
  118049. /**
  118050. * Determine if a given mesh will be used in the current effect.
  118051. * @param mesh mesh to test
  118052. * @returns true if the mesh will be used
  118053. */
  118054. hasMesh(mesh: AbstractMesh): boolean;
  118055. /**
  118056. * Returns true if the layer contains information to display, otherwise false.
  118057. * @returns true if the glow layer should be rendered
  118058. */
  118059. shouldRender(): boolean;
  118060. /**
  118061. * Returns true if the mesh should render, otherwise false.
  118062. * @param mesh The mesh to render
  118063. * @returns true if it should render otherwise false
  118064. */
  118065. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118066. /**
  118067. * Returns true if the mesh can be rendered, otherwise false.
  118068. * @param mesh The mesh to render
  118069. * @param material The material used on the mesh
  118070. * @returns true if it can be rendered otherwise false
  118071. */
  118072. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118073. /**
  118074. * Returns true if the mesh should render, otherwise false.
  118075. * @param mesh The mesh to render
  118076. * @returns true if it should render otherwise false
  118077. */
  118078. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118079. /**
  118080. * Renders the submesh passed in parameter to the generation map.
  118081. */
  118082. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118083. /**
  118084. * Defines wether the current material of the mesh should be use to render the effect.
  118085. * @param mesh defines the current mesh to render
  118086. */
  118087. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118088. /**
  118089. * Rebuild the required buffers.
  118090. * @hidden Internal use only.
  118091. */
  118092. _rebuild(): void;
  118093. /**
  118094. * Dispose only the render target textures and post process.
  118095. */
  118096. private _disposeTextureAndPostProcesses;
  118097. /**
  118098. * Dispose the highlight layer and free resources.
  118099. */
  118100. dispose(): void;
  118101. /**
  118102. * Gets the class name of the effect layer
  118103. * @returns the string with the class name of the effect layer
  118104. */
  118105. getClassName(): string;
  118106. /**
  118107. * Creates an effect layer from parsed effect layer data
  118108. * @param parsedEffectLayer defines effect layer data
  118109. * @param scene defines the current scene
  118110. * @param rootUrl defines the root URL containing the effect layer information
  118111. * @returns a parsed effect Layer
  118112. */
  118113. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118114. }
  118115. }
  118116. declare module BABYLON {
  118117. interface AbstractScene {
  118118. /**
  118119. * The list of effect layers (highlights/glow) added to the scene
  118120. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118121. * @see http://doc.babylonjs.com/how_to/glow_layer
  118122. */
  118123. effectLayers: Array<EffectLayer>;
  118124. /**
  118125. * Removes the given effect layer from this scene.
  118126. * @param toRemove defines the effect layer to remove
  118127. * @returns the index of the removed effect layer
  118128. */
  118129. removeEffectLayer(toRemove: EffectLayer): number;
  118130. /**
  118131. * Adds the given effect layer to this scene
  118132. * @param newEffectLayer defines the effect layer to add
  118133. */
  118134. addEffectLayer(newEffectLayer: EffectLayer): void;
  118135. }
  118136. /**
  118137. * Defines the layer scene component responsible to manage any effect layers
  118138. * in a given scene.
  118139. */
  118140. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118141. /**
  118142. * The component name helpfull to identify the component in the list of scene components.
  118143. */
  118144. readonly name: string;
  118145. /**
  118146. * The scene the component belongs to.
  118147. */
  118148. scene: Scene;
  118149. private _engine;
  118150. private _renderEffects;
  118151. private _needStencil;
  118152. private _previousStencilState;
  118153. /**
  118154. * Creates a new instance of the component for the given scene
  118155. * @param scene Defines the scene to register the component in
  118156. */
  118157. constructor(scene: Scene);
  118158. /**
  118159. * Registers the component in a given scene
  118160. */
  118161. register(): void;
  118162. /**
  118163. * Rebuilds the elements related to this component in case of
  118164. * context lost for instance.
  118165. */
  118166. rebuild(): void;
  118167. /**
  118168. * Serializes the component data to the specified json object
  118169. * @param serializationObject The object to serialize to
  118170. */
  118171. serialize(serializationObject: any): void;
  118172. /**
  118173. * Adds all the elements from the container to the scene
  118174. * @param container the container holding the elements
  118175. */
  118176. addFromContainer(container: AbstractScene): void;
  118177. /**
  118178. * Removes all the elements in the container from the scene
  118179. * @param container contains the elements to remove
  118180. * @param dispose if the removed element should be disposed (default: false)
  118181. */
  118182. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118183. /**
  118184. * Disposes the component and the associated ressources.
  118185. */
  118186. dispose(): void;
  118187. private _isReadyForMesh;
  118188. private _renderMainTexture;
  118189. private _setStencil;
  118190. private _setStencilBack;
  118191. private _draw;
  118192. private _drawCamera;
  118193. private _drawRenderingGroup;
  118194. }
  118195. }
  118196. declare module BABYLON {
  118197. /** @hidden */
  118198. export var glowMapMergePixelShader: {
  118199. name: string;
  118200. shader: string;
  118201. };
  118202. }
  118203. declare module BABYLON {
  118204. /** @hidden */
  118205. export var glowMapMergeVertexShader: {
  118206. name: string;
  118207. shader: string;
  118208. };
  118209. }
  118210. declare module BABYLON {
  118211. interface AbstractScene {
  118212. /**
  118213. * Return a the first highlight layer of the scene with a given name.
  118214. * @param name The name of the highlight layer to look for.
  118215. * @return The highlight layer if found otherwise null.
  118216. */
  118217. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118218. }
  118219. /**
  118220. * Glow layer options. This helps customizing the behaviour
  118221. * of the glow layer.
  118222. */
  118223. export interface IGlowLayerOptions {
  118224. /**
  118225. * Multiplication factor apply to the canvas size to compute the render target size
  118226. * used to generated the glowing objects (the smaller the faster).
  118227. */
  118228. mainTextureRatio: number;
  118229. /**
  118230. * Enforces a fixed size texture to ensure resize independant blur.
  118231. */
  118232. mainTextureFixedSize?: number;
  118233. /**
  118234. * How big is the kernel of the blur texture.
  118235. */
  118236. blurKernelSize: number;
  118237. /**
  118238. * The camera attached to the layer.
  118239. */
  118240. camera: Nullable<Camera>;
  118241. /**
  118242. * Enable MSAA by chosing the number of samples.
  118243. */
  118244. mainTextureSamples?: number;
  118245. /**
  118246. * The rendering group to draw the layer in.
  118247. */
  118248. renderingGroupId: number;
  118249. }
  118250. /**
  118251. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118252. *
  118253. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118254. *
  118255. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118256. */
  118257. export class GlowLayer extends EffectLayer {
  118258. /**
  118259. * Effect Name of the layer.
  118260. */
  118261. static readonly EffectName: string;
  118262. /**
  118263. * The default blur kernel size used for the glow.
  118264. */
  118265. static DefaultBlurKernelSize: number;
  118266. /**
  118267. * The default texture size ratio used for the glow.
  118268. */
  118269. static DefaultTextureRatio: number;
  118270. /**
  118271. * Sets the kernel size of the blur.
  118272. */
  118273. /**
  118274. * Gets the kernel size of the blur.
  118275. */
  118276. blurKernelSize: number;
  118277. /**
  118278. * Sets the glow intensity.
  118279. */
  118280. /**
  118281. * Gets the glow intensity.
  118282. */
  118283. intensity: number;
  118284. private _options;
  118285. private _intensity;
  118286. private _horizontalBlurPostprocess1;
  118287. private _verticalBlurPostprocess1;
  118288. private _horizontalBlurPostprocess2;
  118289. private _verticalBlurPostprocess2;
  118290. private _blurTexture1;
  118291. private _blurTexture2;
  118292. private _postProcesses1;
  118293. private _postProcesses2;
  118294. private _includedOnlyMeshes;
  118295. private _excludedMeshes;
  118296. private _meshesUsingTheirOwnMaterials;
  118297. /**
  118298. * Callback used to let the user override the color selection on a per mesh basis
  118299. */
  118300. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118301. /**
  118302. * Callback used to let the user override the texture selection on a per mesh basis
  118303. */
  118304. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118305. /**
  118306. * Instantiates a new glow Layer and references it to the scene.
  118307. * @param name The name of the layer
  118308. * @param scene The scene to use the layer in
  118309. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118310. */
  118311. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118312. /**
  118313. * Get the effect name of the layer.
  118314. * @return The effect name
  118315. */
  118316. getEffectName(): string;
  118317. /**
  118318. * Create the merge effect. This is the shader use to blit the information back
  118319. * to the main canvas at the end of the scene rendering.
  118320. */
  118321. protected _createMergeEffect(): Effect;
  118322. /**
  118323. * Creates the render target textures and post processes used in the glow layer.
  118324. */
  118325. protected _createTextureAndPostProcesses(): void;
  118326. /**
  118327. * Checks for the readiness of the element composing the layer.
  118328. * @param subMesh the mesh to check for
  118329. * @param useInstances specify wether or not to use instances to render the mesh
  118330. * @param emissiveTexture the associated emissive texture used to generate the glow
  118331. * @return true if ready otherwise, false
  118332. */
  118333. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118334. /**
  118335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118336. */
  118337. needStencil(): boolean;
  118338. /**
  118339. * Returns true if the mesh can be rendered, otherwise false.
  118340. * @param mesh The mesh to render
  118341. * @param material The material used on the mesh
  118342. * @returns true if it can be rendered otherwise false
  118343. */
  118344. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118345. /**
  118346. * Implementation specific of rendering the generating effect on the main canvas.
  118347. * @param effect The effect used to render through
  118348. */
  118349. protected _internalRender(effect: Effect): void;
  118350. /**
  118351. * Sets the required values for both the emissive texture and and the main color.
  118352. */
  118353. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118354. /**
  118355. * Returns true if the mesh should render, otherwise false.
  118356. * @param mesh The mesh to render
  118357. * @returns true if it should render otherwise false
  118358. */
  118359. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118360. /**
  118361. * Adds specific effects defines.
  118362. * @param defines The defines to add specifics to.
  118363. */
  118364. protected _addCustomEffectDefines(defines: string[]): void;
  118365. /**
  118366. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118367. * @param mesh The mesh to exclude from the glow layer
  118368. */
  118369. addExcludedMesh(mesh: Mesh): void;
  118370. /**
  118371. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118372. * @param mesh The mesh to remove
  118373. */
  118374. removeExcludedMesh(mesh: Mesh): void;
  118375. /**
  118376. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118377. * @param mesh The mesh to include in the glow layer
  118378. */
  118379. addIncludedOnlyMesh(mesh: Mesh): void;
  118380. /**
  118381. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118382. * @param mesh The mesh to remove
  118383. */
  118384. removeIncludedOnlyMesh(mesh: Mesh): void;
  118385. /**
  118386. * Determine if a given mesh will be used in the glow layer
  118387. * @param mesh The mesh to test
  118388. * @returns true if the mesh will be highlighted by the current glow layer
  118389. */
  118390. hasMesh(mesh: AbstractMesh): boolean;
  118391. /**
  118392. * Defines wether the current material of the mesh should be use to render the effect.
  118393. * @param mesh defines the current mesh to render
  118394. */
  118395. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118396. /**
  118397. * Add a mesh to be rendered through its own material and not with emissive only.
  118398. * @param mesh The mesh for which we need to use its material
  118399. */
  118400. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118401. /**
  118402. * Remove a mesh from being rendered through its own material and not with emissive only.
  118403. * @param mesh The mesh for which we need to not use its material
  118404. */
  118405. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118406. /**
  118407. * Free any resources and references associated to a mesh.
  118408. * Internal use
  118409. * @param mesh The mesh to free.
  118410. * @hidden
  118411. */
  118412. _disposeMesh(mesh: Mesh): void;
  118413. /**
  118414. * Gets the class name of the effect layer
  118415. * @returns the string with the class name of the effect layer
  118416. */
  118417. getClassName(): string;
  118418. /**
  118419. * Serializes this glow layer
  118420. * @returns a serialized glow layer object
  118421. */
  118422. serialize(): any;
  118423. /**
  118424. * Creates a Glow Layer from parsed glow layer data
  118425. * @param parsedGlowLayer defines glow layer data
  118426. * @param scene defines the current scene
  118427. * @param rootUrl defines the root URL containing the glow layer information
  118428. * @returns a parsed Glow Layer
  118429. */
  118430. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118431. }
  118432. }
  118433. declare module BABYLON {
  118434. /** @hidden */
  118435. export var glowBlurPostProcessPixelShader: {
  118436. name: string;
  118437. shader: string;
  118438. };
  118439. }
  118440. declare module BABYLON {
  118441. interface AbstractScene {
  118442. /**
  118443. * Return a the first highlight layer of the scene with a given name.
  118444. * @param name The name of the highlight layer to look for.
  118445. * @return The highlight layer if found otherwise null.
  118446. */
  118447. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118448. }
  118449. /**
  118450. * Highlight layer options. This helps customizing the behaviour
  118451. * of the highlight layer.
  118452. */
  118453. export interface IHighlightLayerOptions {
  118454. /**
  118455. * Multiplication factor apply to the canvas size to compute the render target size
  118456. * used to generated the glowing objects (the smaller the faster).
  118457. */
  118458. mainTextureRatio: number;
  118459. /**
  118460. * Enforces a fixed size texture to ensure resize independant blur.
  118461. */
  118462. mainTextureFixedSize?: number;
  118463. /**
  118464. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118465. * of the picture to blur (the smaller the faster).
  118466. */
  118467. blurTextureSizeRatio: number;
  118468. /**
  118469. * How big in texel of the blur texture is the vertical blur.
  118470. */
  118471. blurVerticalSize: number;
  118472. /**
  118473. * How big in texel of the blur texture is the horizontal blur.
  118474. */
  118475. blurHorizontalSize: number;
  118476. /**
  118477. * Alpha blending mode used to apply the blur. Default is combine.
  118478. */
  118479. alphaBlendingMode: number;
  118480. /**
  118481. * The camera attached to the layer.
  118482. */
  118483. camera: Nullable<Camera>;
  118484. /**
  118485. * Should we display highlight as a solid stroke?
  118486. */
  118487. isStroke?: boolean;
  118488. /**
  118489. * The rendering group to draw the layer in.
  118490. */
  118491. renderingGroupId: number;
  118492. }
  118493. /**
  118494. * The highlight layer Helps adding a glow effect around a mesh.
  118495. *
  118496. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118497. * glowy meshes to your scene.
  118498. *
  118499. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118500. */
  118501. export class HighlightLayer extends EffectLayer {
  118502. name: string;
  118503. /**
  118504. * Effect Name of the highlight layer.
  118505. */
  118506. static readonly EffectName: string;
  118507. /**
  118508. * The neutral color used during the preparation of the glow effect.
  118509. * This is black by default as the blend operation is a blend operation.
  118510. */
  118511. static NeutralColor: Color4;
  118512. /**
  118513. * Stencil value used for glowing meshes.
  118514. */
  118515. static GlowingMeshStencilReference: number;
  118516. /**
  118517. * Stencil value used for the other meshes in the scene.
  118518. */
  118519. static NormalMeshStencilReference: number;
  118520. /**
  118521. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118522. */
  118523. innerGlow: boolean;
  118524. /**
  118525. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118526. */
  118527. outerGlow: boolean;
  118528. /**
  118529. * Specifies the horizontal size of the blur.
  118530. */
  118531. /**
  118532. * Gets the horizontal size of the blur.
  118533. */
  118534. blurHorizontalSize: number;
  118535. /**
  118536. * Specifies the vertical size of the blur.
  118537. */
  118538. /**
  118539. * Gets the vertical size of the blur.
  118540. */
  118541. blurVerticalSize: number;
  118542. /**
  118543. * An event triggered when the highlight layer is being blurred.
  118544. */
  118545. onBeforeBlurObservable: Observable<HighlightLayer>;
  118546. /**
  118547. * An event triggered when the highlight layer has been blurred.
  118548. */
  118549. onAfterBlurObservable: Observable<HighlightLayer>;
  118550. private _instanceGlowingMeshStencilReference;
  118551. private _options;
  118552. private _downSamplePostprocess;
  118553. private _horizontalBlurPostprocess;
  118554. private _verticalBlurPostprocess;
  118555. private _blurTexture;
  118556. private _meshes;
  118557. private _excludedMeshes;
  118558. /**
  118559. * Instantiates a new highlight Layer and references it to the scene..
  118560. * @param name The name of the layer
  118561. * @param scene The scene to use the layer in
  118562. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118563. */
  118564. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118565. /**
  118566. * Get the effect name of the layer.
  118567. * @return The effect name
  118568. */
  118569. getEffectName(): string;
  118570. /**
  118571. * Create the merge effect. This is the shader use to blit the information back
  118572. * to the main canvas at the end of the scene rendering.
  118573. */
  118574. protected _createMergeEffect(): Effect;
  118575. /**
  118576. * Creates the render target textures and post processes used in the highlight layer.
  118577. */
  118578. protected _createTextureAndPostProcesses(): void;
  118579. /**
  118580. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118581. */
  118582. needStencil(): boolean;
  118583. /**
  118584. * Checks for the readiness of the element composing the layer.
  118585. * @param subMesh the mesh to check for
  118586. * @param useInstances specify wether or not to use instances to render the mesh
  118587. * @param emissiveTexture the associated emissive texture used to generate the glow
  118588. * @return true if ready otherwise, false
  118589. */
  118590. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118591. /**
  118592. * Implementation specific of rendering the generating effect on the main canvas.
  118593. * @param effect The effect used to render through
  118594. */
  118595. protected _internalRender(effect: Effect): void;
  118596. /**
  118597. * Returns true if the layer contains information to display, otherwise false.
  118598. */
  118599. shouldRender(): boolean;
  118600. /**
  118601. * Returns true if the mesh should render, otherwise false.
  118602. * @param mesh The mesh to render
  118603. * @returns true if it should render otherwise false
  118604. */
  118605. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118606. /**
  118607. * Sets the required values for both the emissive texture and and the main color.
  118608. */
  118609. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118610. /**
  118611. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118612. * @param mesh The mesh to exclude from the highlight layer
  118613. */
  118614. addExcludedMesh(mesh: Mesh): void;
  118615. /**
  118616. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118617. * @param mesh The mesh to highlight
  118618. */
  118619. removeExcludedMesh(mesh: Mesh): void;
  118620. /**
  118621. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118622. * @param mesh mesh to test
  118623. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118624. */
  118625. hasMesh(mesh: AbstractMesh): boolean;
  118626. /**
  118627. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118628. * @param mesh The mesh to highlight
  118629. * @param color The color of the highlight
  118630. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118631. */
  118632. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118633. /**
  118634. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118635. * @param mesh The mesh to highlight
  118636. */
  118637. removeMesh(mesh: Mesh): void;
  118638. /**
  118639. * Force the stencil to the normal expected value for none glowing parts
  118640. */
  118641. private _defaultStencilReference;
  118642. /**
  118643. * Free any resources and references associated to a mesh.
  118644. * Internal use
  118645. * @param mesh The mesh to free.
  118646. * @hidden
  118647. */
  118648. _disposeMesh(mesh: Mesh): void;
  118649. /**
  118650. * Dispose the highlight layer and free resources.
  118651. */
  118652. dispose(): void;
  118653. /**
  118654. * Gets the class name of the effect layer
  118655. * @returns the string with the class name of the effect layer
  118656. */
  118657. getClassName(): string;
  118658. /**
  118659. * Serializes this Highlight layer
  118660. * @returns a serialized Highlight layer object
  118661. */
  118662. serialize(): any;
  118663. /**
  118664. * Creates a Highlight layer from parsed Highlight layer data
  118665. * @param parsedHightlightLayer defines the Highlight layer data
  118666. * @param scene defines the current scene
  118667. * @param rootUrl defines the root URL containing the Highlight layer information
  118668. * @returns a parsed Highlight layer
  118669. */
  118670. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118671. }
  118672. }
  118673. declare module BABYLON {
  118674. interface AbstractScene {
  118675. /**
  118676. * The list of layers (background and foreground) of the scene
  118677. */
  118678. layers: Array<Layer>;
  118679. }
  118680. /**
  118681. * Defines the layer scene component responsible to manage any layers
  118682. * in a given scene.
  118683. */
  118684. export class LayerSceneComponent implements ISceneComponent {
  118685. /**
  118686. * The component name helpfull to identify the component in the list of scene components.
  118687. */
  118688. readonly name: string;
  118689. /**
  118690. * The scene the component belongs to.
  118691. */
  118692. scene: Scene;
  118693. private _engine;
  118694. /**
  118695. * Creates a new instance of the component for the given scene
  118696. * @param scene Defines the scene to register the component in
  118697. */
  118698. constructor(scene: Scene);
  118699. /**
  118700. * Registers the component in a given scene
  118701. */
  118702. register(): void;
  118703. /**
  118704. * Rebuilds the elements related to this component in case of
  118705. * context lost for instance.
  118706. */
  118707. rebuild(): void;
  118708. /**
  118709. * Disposes the component and the associated ressources.
  118710. */
  118711. dispose(): void;
  118712. private _draw;
  118713. private _drawCameraPredicate;
  118714. private _drawCameraBackground;
  118715. private _drawCameraForeground;
  118716. private _drawRenderTargetPredicate;
  118717. private _drawRenderTargetBackground;
  118718. private _drawRenderTargetForeground;
  118719. /**
  118720. * Adds all the elements from the container to the scene
  118721. * @param container the container holding the elements
  118722. */
  118723. addFromContainer(container: AbstractScene): void;
  118724. /**
  118725. * Removes all the elements in the container from the scene
  118726. * @param container contains the elements to remove
  118727. * @param dispose if the removed element should be disposed (default: false)
  118728. */
  118729. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118730. }
  118731. }
  118732. declare module BABYLON {
  118733. /** @hidden */
  118734. export var layerPixelShader: {
  118735. name: string;
  118736. shader: string;
  118737. };
  118738. }
  118739. declare module BABYLON {
  118740. /** @hidden */
  118741. export var layerVertexShader: {
  118742. name: string;
  118743. shader: string;
  118744. };
  118745. }
  118746. declare module BABYLON {
  118747. /**
  118748. * This represents a full screen 2d layer.
  118749. * This can be useful to display a picture in the background of your scene for instance.
  118750. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118751. */
  118752. export class Layer {
  118753. /**
  118754. * Define the name of the layer.
  118755. */
  118756. name: string;
  118757. /**
  118758. * Define the texture the layer should display.
  118759. */
  118760. texture: Nullable<Texture>;
  118761. /**
  118762. * Is the layer in background or foreground.
  118763. */
  118764. isBackground: boolean;
  118765. /**
  118766. * Define the color of the layer (instead of texture).
  118767. */
  118768. color: Color4;
  118769. /**
  118770. * Define the scale of the layer in order to zoom in out of the texture.
  118771. */
  118772. scale: Vector2;
  118773. /**
  118774. * Define an offset for the layer in order to shift the texture.
  118775. */
  118776. offset: Vector2;
  118777. /**
  118778. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118779. */
  118780. alphaBlendingMode: number;
  118781. /**
  118782. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118783. * Alpha test will not mix with the background color in case of transparency.
  118784. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118785. */
  118786. alphaTest: boolean;
  118787. /**
  118788. * Define a mask to restrict the layer to only some of the scene cameras.
  118789. */
  118790. layerMask: number;
  118791. /**
  118792. * Define the list of render target the layer is visible into.
  118793. */
  118794. renderTargetTextures: RenderTargetTexture[];
  118795. /**
  118796. * Define if the layer is only used in renderTarget or if it also
  118797. * renders in the main frame buffer of the canvas.
  118798. */
  118799. renderOnlyInRenderTargetTextures: boolean;
  118800. private _scene;
  118801. private _vertexBuffers;
  118802. private _indexBuffer;
  118803. private _effect;
  118804. private _alphaTestEffect;
  118805. /**
  118806. * An event triggered when the layer is disposed.
  118807. */
  118808. onDisposeObservable: Observable<Layer>;
  118809. private _onDisposeObserver;
  118810. /**
  118811. * Back compatibility with callback before the onDisposeObservable existed.
  118812. * The set callback will be triggered when the layer has been disposed.
  118813. */
  118814. onDispose: () => void;
  118815. /**
  118816. * An event triggered before rendering the scene
  118817. */
  118818. onBeforeRenderObservable: Observable<Layer>;
  118819. private _onBeforeRenderObserver;
  118820. /**
  118821. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118822. * The set callback will be triggered just before rendering the layer.
  118823. */
  118824. onBeforeRender: () => void;
  118825. /**
  118826. * An event triggered after rendering the scene
  118827. */
  118828. onAfterRenderObservable: Observable<Layer>;
  118829. private _onAfterRenderObserver;
  118830. /**
  118831. * Back compatibility with callback before the onAfterRenderObservable existed.
  118832. * The set callback will be triggered just after rendering the layer.
  118833. */
  118834. onAfterRender: () => void;
  118835. /**
  118836. * Instantiates a new layer.
  118837. * This represents a full screen 2d layer.
  118838. * This can be useful to display a picture in the background of your scene for instance.
  118839. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118840. * @param name Define the name of the layer in the scene
  118841. * @param imgUrl Define the url of the texture to display in the layer
  118842. * @param scene Define the scene the layer belongs to
  118843. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118844. * @param color Defines a color for the layer
  118845. */
  118846. constructor(
  118847. /**
  118848. * Define the name of the layer.
  118849. */
  118850. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118851. private _createIndexBuffer;
  118852. /** @hidden */
  118853. _rebuild(): void;
  118854. /**
  118855. * Renders the layer in the scene.
  118856. */
  118857. render(): void;
  118858. /**
  118859. * Disposes and releases the associated ressources.
  118860. */
  118861. dispose(): void;
  118862. }
  118863. }
  118864. declare module BABYLON {
  118865. /** @hidden */
  118866. export var lensFlarePixelShader: {
  118867. name: string;
  118868. shader: string;
  118869. };
  118870. }
  118871. declare module BABYLON {
  118872. /** @hidden */
  118873. export var lensFlareVertexShader: {
  118874. name: string;
  118875. shader: string;
  118876. };
  118877. }
  118878. declare module BABYLON {
  118879. /**
  118880. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118881. * It is usually composed of several `lensFlare`.
  118882. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118883. */
  118884. export class LensFlareSystem {
  118885. /**
  118886. * Define the name of the lens flare system
  118887. */
  118888. name: string;
  118889. /**
  118890. * List of lens flares used in this system.
  118891. */
  118892. lensFlares: LensFlare[];
  118893. /**
  118894. * Define a limit from the border the lens flare can be visible.
  118895. */
  118896. borderLimit: number;
  118897. /**
  118898. * Define a viewport border we do not want to see the lens flare in.
  118899. */
  118900. viewportBorder: number;
  118901. /**
  118902. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118903. */
  118904. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118905. /**
  118906. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118907. */
  118908. layerMask: number;
  118909. /**
  118910. * Define the id of the lens flare system in the scene.
  118911. * (equal to name by default)
  118912. */
  118913. id: string;
  118914. private _scene;
  118915. private _emitter;
  118916. private _vertexBuffers;
  118917. private _indexBuffer;
  118918. private _effect;
  118919. private _positionX;
  118920. private _positionY;
  118921. private _isEnabled;
  118922. /** @hidden */
  118923. static _SceneComponentInitialization: (scene: Scene) => void;
  118924. /**
  118925. * Instantiates a lens flare system.
  118926. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118927. * It is usually composed of several `lensFlare`.
  118928. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118929. * @param name Define the name of the lens flare system in the scene
  118930. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118931. * @param scene Define the scene the lens flare system belongs to
  118932. */
  118933. constructor(
  118934. /**
  118935. * Define the name of the lens flare system
  118936. */
  118937. name: string, emitter: any, scene: Scene);
  118938. /**
  118939. * Define if the lens flare system is enabled.
  118940. */
  118941. isEnabled: boolean;
  118942. /**
  118943. * Get the scene the effects belongs to.
  118944. * @returns the scene holding the lens flare system
  118945. */
  118946. getScene(): Scene;
  118947. /**
  118948. * Get the emitter of the lens flare system.
  118949. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118950. * @returns the emitter of the lens flare system
  118951. */
  118952. getEmitter(): any;
  118953. /**
  118954. * Set the emitter of the lens flare system.
  118955. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118956. * @param newEmitter Define the new emitter of the system
  118957. */
  118958. setEmitter(newEmitter: any): void;
  118959. /**
  118960. * Get the lens flare system emitter position.
  118961. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118962. * @returns the position
  118963. */
  118964. getEmitterPosition(): Vector3;
  118965. /**
  118966. * @hidden
  118967. */
  118968. computeEffectivePosition(globalViewport: Viewport): boolean;
  118969. /** @hidden */
  118970. _isVisible(): boolean;
  118971. /**
  118972. * @hidden
  118973. */
  118974. render(): boolean;
  118975. /**
  118976. * Dispose and release the lens flare with its associated resources.
  118977. */
  118978. dispose(): void;
  118979. /**
  118980. * Parse a lens flare system from a JSON repressentation
  118981. * @param parsedLensFlareSystem Define the JSON to parse
  118982. * @param scene Define the scene the parsed system should be instantiated in
  118983. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118984. * @returns the parsed system
  118985. */
  118986. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118987. /**
  118988. * Serialize the current Lens Flare System into a JSON representation.
  118989. * @returns the serialized JSON
  118990. */
  118991. serialize(): any;
  118992. }
  118993. }
  118994. declare module BABYLON {
  118995. /**
  118996. * This represents one of the lens effect in a `lensFlareSystem`.
  118997. * It controls one of the indiviual texture used in the effect.
  118998. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118999. */
  119000. export class LensFlare {
  119001. /**
  119002. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119003. */
  119004. size: number;
  119005. /**
  119006. * 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.
  119007. */
  119008. position: number;
  119009. /**
  119010. * Define the lens color.
  119011. */
  119012. color: Color3;
  119013. /**
  119014. * Define the lens texture.
  119015. */
  119016. texture: Nullable<Texture>;
  119017. /**
  119018. * Define the alpha mode to render this particular lens.
  119019. */
  119020. alphaMode: number;
  119021. private _system;
  119022. /**
  119023. * Creates a new Lens Flare.
  119024. * This represents one of the lens effect in a `lensFlareSystem`.
  119025. * It controls one of the indiviual texture used in the effect.
  119026. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119027. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119028. * @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.
  119029. * @param color Define the lens color
  119030. * @param imgUrl Define the lens texture url
  119031. * @param system Define the `lensFlareSystem` this flare is part of
  119032. * @returns The newly created Lens Flare
  119033. */
  119034. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119035. /**
  119036. * Instantiates a new Lens Flare.
  119037. * This represents one of the lens effect in a `lensFlareSystem`.
  119038. * It controls one of the indiviual texture used in the effect.
  119039. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119040. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119041. * @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.
  119042. * @param color Define the lens color
  119043. * @param imgUrl Define the lens texture url
  119044. * @param system Define the `lensFlareSystem` this flare is part of
  119045. */
  119046. constructor(
  119047. /**
  119048. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119049. */
  119050. size: number,
  119051. /**
  119052. * 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.
  119053. */
  119054. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119055. /**
  119056. * Dispose and release the lens flare with its associated resources.
  119057. */
  119058. dispose(): void;
  119059. }
  119060. }
  119061. declare module BABYLON {
  119062. interface AbstractScene {
  119063. /**
  119064. * The list of lens flare system added to the scene
  119065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119066. */
  119067. lensFlareSystems: Array<LensFlareSystem>;
  119068. /**
  119069. * Removes the given lens flare system from this scene.
  119070. * @param toRemove The lens flare system to remove
  119071. * @returns The index of the removed lens flare system
  119072. */
  119073. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119074. /**
  119075. * Adds the given lens flare system to this scene
  119076. * @param newLensFlareSystem The lens flare system to add
  119077. */
  119078. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119079. /**
  119080. * Gets a lens flare system using its name
  119081. * @param name defines the name to look for
  119082. * @returns the lens flare system or null if not found
  119083. */
  119084. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119085. /**
  119086. * Gets a lens flare system using its id
  119087. * @param id defines the id to look for
  119088. * @returns the lens flare system or null if not found
  119089. */
  119090. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119091. }
  119092. /**
  119093. * Defines the lens flare scene component responsible to manage any lens flares
  119094. * in a given scene.
  119095. */
  119096. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119097. /**
  119098. * The component name helpfull to identify the component in the list of scene components.
  119099. */
  119100. readonly name: string;
  119101. /**
  119102. * The scene the component belongs to.
  119103. */
  119104. scene: Scene;
  119105. /**
  119106. * Creates a new instance of the component for the given scene
  119107. * @param scene Defines the scene to register the component in
  119108. */
  119109. constructor(scene: Scene);
  119110. /**
  119111. * Registers the component in a given scene
  119112. */
  119113. register(): void;
  119114. /**
  119115. * Rebuilds the elements related to this component in case of
  119116. * context lost for instance.
  119117. */
  119118. rebuild(): void;
  119119. /**
  119120. * Adds all the elements from the container to the scene
  119121. * @param container the container holding the elements
  119122. */
  119123. addFromContainer(container: AbstractScene): void;
  119124. /**
  119125. * Removes all the elements in the container from the scene
  119126. * @param container contains the elements to remove
  119127. * @param dispose if the removed element should be disposed (default: false)
  119128. */
  119129. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119130. /**
  119131. * Serializes the component data to the specified json object
  119132. * @param serializationObject The object to serialize to
  119133. */
  119134. serialize(serializationObject: any): void;
  119135. /**
  119136. * Disposes the component and the associated ressources.
  119137. */
  119138. dispose(): void;
  119139. private _draw;
  119140. }
  119141. }
  119142. declare module BABYLON {
  119143. /**
  119144. * Defines the shadow generator component responsible to manage any shadow generators
  119145. * in a given scene.
  119146. */
  119147. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119148. /**
  119149. * The component name helpfull to identify the component in the list of scene components.
  119150. */
  119151. readonly name: string;
  119152. /**
  119153. * The scene the component belongs to.
  119154. */
  119155. scene: Scene;
  119156. /**
  119157. * Creates a new instance of the component for the given scene
  119158. * @param scene Defines the scene to register the component in
  119159. */
  119160. constructor(scene: Scene);
  119161. /**
  119162. * Registers the component in a given scene
  119163. */
  119164. register(): void;
  119165. /**
  119166. * Rebuilds the elements related to this component in case of
  119167. * context lost for instance.
  119168. */
  119169. rebuild(): void;
  119170. /**
  119171. * Serializes the component data to the specified json object
  119172. * @param serializationObject The object to serialize to
  119173. */
  119174. serialize(serializationObject: any): void;
  119175. /**
  119176. * Adds all the elements from the container to the scene
  119177. * @param container the container holding the elements
  119178. */
  119179. addFromContainer(container: AbstractScene): void;
  119180. /**
  119181. * Removes all the elements in the container from the scene
  119182. * @param container contains the elements to remove
  119183. * @param dispose if the removed element should be disposed (default: false)
  119184. */
  119185. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119186. /**
  119187. * Rebuilds the elements related to this component in case of
  119188. * context lost for instance.
  119189. */
  119190. dispose(): void;
  119191. private _gatherRenderTargets;
  119192. }
  119193. }
  119194. declare module BABYLON {
  119195. /**
  119196. * A point light is a light defined by an unique point in world space.
  119197. * The light is emitted in every direction from this point.
  119198. * A good example of a point light is a standard light bulb.
  119199. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119200. */
  119201. export class PointLight extends ShadowLight {
  119202. private _shadowAngle;
  119203. /**
  119204. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119205. * This specifies what angle the shadow will use to be created.
  119206. *
  119207. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119208. */
  119209. /**
  119210. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119211. * This specifies what angle the shadow will use to be created.
  119212. *
  119213. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119214. */
  119215. shadowAngle: number;
  119216. /**
  119217. * Gets the direction if it has been set.
  119218. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119219. */
  119220. /**
  119221. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119222. */
  119223. direction: Vector3;
  119224. /**
  119225. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119226. * A PointLight emits the light in every direction.
  119227. * It can cast shadows.
  119228. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119229. * ```javascript
  119230. * var pointLight = new PointLight("pl", camera.position, scene);
  119231. * ```
  119232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119233. * @param name The light friendly name
  119234. * @param position The position of the point light in the scene
  119235. * @param scene The scene the lights belongs to
  119236. */
  119237. constructor(name: string, position: Vector3, scene: Scene);
  119238. /**
  119239. * Returns the string "PointLight"
  119240. * @returns the class name
  119241. */
  119242. getClassName(): string;
  119243. /**
  119244. * Returns the integer 0.
  119245. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119246. */
  119247. getTypeID(): number;
  119248. /**
  119249. * Specifies wether or not the shadowmap should be a cube texture.
  119250. * @returns true if the shadowmap needs to be a cube texture.
  119251. */
  119252. needCube(): boolean;
  119253. /**
  119254. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119255. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119256. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119257. */
  119258. getShadowDirection(faceIndex?: number): Vector3;
  119259. /**
  119260. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119261. * - fov = PI / 2
  119262. * - aspect ratio : 1.0
  119263. * - z-near and far equal to the active camera minZ and maxZ.
  119264. * Returns the PointLight.
  119265. */
  119266. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119267. protected _buildUniformLayout(): void;
  119268. /**
  119269. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119270. * @param effect The effect to update
  119271. * @param lightIndex The index of the light in the effect to update
  119272. * @returns The point light
  119273. */
  119274. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119275. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119276. /**
  119277. * Prepares the list of defines specific to the light type.
  119278. * @param defines the list of defines
  119279. * @param lightIndex defines the index of the light for the effect
  119280. */
  119281. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119282. }
  119283. }
  119284. declare module BABYLON {
  119285. /**
  119286. * Header information of HDR texture files.
  119287. */
  119288. export interface HDRInfo {
  119289. /**
  119290. * The height of the texture in pixels.
  119291. */
  119292. height: number;
  119293. /**
  119294. * The width of the texture in pixels.
  119295. */
  119296. width: number;
  119297. /**
  119298. * The index of the beginning of the data in the binary file.
  119299. */
  119300. dataPosition: number;
  119301. }
  119302. /**
  119303. * This groups tools to convert HDR texture to native colors array.
  119304. */
  119305. export class HDRTools {
  119306. private static Ldexp;
  119307. private static Rgbe2float;
  119308. private static readStringLine;
  119309. /**
  119310. * Reads header information from an RGBE texture stored in a native array.
  119311. * More information on this format are available here:
  119312. * https://en.wikipedia.org/wiki/RGBE_image_format
  119313. *
  119314. * @param uint8array The binary file stored in native array.
  119315. * @return The header information.
  119316. */
  119317. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119318. /**
  119319. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119320. * This RGBE texture needs to store the information as a panorama.
  119321. *
  119322. * More information on this format are available here:
  119323. * https://en.wikipedia.org/wiki/RGBE_image_format
  119324. *
  119325. * @param buffer The binary file stored in an array buffer.
  119326. * @param size The expected size of the extracted cubemap.
  119327. * @return The Cube Map information.
  119328. */
  119329. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119330. /**
  119331. * Returns the pixels data extracted from an RGBE texture.
  119332. * This pixels will be stored left to right up to down in the R G B order in one array.
  119333. *
  119334. * More information on this format are available here:
  119335. * https://en.wikipedia.org/wiki/RGBE_image_format
  119336. *
  119337. * @param uint8array The binary file stored in an array buffer.
  119338. * @param hdrInfo The header information of the file.
  119339. * @return The pixels data in RGB right to left up to down order.
  119340. */
  119341. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119342. private static RGBE_ReadPixels_RLE;
  119343. }
  119344. }
  119345. declare module BABYLON {
  119346. /**
  119347. * This represents a texture coming from an HDR input.
  119348. *
  119349. * The only supported format is currently panorama picture stored in RGBE format.
  119350. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119351. */
  119352. export class HDRCubeTexture extends BaseTexture {
  119353. private static _facesMapping;
  119354. private _generateHarmonics;
  119355. private _noMipmap;
  119356. private _textureMatrix;
  119357. private _size;
  119358. private _onLoad;
  119359. private _onError;
  119360. /**
  119361. * The texture URL.
  119362. */
  119363. url: string;
  119364. /**
  119365. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119366. */
  119367. coordinatesMode: number;
  119368. protected _isBlocking: boolean;
  119369. /**
  119370. * Sets wether or not the texture is blocking during loading.
  119371. */
  119372. /**
  119373. * Gets wether or not the texture is blocking during loading.
  119374. */
  119375. isBlocking: boolean;
  119376. protected _rotationY: number;
  119377. /**
  119378. * Sets texture matrix rotation angle around Y axis in radians.
  119379. */
  119380. /**
  119381. * Gets texture matrix rotation angle around Y axis radians.
  119382. */
  119383. rotationY: number;
  119384. /**
  119385. * Gets or sets the center of the bounding box associated with the cube texture
  119386. * It must define where the camera used to render the texture was set
  119387. */
  119388. boundingBoxPosition: Vector3;
  119389. private _boundingBoxSize;
  119390. /**
  119391. * Gets or sets the size of the bounding box associated with the cube texture
  119392. * When defined, the cubemap will switch to local mode
  119393. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119394. * @example https://www.babylonjs-playground.com/#RNASML
  119395. */
  119396. boundingBoxSize: Vector3;
  119397. /**
  119398. * Instantiates an HDRTexture from the following parameters.
  119399. *
  119400. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119401. * @param scene The scene the texture will be used in
  119402. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119403. * @param noMipmap Forces to not generate the mipmap if true
  119404. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119405. * @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)
  119406. * @param reserved Reserved flag for internal use.
  119407. */
  119408. 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>);
  119409. /**
  119410. * Get the current class name of the texture useful for serialization or dynamic coding.
  119411. * @returns "HDRCubeTexture"
  119412. */
  119413. getClassName(): string;
  119414. /**
  119415. * Occurs when the file is raw .hdr file.
  119416. */
  119417. private loadTexture;
  119418. clone(): HDRCubeTexture;
  119419. delayLoad(): void;
  119420. /**
  119421. * Get the texture reflection matrix used to rotate/transform the reflection.
  119422. * @returns the reflection matrix
  119423. */
  119424. getReflectionTextureMatrix(): Matrix;
  119425. /**
  119426. * Set the texture reflection matrix used to rotate/transform the reflection.
  119427. * @param value Define the reflection matrix to set
  119428. */
  119429. setReflectionTextureMatrix(value: Matrix): void;
  119430. /**
  119431. * Parses a JSON representation of an HDR Texture in order to create the texture
  119432. * @param parsedTexture Define the JSON representation
  119433. * @param scene Define the scene the texture should be created in
  119434. * @param rootUrl Define the root url in case we need to load relative dependencies
  119435. * @returns the newly created texture after parsing
  119436. */
  119437. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119438. serialize(): any;
  119439. }
  119440. }
  119441. declare module BABYLON {
  119442. /**
  119443. * Class used to control physics engine
  119444. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119445. */
  119446. export class PhysicsEngine implements IPhysicsEngine {
  119447. private _physicsPlugin;
  119448. /**
  119449. * Global value used to control the smallest number supported by the simulation
  119450. */
  119451. static Epsilon: number;
  119452. private _impostors;
  119453. private _joints;
  119454. /**
  119455. * Gets the gravity vector used by the simulation
  119456. */
  119457. gravity: Vector3;
  119458. /**
  119459. * Factory used to create the default physics plugin.
  119460. * @returns The default physics plugin
  119461. */
  119462. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119463. /**
  119464. * Creates a new Physics Engine
  119465. * @param gravity defines the gravity vector used by the simulation
  119466. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119467. */
  119468. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119469. /**
  119470. * Sets the gravity vector used by the simulation
  119471. * @param gravity defines the gravity vector to use
  119472. */
  119473. setGravity(gravity: Vector3): void;
  119474. /**
  119475. * Set the time step of the physics engine.
  119476. * Default is 1/60.
  119477. * To slow it down, enter 1/600 for example.
  119478. * To speed it up, 1/30
  119479. * @param newTimeStep defines the new timestep to apply to this world.
  119480. */
  119481. setTimeStep(newTimeStep?: number): void;
  119482. /**
  119483. * Get the time step of the physics engine.
  119484. * @returns the current time step
  119485. */
  119486. getTimeStep(): number;
  119487. /**
  119488. * Release all resources
  119489. */
  119490. dispose(): void;
  119491. /**
  119492. * Gets the name of the current physics plugin
  119493. * @returns the name of the plugin
  119494. */
  119495. getPhysicsPluginName(): string;
  119496. /**
  119497. * Adding a new impostor for the impostor tracking.
  119498. * This will be done by the impostor itself.
  119499. * @param impostor the impostor to add
  119500. */
  119501. addImpostor(impostor: PhysicsImpostor): void;
  119502. /**
  119503. * Remove an impostor from the engine.
  119504. * This impostor and its mesh will not longer be updated by the physics engine.
  119505. * @param impostor the impostor to remove
  119506. */
  119507. removeImpostor(impostor: PhysicsImpostor): void;
  119508. /**
  119509. * Add a joint to the physics engine
  119510. * @param mainImpostor defines the main impostor to which the joint is added.
  119511. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119512. * @param joint defines the joint that will connect both impostors.
  119513. */
  119514. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119515. /**
  119516. * Removes a joint from the simulation
  119517. * @param mainImpostor defines the impostor used with the joint
  119518. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119519. * @param joint defines the joint to remove
  119520. */
  119521. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119522. /**
  119523. * Called by the scene. No need to call it.
  119524. * @param delta defines the timespam between frames
  119525. */
  119526. _step(delta: number): void;
  119527. /**
  119528. * Gets the current plugin used to run the simulation
  119529. * @returns current plugin
  119530. */
  119531. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119532. /**
  119533. * Gets the list of physic impostors
  119534. * @returns an array of PhysicsImpostor
  119535. */
  119536. getImpostors(): Array<PhysicsImpostor>;
  119537. /**
  119538. * Gets the impostor for a physics enabled object
  119539. * @param object defines the object impersonated by the impostor
  119540. * @returns the PhysicsImpostor or null if not found
  119541. */
  119542. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119543. /**
  119544. * Gets the impostor for a physics body object
  119545. * @param body defines physics body used by the impostor
  119546. * @returns the PhysicsImpostor or null if not found
  119547. */
  119548. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119549. /**
  119550. * Does a raycast in the physics world
  119551. * @param from when should the ray start?
  119552. * @param to when should the ray end?
  119553. * @returns PhysicsRaycastResult
  119554. */
  119555. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119556. }
  119557. }
  119558. declare module BABYLON {
  119559. /** @hidden */
  119560. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119561. private _useDeltaForWorldStep;
  119562. world: any;
  119563. name: string;
  119564. private _physicsMaterials;
  119565. private _fixedTimeStep;
  119566. private _cannonRaycastResult;
  119567. private _raycastResult;
  119568. private _physicsBodysToRemoveAfterStep;
  119569. BJSCANNON: any;
  119570. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119571. setGravity(gravity: Vector3): void;
  119572. setTimeStep(timeStep: number): void;
  119573. getTimeStep(): number;
  119574. executeStep(delta: number): void;
  119575. private _removeMarkedPhysicsBodiesFromWorld;
  119576. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119577. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119579. private _processChildMeshes;
  119580. removePhysicsBody(impostor: PhysicsImpostor): void;
  119581. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119582. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119583. private _addMaterial;
  119584. private _checkWithEpsilon;
  119585. private _createShape;
  119586. private _createHeightmap;
  119587. private _minus90X;
  119588. private _plus90X;
  119589. private _tmpPosition;
  119590. private _tmpDeltaPosition;
  119591. private _tmpUnityRotation;
  119592. private _updatePhysicsBodyTransformation;
  119593. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119594. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119595. isSupported(): boolean;
  119596. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119597. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119599. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119600. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119601. getBodyMass(impostor: PhysicsImpostor): number;
  119602. getBodyFriction(impostor: PhysicsImpostor): number;
  119603. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119604. getBodyRestitution(impostor: PhysicsImpostor): number;
  119605. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119606. sleepBody(impostor: PhysicsImpostor): void;
  119607. wakeUpBody(impostor: PhysicsImpostor): void;
  119608. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119609. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119610. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119611. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119612. getRadius(impostor: PhysicsImpostor): number;
  119613. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119614. dispose(): void;
  119615. private _extendNamespace;
  119616. /**
  119617. * Does a raycast in the physics world
  119618. * @param from when should the ray start?
  119619. * @param to when should the ray end?
  119620. * @returns PhysicsRaycastResult
  119621. */
  119622. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119623. }
  119624. }
  119625. declare module BABYLON {
  119626. /** @hidden */
  119627. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119628. world: any;
  119629. name: string;
  119630. BJSOIMO: any;
  119631. private _raycastResult;
  119632. constructor(iterations?: number, oimoInjection?: any);
  119633. setGravity(gravity: Vector3): void;
  119634. setTimeStep(timeStep: number): void;
  119635. getTimeStep(): number;
  119636. private _tmpImpostorsArray;
  119637. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119638. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119639. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119640. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119641. private _tmpPositionVector;
  119642. removePhysicsBody(impostor: PhysicsImpostor): void;
  119643. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119644. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119645. isSupported(): boolean;
  119646. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119647. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119648. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119649. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119650. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119651. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119652. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119653. getBodyMass(impostor: PhysicsImpostor): number;
  119654. getBodyFriction(impostor: PhysicsImpostor): number;
  119655. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119656. getBodyRestitution(impostor: PhysicsImpostor): number;
  119657. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119658. sleepBody(impostor: PhysicsImpostor): void;
  119659. wakeUpBody(impostor: PhysicsImpostor): void;
  119660. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119661. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119662. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119663. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119664. getRadius(impostor: PhysicsImpostor): number;
  119665. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119666. dispose(): void;
  119667. /**
  119668. * Does a raycast in the physics world
  119669. * @param from when should the ray start?
  119670. * @param to when should the ray end?
  119671. * @returns PhysicsRaycastResult
  119672. */
  119673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119674. }
  119675. }
  119676. declare module BABYLON {
  119677. /**
  119678. * Class containing static functions to help procedurally build meshes
  119679. */
  119680. export class RibbonBuilder {
  119681. /**
  119682. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119683. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119684. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119685. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119686. * * 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
  119687. * * 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
  119688. * * 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
  119689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119692. * * 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
  119693. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119694. * * 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
  119695. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119697. * @param name defines the name of the mesh
  119698. * @param options defines the options used to create the mesh
  119699. * @param scene defines the hosting scene
  119700. * @returns the ribbon mesh
  119701. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119703. */
  119704. static CreateRibbon(name: string, options: {
  119705. pathArray: Vector3[][];
  119706. closeArray?: boolean;
  119707. closePath?: boolean;
  119708. offset?: number;
  119709. updatable?: boolean;
  119710. sideOrientation?: number;
  119711. frontUVs?: Vector4;
  119712. backUVs?: Vector4;
  119713. instance?: Mesh;
  119714. invertUV?: boolean;
  119715. uvs?: Vector2[];
  119716. colors?: Color4[];
  119717. }, scene?: Nullable<Scene>): Mesh;
  119718. }
  119719. }
  119720. declare module BABYLON {
  119721. /**
  119722. * Class containing static functions to help procedurally build meshes
  119723. */
  119724. export class ShapeBuilder {
  119725. /**
  119726. * 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.
  119727. * * 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.
  119728. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119729. * * 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.
  119730. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119731. * * 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
  119732. * * 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
  119733. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119736. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119738. * @param name defines the name of the mesh
  119739. * @param options defines the options used to create the mesh
  119740. * @param scene defines the hosting scene
  119741. * @returns the extruded shape mesh
  119742. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119744. */
  119745. static ExtrudeShape(name: string, options: {
  119746. shape: Vector3[];
  119747. path: Vector3[];
  119748. scale?: number;
  119749. rotation?: number;
  119750. cap?: number;
  119751. updatable?: boolean;
  119752. sideOrientation?: number;
  119753. frontUVs?: Vector4;
  119754. backUVs?: Vector4;
  119755. instance?: Mesh;
  119756. invertUV?: boolean;
  119757. }, scene?: Nullable<Scene>): Mesh;
  119758. /**
  119759. * Creates an custom extruded shape mesh.
  119760. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119761. * * 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.
  119762. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119763. * * 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
  119764. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119765. * * 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
  119766. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119767. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119768. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119769. * * 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
  119770. * * 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
  119771. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119776. * @param name defines the name of the mesh
  119777. * @param options defines the options used to create the mesh
  119778. * @param scene defines the hosting scene
  119779. * @returns the custom extruded shape mesh
  119780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119783. */
  119784. static ExtrudeShapeCustom(name: string, options: {
  119785. shape: Vector3[];
  119786. path: Vector3[];
  119787. scaleFunction?: any;
  119788. rotationFunction?: any;
  119789. ribbonCloseArray?: boolean;
  119790. ribbonClosePath?: boolean;
  119791. cap?: number;
  119792. updatable?: boolean;
  119793. sideOrientation?: number;
  119794. frontUVs?: Vector4;
  119795. backUVs?: Vector4;
  119796. instance?: Mesh;
  119797. invertUV?: boolean;
  119798. }, scene?: Nullable<Scene>): Mesh;
  119799. private static _ExtrudeShapeGeneric;
  119800. }
  119801. }
  119802. declare module BABYLON {
  119803. /**
  119804. * AmmoJS Physics plugin
  119805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119806. * @see https://github.com/kripken/ammo.js/
  119807. */
  119808. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119809. private _useDeltaForWorldStep;
  119810. /**
  119811. * Reference to the Ammo library
  119812. */
  119813. bjsAMMO: any;
  119814. /**
  119815. * Created ammoJS world which physics bodies are added to
  119816. */
  119817. world: any;
  119818. /**
  119819. * Name of the plugin
  119820. */
  119821. name: string;
  119822. private _timeStep;
  119823. private _fixedTimeStep;
  119824. private _maxSteps;
  119825. private _tmpQuaternion;
  119826. private _tmpAmmoTransform;
  119827. private _tmpAmmoQuaternion;
  119828. private _tmpAmmoConcreteContactResultCallback;
  119829. private _collisionConfiguration;
  119830. private _dispatcher;
  119831. private _overlappingPairCache;
  119832. private _solver;
  119833. private _softBodySolver;
  119834. private _tmpAmmoVectorA;
  119835. private _tmpAmmoVectorB;
  119836. private _tmpAmmoVectorC;
  119837. private _tmpAmmoVectorD;
  119838. private _tmpContactCallbackResult;
  119839. private _tmpAmmoVectorRCA;
  119840. private _tmpAmmoVectorRCB;
  119841. private _raycastResult;
  119842. private static readonly DISABLE_COLLISION_FLAG;
  119843. private static readonly KINEMATIC_FLAG;
  119844. private static readonly DISABLE_DEACTIVATION_FLAG;
  119845. /**
  119846. * Initializes the ammoJS plugin
  119847. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119848. * @param ammoInjection can be used to inject your own ammo reference
  119849. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119850. */
  119851. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119852. /**
  119853. * Sets the gravity of the physics world (m/(s^2))
  119854. * @param gravity Gravity to set
  119855. */
  119856. setGravity(gravity: Vector3): void;
  119857. /**
  119858. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119859. * @param timeStep timestep to use in seconds
  119860. */
  119861. setTimeStep(timeStep: number): void;
  119862. /**
  119863. * 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)
  119864. * @param fixedTimeStep fixedTimeStep to use in seconds
  119865. */
  119866. setFixedTimeStep(fixedTimeStep: number): void;
  119867. /**
  119868. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119869. * @param maxSteps the maximum number of steps by the physics engine per frame
  119870. */
  119871. setMaxSteps(maxSteps: number): void;
  119872. /**
  119873. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119874. * @returns the current timestep in seconds
  119875. */
  119876. getTimeStep(): number;
  119877. private _isImpostorInContact;
  119878. private _isImpostorPairInContact;
  119879. private _stepSimulation;
  119880. /**
  119881. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119882. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119883. * After the step the babylon meshes are set to the position of the physics imposters
  119884. * @param delta amount of time to step forward
  119885. * @param impostors array of imposters to update before/after the step
  119886. */
  119887. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119888. /**
  119889. * Update babylon mesh to match physics world object
  119890. * @param impostor imposter to match
  119891. */
  119892. private _afterSoftStep;
  119893. /**
  119894. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119895. * @param impostor imposter to match
  119896. */
  119897. private _ropeStep;
  119898. /**
  119899. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119900. * @param impostor imposter to match
  119901. */
  119902. private _softbodyOrClothStep;
  119903. private _tmpVector;
  119904. private _tmpMatrix;
  119905. /**
  119906. * Applies an impulse on the imposter
  119907. * @param impostor imposter to apply impulse to
  119908. * @param force amount of force to be applied to the imposter
  119909. * @param contactPoint the location to apply the impulse on the imposter
  119910. */
  119911. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119912. /**
  119913. * Applies a force on the imposter
  119914. * @param impostor imposter to apply force
  119915. * @param force amount of force to be applied to the imposter
  119916. * @param contactPoint the location to apply the force on the imposter
  119917. */
  119918. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119919. /**
  119920. * Creates a physics body using the plugin
  119921. * @param impostor the imposter to create the physics body on
  119922. */
  119923. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119924. /**
  119925. * Removes the physics body from the imposter and disposes of the body's memory
  119926. * @param impostor imposter to remove the physics body from
  119927. */
  119928. removePhysicsBody(impostor: PhysicsImpostor): void;
  119929. /**
  119930. * Generates a joint
  119931. * @param impostorJoint the imposter joint to create the joint with
  119932. */
  119933. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119934. /**
  119935. * Removes a joint
  119936. * @param impostorJoint the imposter joint to remove the joint from
  119937. */
  119938. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119939. private _addMeshVerts;
  119940. /**
  119941. * Initialise the soft body vertices to match its object's (mesh) vertices
  119942. * Softbody vertices (nodes) are in world space and to match this
  119943. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119944. * @param impostor to create the softbody for
  119945. */
  119946. private _softVertexData;
  119947. /**
  119948. * Create an impostor's soft body
  119949. * @param impostor to create the softbody for
  119950. */
  119951. private _createSoftbody;
  119952. /**
  119953. * Create cloth for an impostor
  119954. * @param impostor to create the softbody for
  119955. */
  119956. private _createCloth;
  119957. /**
  119958. * Create rope for an impostor
  119959. * @param impostor to create the softbody for
  119960. */
  119961. private _createRope;
  119962. private _addHullVerts;
  119963. private _createShape;
  119964. /**
  119965. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119966. * @param impostor imposter containing the physics body and babylon object
  119967. */
  119968. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119969. /**
  119970. * Sets the babylon object's position/rotation from the physics body's position/rotation
  119971. * @param impostor imposter containing the physics body and babylon object
  119972. * @param newPosition new position
  119973. * @param newRotation new rotation
  119974. */
  119975. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119976. /**
  119977. * If this plugin is supported
  119978. * @returns true if its supported
  119979. */
  119980. isSupported(): boolean;
  119981. /**
  119982. * Sets the linear velocity of the physics body
  119983. * @param impostor imposter to set the velocity on
  119984. * @param velocity velocity to set
  119985. */
  119986. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119987. /**
  119988. * Sets the angular velocity of the physics body
  119989. * @param impostor imposter to set the velocity on
  119990. * @param velocity velocity to set
  119991. */
  119992. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119993. /**
  119994. * gets the linear velocity
  119995. * @param impostor imposter to get linear velocity from
  119996. * @returns linear velocity
  119997. */
  119998. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119999. /**
  120000. * gets the angular velocity
  120001. * @param impostor imposter to get angular velocity from
  120002. * @returns angular velocity
  120003. */
  120004. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120005. /**
  120006. * Sets the mass of physics body
  120007. * @param impostor imposter to set the mass on
  120008. * @param mass mass to set
  120009. */
  120010. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120011. /**
  120012. * Gets the mass of the physics body
  120013. * @param impostor imposter to get the mass from
  120014. * @returns mass
  120015. */
  120016. getBodyMass(impostor: PhysicsImpostor): number;
  120017. /**
  120018. * Gets friction of the impostor
  120019. * @param impostor impostor to get friction from
  120020. * @returns friction value
  120021. */
  120022. getBodyFriction(impostor: PhysicsImpostor): number;
  120023. /**
  120024. * Sets friction of the impostor
  120025. * @param impostor impostor to set friction on
  120026. * @param friction friction value
  120027. */
  120028. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120029. /**
  120030. * Gets restitution of the impostor
  120031. * @param impostor impostor to get restitution from
  120032. * @returns restitution value
  120033. */
  120034. getBodyRestitution(impostor: PhysicsImpostor): number;
  120035. /**
  120036. * Sets resitution of the impostor
  120037. * @param impostor impostor to set resitution on
  120038. * @param restitution resitution value
  120039. */
  120040. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120041. /**
  120042. * Gets pressure inside the impostor
  120043. * @param impostor impostor to get pressure from
  120044. * @returns pressure value
  120045. */
  120046. getBodyPressure(impostor: PhysicsImpostor): number;
  120047. /**
  120048. * Sets pressure inside a soft body impostor
  120049. * Cloth and rope must remain 0 pressure
  120050. * @param impostor impostor to set pressure on
  120051. * @param pressure pressure value
  120052. */
  120053. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120054. /**
  120055. * Gets stiffness of the impostor
  120056. * @param impostor impostor to get stiffness from
  120057. * @returns pressure value
  120058. */
  120059. getBodyStiffness(impostor: PhysicsImpostor): number;
  120060. /**
  120061. * Sets stiffness of the impostor
  120062. * @param impostor impostor to set stiffness on
  120063. * @param stiffness stiffness value from 0 to 1
  120064. */
  120065. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120066. /**
  120067. * Gets velocityIterations of the impostor
  120068. * @param impostor impostor to get velocity iterations from
  120069. * @returns velocityIterations value
  120070. */
  120071. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120072. /**
  120073. * Sets velocityIterations of the impostor
  120074. * @param impostor impostor to set velocity iterations on
  120075. * @param velocityIterations velocityIterations value
  120076. */
  120077. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120078. /**
  120079. * Gets positionIterations of the impostor
  120080. * @param impostor impostor to get position iterations from
  120081. * @returns positionIterations value
  120082. */
  120083. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120084. /**
  120085. * Sets positionIterations of the impostor
  120086. * @param impostor impostor to set position on
  120087. * @param positionIterations positionIterations value
  120088. */
  120089. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120090. /**
  120091. * Append an anchor to a cloth object
  120092. * @param impostor is the cloth impostor to add anchor to
  120093. * @param otherImpostor is the rigid impostor to anchor to
  120094. * @param width ratio across width from 0 to 1
  120095. * @param height ratio up height from 0 to 1
  120096. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120097. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120098. */
  120099. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120100. /**
  120101. * Append an hook to a rope object
  120102. * @param impostor is the rope impostor to add hook to
  120103. * @param otherImpostor is the rigid impostor to hook to
  120104. * @param length ratio along the rope from 0 to 1
  120105. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120106. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120107. */
  120108. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120109. /**
  120110. * Sleeps the physics body and stops it from being active
  120111. * @param impostor impostor to sleep
  120112. */
  120113. sleepBody(impostor: PhysicsImpostor): void;
  120114. /**
  120115. * Activates the physics body
  120116. * @param impostor impostor to activate
  120117. */
  120118. wakeUpBody(impostor: PhysicsImpostor): void;
  120119. /**
  120120. * Updates the distance parameters of the joint
  120121. * @param joint joint to update
  120122. * @param maxDistance maximum distance of the joint
  120123. * @param minDistance minimum distance of the joint
  120124. */
  120125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120126. /**
  120127. * Sets a motor on the joint
  120128. * @param joint joint to set motor on
  120129. * @param speed speed of the motor
  120130. * @param maxForce maximum force of the motor
  120131. * @param motorIndex index of the motor
  120132. */
  120133. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120134. /**
  120135. * Sets the motors limit
  120136. * @param joint joint to set limit on
  120137. * @param upperLimit upper limit
  120138. * @param lowerLimit lower limit
  120139. */
  120140. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120141. /**
  120142. * Syncs the position and rotation of a mesh with the impostor
  120143. * @param mesh mesh to sync
  120144. * @param impostor impostor to update the mesh with
  120145. */
  120146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120147. /**
  120148. * Gets the radius of the impostor
  120149. * @param impostor impostor to get radius from
  120150. * @returns the radius
  120151. */
  120152. getRadius(impostor: PhysicsImpostor): number;
  120153. /**
  120154. * Gets the box size of the impostor
  120155. * @param impostor impostor to get box size from
  120156. * @param result the resulting box size
  120157. */
  120158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120159. /**
  120160. * Disposes of the impostor
  120161. */
  120162. dispose(): void;
  120163. /**
  120164. * Does a raycast in the physics world
  120165. * @param from when should the ray start?
  120166. * @param to when should the ray end?
  120167. * @returns PhysicsRaycastResult
  120168. */
  120169. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120170. }
  120171. }
  120172. declare module BABYLON {
  120173. interface AbstractScene {
  120174. /**
  120175. * The list of reflection probes added to the scene
  120176. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120177. */
  120178. reflectionProbes: Array<ReflectionProbe>;
  120179. /**
  120180. * Removes the given reflection probe from this scene.
  120181. * @param toRemove The reflection probe to remove
  120182. * @returns The index of the removed reflection probe
  120183. */
  120184. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120185. /**
  120186. * Adds the given reflection probe to this scene.
  120187. * @param newReflectionProbe The reflection probe to add
  120188. */
  120189. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120190. }
  120191. /**
  120192. * Class used to generate realtime reflection / refraction cube textures
  120193. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120194. */
  120195. export class ReflectionProbe {
  120196. /** defines the name of the probe */
  120197. name: string;
  120198. private _scene;
  120199. private _renderTargetTexture;
  120200. private _projectionMatrix;
  120201. private _viewMatrix;
  120202. private _target;
  120203. private _add;
  120204. private _attachedMesh;
  120205. private _invertYAxis;
  120206. /** Gets or sets probe position (center of the cube map) */
  120207. position: Vector3;
  120208. /**
  120209. * Creates a new reflection probe
  120210. * @param name defines the name of the probe
  120211. * @param size defines the texture resolution (for each face)
  120212. * @param scene defines the hosting scene
  120213. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120214. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120215. */
  120216. constructor(
  120217. /** defines the name of the probe */
  120218. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120219. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120220. samples: number;
  120221. /** Gets or sets the refresh rate to use (on every frame by default) */
  120222. refreshRate: number;
  120223. /**
  120224. * Gets the hosting scene
  120225. * @returns a Scene
  120226. */
  120227. getScene(): Scene;
  120228. /** Gets the internal CubeTexture used to render to */
  120229. readonly cubeTexture: RenderTargetTexture;
  120230. /** Gets the list of meshes to render */
  120231. readonly renderList: Nullable<AbstractMesh[]>;
  120232. /**
  120233. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120234. * @param mesh defines the mesh to attach to
  120235. */
  120236. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120237. /**
  120238. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120239. * @param renderingGroupId The rendering group id corresponding to its index
  120240. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120241. */
  120242. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120243. /**
  120244. * Clean all associated resources
  120245. */
  120246. dispose(): void;
  120247. /**
  120248. * Converts the reflection probe information to a readable string for debug purpose.
  120249. * @param fullDetails Supports for multiple levels of logging within scene loading
  120250. * @returns the human readable reflection probe info
  120251. */
  120252. toString(fullDetails?: boolean): string;
  120253. /**
  120254. * Get the class name of the relfection probe.
  120255. * @returns "ReflectionProbe"
  120256. */
  120257. getClassName(): string;
  120258. /**
  120259. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120260. * @returns The JSON representation of the texture
  120261. */
  120262. serialize(): any;
  120263. /**
  120264. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120265. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120266. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120267. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120268. * @returns The parsed reflection probe if successful
  120269. */
  120270. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120271. }
  120272. }
  120273. declare module BABYLON {
  120274. /** @hidden */
  120275. export var _BabylonLoaderRegistered: boolean;
  120276. /**
  120277. * Helps setting up some configuration for the babylon file loader.
  120278. */
  120279. export class BabylonFileLoaderConfiguration {
  120280. /**
  120281. * The loader does not allow injecting custom physix engine into the plugins.
  120282. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120283. * So you could set this variable to your engine import to make it work.
  120284. */
  120285. static LoaderInjectedPhysicsEngine: any;
  120286. }
  120287. }
  120288. declare module BABYLON {
  120289. /**
  120290. * The Physically based simple base material of BJS.
  120291. *
  120292. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120293. * It is used as the base class for both the specGloss and metalRough conventions.
  120294. */
  120295. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120296. /**
  120297. * Number of Simultaneous lights allowed on the material.
  120298. */
  120299. maxSimultaneousLights: number;
  120300. /**
  120301. * If sets to true, disables all the lights affecting the material.
  120302. */
  120303. disableLighting: boolean;
  120304. /**
  120305. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120306. */
  120307. environmentTexture: BaseTexture;
  120308. /**
  120309. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120310. */
  120311. invertNormalMapX: boolean;
  120312. /**
  120313. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120314. */
  120315. invertNormalMapY: boolean;
  120316. /**
  120317. * Normal map used in the model.
  120318. */
  120319. normalTexture: BaseTexture;
  120320. /**
  120321. * Emissivie color used to self-illuminate the model.
  120322. */
  120323. emissiveColor: Color3;
  120324. /**
  120325. * Emissivie texture used to self-illuminate the model.
  120326. */
  120327. emissiveTexture: BaseTexture;
  120328. /**
  120329. * Occlusion Channel Strenght.
  120330. */
  120331. occlusionStrength: number;
  120332. /**
  120333. * Occlusion Texture of the material (adding extra occlusion effects).
  120334. */
  120335. occlusionTexture: BaseTexture;
  120336. /**
  120337. * Defines the alpha limits in alpha test mode.
  120338. */
  120339. alphaCutOff: number;
  120340. /**
  120341. * Gets the current double sided mode.
  120342. */
  120343. /**
  120344. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120345. */
  120346. doubleSided: boolean;
  120347. /**
  120348. * Stores the pre-calculated light information of a mesh in a texture.
  120349. */
  120350. lightmapTexture: BaseTexture;
  120351. /**
  120352. * If true, the light map contains occlusion information instead of lighting info.
  120353. */
  120354. useLightmapAsShadowmap: boolean;
  120355. /**
  120356. * Instantiates a new PBRMaterial instance.
  120357. *
  120358. * @param name The material name
  120359. * @param scene The scene the material will be use in.
  120360. */
  120361. constructor(name: string, scene: Scene);
  120362. getClassName(): string;
  120363. }
  120364. }
  120365. declare module BABYLON {
  120366. /**
  120367. * The PBR material of BJS following the metal roughness convention.
  120368. *
  120369. * This fits to the PBR convention in the GLTF definition:
  120370. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120371. */
  120372. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120373. /**
  120374. * The base color has two different interpretations depending on the value of metalness.
  120375. * When the material is a metal, the base color is the specific measured reflectance value
  120376. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120377. * of the material.
  120378. */
  120379. baseColor: Color3;
  120380. /**
  120381. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120382. * well as opacity information in the alpha channel.
  120383. */
  120384. baseTexture: BaseTexture;
  120385. /**
  120386. * Specifies the metallic scalar value of the material.
  120387. * Can also be used to scale the metalness values of the metallic texture.
  120388. */
  120389. metallic: number;
  120390. /**
  120391. * Specifies the roughness scalar value of the material.
  120392. * Can also be used to scale the roughness values of the metallic texture.
  120393. */
  120394. roughness: number;
  120395. /**
  120396. * Texture containing both the metallic value in the B channel and the
  120397. * roughness value in the G channel to keep better precision.
  120398. */
  120399. metallicRoughnessTexture: BaseTexture;
  120400. /**
  120401. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120402. *
  120403. * @param name The material name
  120404. * @param scene The scene the material will be use in.
  120405. */
  120406. constructor(name: string, scene: Scene);
  120407. /**
  120408. * Return the currrent class name of the material.
  120409. */
  120410. getClassName(): string;
  120411. /**
  120412. * Makes a duplicate of the current material.
  120413. * @param name - name to use for the new material.
  120414. */
  120415. clone(name: string): PBRMetallicRoughnessMaterial;
  120416. /**
  120417. * Serialize the material to a parsable JSON object.
  120418. */
  120419. serialize(): any;
  120420. /**
  120421. * Parses a JSON object correponding to the serialize function.
  120422. */
  120423. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120424. }
  120425. }
  120426. declare module BABYLON {
  120427. /**
  120428. * The PBR material of BJS following the specular glossiness convention.
  120429. *
  120430. * This fits to the PBR convention in the GLTF definition:
  120431. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120432. */
  120433. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120434. /**
  120435. * Specifies the diffuse color of the material.
  120436. */
  120437. diffuseColor: Color3;
  120438. /**
  120439. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120440. * channel.
  120441. */
  120442. diffuseTexture: BaseTexture;
  120443. /**
  120444. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120445. */
  120446. specularColor: Color3;
  120447. /**
  120448. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120449. */
  120450. glossiness: number;
  120451. /**
  120452. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120453. */
  120454. specularGlossinessTexture: BaseTexture;
  120455. /**
  120456. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120457. *
  120458. * @param name The material name
  120459. * @param scene The scene the material will be use in.
  120460. */
  120461. constructor(name: string, scene: Scene);
  120462. /**
  120463. * Return the currrent class name of the material.
  120464. */
  120465. getClassName(): string;
  120466. /**
  120467. * Makes a duplicate of the current material.
  120468. * @param name - name to use for the new material.
  120469. */
  120470. clone(name: string): PBRSpecularGlossinessMaterial;
  120471. /**
  120472. * Serialize the material to a parsable JSON object.
  120473. */
  120474. serialize(): any;
  120475. /**
  120476. * Parses a JSON object correponding to the serialize function.
  120477. */
  120478. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120479. }
  120480. }
  120481. declare module BABYLON {
  120482. /**
  120483. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120484. * It can help converting any input color in a desired output one. This can then be used to create effects
  120485. * from sepia, black and white to sixties or futuristic rendering...
  120486. *
  120487. * The only supported format is currently 3dl.
  120488. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120489. */
  120490. export class ColorGradingTexture extends BaseTexture {
  120491. /**
  120492. * The current texture matrix. (will always be identity in color grading texture)
  120493. */
  120494. private _textureMatrix;
  120495. /**
  120496. * The texture URL.
  120497. */
  120498. url: string;
  120499. /**
  120500. * Empty line regex stored for GC.
  120501. */
  120502. private static _noneEmptyLineRegex;
  120503. private _engine;
  120504. /**
  120505. * Instantiates a ColorGradingTexture from the following parameters.
  120506. *
  120507. * @param url The location of the color gradind data (currently only supporting 3dl)
  120508. * @param scene The scene the texture will be used in
  120509. */
  120510. constructor(url: string, scene: Scene);
  120511. /**
  120512. * Returns the texture matrix used in most of the material.
  120513. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120514. */
  120515. getTextureMatrix(): Matrix;
  120516. /**
  120517. * Occurs when the file being loaded is a .3dl LUT file.
  120518. */
  120519. private load3dlTexture;
  120520. /**
  120521. * Starts the loading process of the texture.
  120522. */
  120523. private loadTexture;
  120524. /**
  120525. * Clones the color gradind texture.
  120526. */
  120527. clone(): ColorGradingTexture;
  120528. /**
  120529. * Called during delayed load for textures.
  120530. */
  120531. delayLoad(): void;
  120532. /**
  120533. * Parses a color grading texture serialized by Babylon.
  120534. * @param parsedTexture The texture information being parsedTexture
  120535. * @param scene The scene to load the texture in
  120536. * @param rootUrl The root url of the data assets to load
  120537. * @return A color gradind texture
  120538. */
  120539. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120540. /**
  120541. * Serializes the LUT texture to json format.
  120542. */
  120543. serialize(): any;
  120544. }
  120545. }
  120546. declare module BABYLON {
  120547. /**
  120548. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120549. */
  120550. export class EquiRectangularCubeTexture extends BaseTexture {
  120551. /** The six faces of the cube. */
  120552. private static _FacesMapping;
  120553. private _noMipmap;
  120554. private _onLoad;
  120555. private _onError;
  120556. /** The size of the cubemap. */
  120557. private _size;
  120558. /** The buffer of the image. */
  120559. private _buffer;
  120560. /** The width of the input image. */
  120561. private _width;
  120562. /** The height of the input image. */
  120563. private _height;
  120564. /** The URL to the image. */
  120565. url: string;
  120566. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120567. coordinatesMode: number;
  120568. /**
  120569. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120570. * @param url The location of the image
  120571. * @param scene The scene the texture will be used in
  120572. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120573. * @param noMipmap Forces to not generate the mipmap if true
  120574. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120575. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120576. * @param onLoad — defines a callback called when texture is loaded
  120577. * @param onError — defines a callback called if there is an error
  120578. */
  120579. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120580. /**
  120581. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120582. */
  120583. private loadImage;
  120584. /**
  120585. * Convert the image buffer into a cubemap and create a CubeTexture.
  120586. */
  120587. private loadTexture;
  120588. /**
  120589. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120590. * @param buffer The ArrayBuffer that should be converted.
  120591. * @returns The buffer as Float32Array.
  120592. */
  120593. private getFloat32ArrayFromArrayBuffer;
  120594. /**
  120595. * Get the current class name of the texture useful for serialization or dynamic coding.
  120596. * @returns "EquiRectangularCubeTexture"
  120597. */
  120598. getClassName(): string;
  120599. /**
  120600. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120601. * @returns A clone of the current EquiRectangularCubeTexture.
  120602. */
  120603. clone(): EquiRectangularCubeTexture;
  120604. }
  120605. }
  120606. declare module BABYLON {
  120607. /**
  120608. * Based on jsTGALoader - Javascript loader for TGA file
  120609. * By Vincent Thibault
  120610. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120611. */
  120612. export class TGATools {
  120613. private static _TYPE_INDEXED;
  120614. private static _TYPE_RGB;
  120615. private static _TYPE_GREY;
  120616. private static _TYPE_RLE_INDEXED;
  120617. private static _TYPE_RLE_RGB;
  120618. private static _TYPE_RLE_GREY;
  120619. private static _ORIGIN_MASK;
  120620. private static _ORIGIN_SHIFT;
  120621. private static _ORIGIN_BL;
  120622. private static _ORIGIN_BR;
  120623. private static _ORIGIN_UL;
  120624. private static _ORIGIN_UR;
  120625. /**
  120626. * Gets the header of a TGA file
  120627. * @param data defines the TGA data
  120628. * @returns the header
  120629. */
  120630. static GetTGAHeader(data: Uint8Array): any;
  120631. /**
  120632. * Uploads TGA content to a Babylon Texture
  120633. * @hidden
  120634. */
  120635. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120636. /** @hidden */
  120637. 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;
  120638. /** @hidden */
  120639. 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;
  120640. /** @hidden */
  120641. 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;
  120642. /** @hidden */
  120643. 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;
  120644. /** @hidden */
  120645. 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;
  120646. /** @hidden */
  120647. 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;
  120648. }
  120649. }
  120650. declare module BABYLON {
  120651. /**
  120652. * Implementation of the TGA Texture Loader.
  120653. * @hidden
  120654. */
  120655. export class _TGATextureLoader implements IInternalTextureLoader {
  120656. /**
  120657. * Defines wether the loader supports cascade loading the different faces.
  120658. */
  120659. readonly supportCascades: boolean;
  120660. /**
  120661. * This returns if the loader support the current file information.
  120662. * @param extension defines the file extension of the file being loaded
  120663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120664. * @param fallback defines the fallback internal texture if any
  120665. * @param isBase64 defines whether the texture is encoded as a base64
  120666. * @param isBuffer defines whether the texture data are stored as a buffer
  120667. * @returns true if the loader can load the specified file
  120668. */
  120669. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120670. /**
  120671. * Transform the url before loading if required.
  120672. * @param rootUrl the url of the texture
  120673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120674. * @returns the transformed texture
  120675. */
  120676. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120677. /**
  120678. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120679. * @param rootUrl the url of the texture
  120680. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120681. * @returns the fallback texture
  120682. */
  120683. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120684. /**
  120685. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120686. * @param data contains the texture data
  120687. * @param texture defines the BabylonJS internal texture
  120688. * @param createPolynomials will be true if polynomials have been requested
  120689. * @param onLoad defines the callback to trigger once the texture is ready
  120690. * @param onError defines the callback to trigger in case of error
  120691. */
  120692. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120693. /**
  120694. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120695. * @param data contains the texture data
  120696. * @param texture defines the BabylonJS internal texture
  120697. * @param callback defines the method to call once ready to upload
  120698. */
  120699. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120700. }
  120701. }
  120702. declare module BABYLON {
  120703. /**
  120704. * Info about the .basis files
  120705. */
  120706. class BasisFileInfo {
  120707. /**
  120708. * If the file has alpha
  120709. */
  120710. hasAlpha: boolean;
  120711. /**
  120712. * Info about each image of the basis file
  120713. */
  120714. images: Array<{
  120715. levels: Array<{
  120716. width: number;
  120717. height: number;
  120718. transcodedPixels: ArrayBufferView;
  120719. }>;
  120720. }>;
  120721. }
  120722. /**
  120723. * Result of transcoding a basis file
  120724. */
  120725. class TranscodeResult {
  120726. /**
  120727. * Info about the .basis file
  120728. */
  120729. fileInfo: BasisFileInfo;
  120730. /**
  120731. * Format to use when loading the file
  120732. */
  120733. format: number;
  120734. }
  120735. /**
  120736. * Configuration options for the Basis transcoder
  120737. */
  120738. export class BasisTranscodeConfiguration {
  120739. /**
  120740. * Supported compression formats used to determine the supported output format of the transcoder
  120741. */
  120742. supportedCompressionFormats?: {
  120743. /**
  120744. * etc1 compression format
  120745. */
  120746. etc1?: boolean;
  120747. /**
  120748. * s3tc compression format
  120749. */
  120750. s3tc?: boolean;
  120751. /**
  120752. * pvrtc compression format
  120753. */
  120754. pvrtc?: boolean;
  120755. /**
  120756. * etc2 compression format
  120757. */
  120758. etc2?: boolean;
  120759. };
  120760. /**
  120761. * If mipmap levels should be loaded for transcoded images (Default: true)
  120762. */
  120763. loadMipmapLevels?: boolean;
  120764. /**
  120765. * Index of a single image to load (Default: all images)
  120766. */
  120767. loadSingleImage?: number;
  120768. }
  120769. /**
  120770. * Used to load .Basis files
  120771. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120772. */
  120773. export class BasisTools {
  120774. private static _IgnoreSupportedFormats;
  120775. /**
  120776. * URL to use when loading the basis transcoder
  120777. */
  120778. static JSModuleURL: string;
  120779. /**
  120780. * URL to use when loading the wasm module for the transcoder
  120781. */
  120782. static WasmModuleURL: string;
  120783. /**
  120784. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120785. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120786. * @returns internal format corresponding to the Basis format
  120787. */
  120788. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120789. private static _WorkerPromise;
  120790. private static _Worker;
  120791. private static _actionId;
  120792. private static _CreateWorkerAsync;
  120793. /**
  120794. * Transcodes a loaded image file to compressed pixel data
  120795. * @param imageData image data to transcode
  120796. * @param config configuration options for the transcoding
  120797. * @returns a promise resulting in the transcoded image
  120798. */
  120799. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120800. /**
  120801. * Loads a texture from the transcode result
  120802. * @param texture texture load to
  120803. * @param transcodeResult the result of transcoding the basis file to load from
  120804. */
  120805. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120806. }
  120807. }
  120808. declare module BABYLON {
  120809. /**
  120810. * Loader for .basis file format
  120811. */
  120812. export class _BasisTextureLoader implements IInternalTextureLoader {
  120813. /**
  120814. * Defines whether the loader supports cascade loading the different faces.
  120815. */
  120816. readonly supportCascades: boolean;
  120817. /**
  120818. * This returns if the loader support the current file information.
  120819. * @param extension defines the file extension of the file being loaded
  120820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120821. * @param fallback defines the fallback internal texture if any
  120822. * @param isBase64 defines whether the texture is encoded as a base64
  120823. * @param isBuffer defines whether the texture data are stored as a buffer
  120824. * @returns true if the loader can load the specified file
  120825. */
  120826. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120827. /**
  120828. * Transform the url before loading if required.
  120829. * @param rootUrl the url of the texture
  120830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120831. * @returns the transformed texture
  120832. */
  120833. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120834. /**
  120835. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120836. * @param rootUrl the url of the texture
  120837. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120838. * @returns the fallback texture
  120839. */
  120840. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120841. /**
  120842. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120843. * @param data contains the texture data
  120844. * @param texture defines the BabylonJS internal texture
  120845. * @param createPolynomials will be true if polynomials have been requested
  120846. * @param onLoad defines the callback to trigger once the texture is ready
  120847. * @param onError defines the callback to trigger in case of error
  120848. */
  120849. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120850. /**
  120851. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120852. * @param data contains the texture data
  120853. * @param texture defines the BabylonJS internal texture
  120854. * @param callback defines the method to call once ready to upload
  120855. */
  120856. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120857. }
  120858. }
  120859. declare module BABYLON {
  120860. /**
  120861. * 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.
  120862. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120863. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120864. */
  120865. export class CustomProceduralTexture extends ProceduralTexture {
  120866. private _animate;
  120867. private _time;
  120868. private _config;
  120869. private _texturePath;
  120870. /**
  120871. * Instantiates a new Custom Procedural Texture.
  120872. * 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.
  120873. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120874. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120875. * @param name Define the name of the texture
  120876. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120877. * @param size Define the size of the texture to create
  120878. * @param scene Define the scene the texture belongs to
  120879. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120880. * @param generateMipMaps Define if the texture should creates mip maps or not
  120881. */
  120882. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120883. private _loadJson;
  120884. /**
  120885. * Is the texture ready to be used ? (rendered at least once)
  120886. * @returns true if ready, otherwise, false.
  120887. */
  120888. isReady(): boolean;
  120889. /**
  120890. * Render the texture to its associated render target.
  120891. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120892. */
  120893. render(useCameraPostProcess?: boolean): void;
  120894. /**
  120895. * Update the list of dependant textures samplers in the shader.
  120896. */
  120897. updateTextures(): void;
  120898. /**
  120899. * Update the uniform values of the procedural texture in the shader.
  120900. */
  120901. updateShaderUniforms(): void;
  120902. /**
  120903. * Define if the texture animates or not.
  120904. */
  120905. animate: boolean;
  120906. }
  120907. }
  120908. declare module BABYLON {
  120909. /** @hidden */
  120910. export var noisePixelShader: {
  120911. name: string;
  120912. shader: string;
  120913. };
  120914. }
  120915. declare module BABYLON {
  120916. /**
  120917. * Class used to generate noise procedural textures
  120918. */
  120919. export class NoiseProceduralTexture extends ProceduralTexture {
  120920. private _time;
  120921. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120922. brightness: number;
  120923. /** Defines the number of octaves to process */
  120924. octaves: number;
  120925. /** Defines the level of persistence (0.8 by default) */
  120926. persistence: number;
  120927. /** Gets or sets animation speed factor (default is 1) */
  120928. animationSpeedFactor: number;
  120929. /**
  120930. * Creates a new NoiseProceduralTexture
  120931. * @param name defines the name fo the texture
  120932. * @param size defines the size of the texture (default is 256)
  120933. * @param scene defines the hosting scene
  120934. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120935. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120936. */
  120937. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120938. private _updateShaderUniforms;
  120939. protected _getDefines(): string;
  120940. /** Generate the current state of the procedural texture */
  120941. render(useCameraPostProcess?: boolean): void;
  120942. /**
  120943. * Serializes this noise procedural texture
  120944. * @returns a serialized noise procedural texture object
  120945. */
  120946. serialize(): any;
  120947. /**
  120948. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120949. * @param parsedTexture defines parsed texture data
  120950. * @param scene defines the current scene
  120951. * @param rootUrl defines the root URL containing noise procedural texture information
  120952. * @returns a parsed NoiseProceduralTexture
  120953. */
  120954. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  120955. }
  120956. }
  120957. declare module BABYLON {
  120958. /**
  120959. * Raw cube texture where the raw buffers are passed in
  120960. */
  120961. export class RawCubeTexture extends CubeTexture {
  120962. /**
  120963. * Creates a cube texture where the raw buffers are passed in.
  120964. * @param scene defines the scene the texture is attached to
  120965. * @param data defines the array of data to use to create each face
  120966. * @param size defines the size of the textures
  120967. * @param format defines the format of the data
  120968. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  120969. * @param generateMipMaps defines if the engine should generate the mip levels
  120970. * @param invertY defines if data must be stored with Y axis inverted
  120971. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  120972. * @param compression defines the compression used (null by default)
  120973. */
  120974. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  120975. /**
  120976. * Updates the raw cube texture.
  120977. * @param data defines the data to store
  120978. * @param format defines the data format
  120979. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120980. * @param invertY defines if data must be stored with Y axis inverted
  120981. * @param compression defines the compression used (null by default)
  120982. * @param level defines which level of the texture to update
  120983. */
  120984. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  120985. /**
  120986. * Updates a raw cube texture with RGBD encoded data.
  120987. * @param data defines the array of data [mipmap][face] to use to create each face
  120988. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  120989. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120990. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120991. * @returns a promsie that resolves when the operation is complete
  120992. */
  120993. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120994. /**
  120995. * Clones the raw cube texture.
  120996. * @return a new cube texture
  120997. */
  120998. clone(): CubeTexture;
  120999. /** @hidden */
  121000. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121001. }
  121002. }
  121003. declare module BABYLON {
  121004. /**
  121005. * Class used to store 3D textures containing user data
  121006. */
  121007. export class RawTexture3D extends Texture {
  121008. /** Gets or sets the texture format to use */
  121009. format: number;
  121010. private _engine;
  121011. /**
  121012. * Create a new RawTexture3D
  121013. * @param data defines the data of the texture
  121014. * @param width defines the width of the texture
  121015. * @param height defines the height of the texture
  121016. * @param depth defines the depth of the texture
  121017. * @param format defines the texture format to use
  121018. * @param scene defines the hosting scene
  121019. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121020. * @param invertY defines if texture must be stored with Y axis inverted
  121021. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121022. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121023. */
  121024. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121025. /** Gets or sets the texture format to use */
  121026. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121027. /**
  121028. * Update the texture with new data
  121029. * @param data defines the data to store in the texture
  121030. */
  121031. update(data: ArrayBufferView): void;
  121032. }
  121033. }
  121034. declare module BABYLON {
  121035. /**
  121036. * Class used to store 2D array textures containing user data
  121037. */
  121038. export class RawTexture2DArray extends Texture {
  121039. /** Gets or sets the texture format to use */
  121040. format: number;
  121041. private _engine;
  121042. /**
  121043. * Create a new RawTexture2DArray
  121044. * @param data defines the data of the texture
  121045. * @param width defines the width of the texture
  121046. * @param height defines the height of the texture
  121047. * @param depth defines the number of layers of the texture
  121048. * @param format defines the texture format to use
  121049. * @param scene defines the hosting scene
  121050. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121051. * @param invertY defines if texture must be stored with Y axis inverted
  121052. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121053. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121054. */
  121055. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121056. /** Gets or sets the texture format to use */
  121057. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121058. /**
  121059. * Update the texture with new data
  121060. * @param data defines the data to store in the texture
  121061. */
  121062. update(data: ArrayBufferView): void;
  121063. }
  121064. }
  121065. declare module BABYLON {
  121066. /**
  121067. * Creates a refraction texture used by refraction channel of the standard material.
  121068. * It is like a mirror but to see through a material.
  121069. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121070. */
  121071. export class RefractionTexture extends RenderTargetTexture {
  121072. /**
  121073. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121074. * 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.
  121075. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121076. */
  121077. refractionPlane: Plane;
  121078. /**
  121079. * Define how deep under the surface we should see.
  121080. */
  121081. depth: number;
  121082. /**
  121083. * Creates a refraction texture used by refraction channel of the standard material.
  121084. * It is like a mirror but to see through a material.
  121085. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121086. * @param name Define the texture name
  121087. * @param size Define the size of the underlying texture
  121088. * @param scene Define the scene the refraction belongs to
  121089. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121090. */
  121091. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121092. /**
  121093. * Clone the refraction texture.
  121094. * @returns the cloned texture
  121095. */
  121096. clone(): RefractionTexture;
  121097. /**
  121098. * Serialize the texture to a JSON representation you could use in Parse later on
  121099. * @returns the serialized JSON representation
  121100. */
  121101. serialize(): any;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Defines the options related to the creation of an HtmlElementTexture
  121107. */
  121108. export interface IHtmlElementTextureOptions {
  121109. /**
  121110. * Defines wether mip maps should be created or not.
  121111. */
  121112. generateMipMaps?: boolean;
  121113. /**
  121114. * Defines the sampling mode of the texture.
  121115. */
  121116. samplingMode?: number;
  121117. /**
  121118. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121119. */
  121120. engine: Nullable<ThinEngine>;
  121121. /**
  121122. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121123. */
  121124. scene: Nullable<Scene>;
  121125. }
  121126. /**
  121127. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121128. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121129. * is automatically managed.
  121130. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121131. * in your application.
  121132. *
  121133. * As the update is not automatic, you need to call them manually.
  121134. */
  121135. export class HtmlElementTexture extends BaseTexture {
  121136. /**
  121137. * The texture URL.
  121138. */
  121139. element: HTMLVideoElement | HTMLCanvasElement;
  121140. private static readonly DefaultOptions;
  121141. private _textureMatrix;
  121142. private _engine;
  121143. private _isVideo;
  121144. private _generateMipMaps;
  121145. private _samplingMode;
  121146. /**
  121147. * Instantiates a HtmlElementTexture from the following parameters.
  121148. *
  121149. * @param name Defines the name of the texture
  121150. * @param element Defines the video or canvas the texture is filled with
  121151. * @param options Defines the other none mandatory texture creation options
  121152. */
  121153. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121154. private _createInternalTexture;
  121155. /**
  121156. * Returns the texture matrix used in most of the material.
  121157. */
  121158. getTextureMatrix(): Matrix;
  121159. /**
  121160. * Updates the content of the texture.
  121161. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121162. */
  121163. update(invertY?: Nullable<boolean>): void;
  121164. }
  121165. }
  121166. declare module BABYLON {
  121167. /**
  121168. * Enum used to define the target of a block
  121169. */
  121170. export enum NodeMaterialBlockTargets {
  121171. /** Vertex shader */
  121172. Vertex = 1,
  121173. /** Fragment shader */
  121174. Fragment = 2,
  121175. /** Neutral */
  121176. Neutral = 4,
  121177. /** Vertex and Fragment */
  121178. VertexAndFragment = 3
  121179. }
  121180. }
  121181. declare module BABYLON {
  121182. /**
  121183. * Defines the kind of connection point for node based material
  121184. */
  121185. export enum NodeMaterialBlockConnectionPointTypes {
  121186. /** Float */
  121187. Float = 1,
  121188. /** Int */
  121189. Int = 2,
  121190. /** Vector2 */
  121191. Vector2 = 4,
  121192. /** Vector3 */
  121193. Vector3 = 8,
  121194. /** Vector4 */
  121195. Vector4 = 16,
  121196. /** Color3 */
  121197. Color3 = 32,
  121198. /** Color4 */
  121199. Color4 = 64,
  121200. /** Matrix */
  121201. Matrix = 128,
  121202. /** Detect type based on connection */
  121203. AutoDetect = 1024,
  121204. /** Output type that will be defined by input type */
  121205. BasedOnInput = 2048
  121206. }
  121207. }
  121208. declare module BABYLON {
  121209. /**
  121210. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121211. */
  121212. export enum NodeMaterialBlockConnectionPointMode {
  121213. /** Value is an uniform */
  121214. Uniform = 0,
  121215. /** Value is a mesh attribute */
  121216. Attribute = 1,
  121217. /** Value is a varying between vertex and fragment shaders */
  121218. Varying = 2,
  121219. /** Mode is undefined */
  121220. Undefined = 3
  121221. }
  121222. }
  121223. declare module BABYLON {
  121224. /**
  121225. * Enum used to define system values e.g. values automatically provided by the system
  121226. */
  121227. export enum NodeMaterialSystemValues {
  121228. /** World */
  121229. World = 1,
  121230. /** View */
  121231. View = 2,
  121232. /** Projection */
  121233. Projection = 3,
  121234. /** ViewProjection */
  121235. ViewProjection = 4,
  121236. /** WorldView */
  121237. WorldView = 5,
  121238. /** WorldViewProjection */
  121239. WorldViewProjection = 6,
  121240. /** CameraPosition */
  121241. CameraPosition = 7,
  121242. /** Fog Color */
  121243. FogColor = 8,
  121244. /** Delta time */
  121245. DeltaTime = 9
  121246. }
  121247. }
  121248. declare module BABYLON {
  121249. /**
  121250. * Root class for all node material optimizers
  121251. */
  121252. export class NodeMaterialOptimizer {
  121253. /**
  121254. * Function used to optimize a NodeMaterial graph
  121255. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121256. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121257. */
  121258. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121259. }
  121260. }
  121261. declare module BABYLON {
  121262. /**
  121263. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121264. */
  121265. export class TransformBlock extends NodeMaterialBlock {
  121266. /**
  121267. * Defines the value to use to complement W value to transform it to a Vector4
  121268. */
  121269. complementW: number;
  121270. /**
  121271. * Defines the value to use to complement z value to transform it to a Vector4
  121272. */
  121273. complementZ: number;
  121274. /**
  121275. * Creates a new TransformBlock
  121276. * @param name defines the block name
  121277. */
  121278. constructor(name: string);
  121279. /**
  121280. * Gets the current class name
  121281. * @returns the class name
  121282. */
  121283. getClassName(): string;
  121284. /**
  121285. * Gets the vector input
  121286. */
  121287. readonly vector: NodeMaterialConnectionPoint;
  121288. /**
  121289. * Gets the output component
  121290. */
  121291. readonly output: NodeMaterialConnectionPoint;
  121292. /**
  121293. * Gets the matrix transform input
  121294. */
  121295. readonly transform: NodeMaterialConnectionPoint;
  121296. protected _buildBlock(state: NodeMaterialBuildState): this;
  121297. serialize(): any;
  121298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121299. protected _dumpPropertiesCode(): string;
  121300. }
  121301. }
  121302. declare module BABYLON {
  121303. /**
  121304. * Block used to output the vertex position
  121305. */
  121306. export class VertexOutputBlock extends NodeMaterialBlock {
  121307. /**
  121308. * Creates a new VertexOutputBlock
  121309. * @param name defines the block name
  121310. */
  121311. constructor(name: string);
  121312. /**
  121313. * Gets the current class name
  121314. * @returns the class name
  121315. */
  121316. getClassName(): string;
  121317. /**
  121318. * Gets the vector input component
  121319. */
  121320. readonly vector: NodeMaterialConnectionPoint;
  121321. protected _buildBlock(state: NodeMaterialBuildState): this;
  121322. }
  121323. }
  121324. declare module BABYLON {
  121325. /**
  121326. * Block used to output the final color
  121327. */
  121328. export class FragmentOutputBlock extends NodeMaterialBlock {
  121329. /**
  121330. * Create a new FragmentOutputBlock
  121331. * @param name defines the block name
  121332. */
  121333. constructor(name: string);
  121334. /**
  121335. * Gets the current class name
  121336. * @returns the class name
  121337. */
  121338. getClassName(): string;
  121339. /**
  121340. * Gets the rgba input component
  121341. */
  121342. readonly rgba: NodeMaterialConnectionPoint;
  121343. /**
  121344. * Gets the rgb input component
  121345. */
  121346. readonly rgb: NodeMaterialConnectionPoint;
  121347. /**
  121348. * Gets the a input component
  121349. */
  121350. readonly a: NodeMaterialConnectionPoint;
  121351. protected _buildBlock(state: NodeMaterialBuildState): this;
  121352. }
  121353. }
  121354. declare module BABYLON {
  121355. /**
  121356. * Block used to read a reflection texture from a sampler
  121357. */
  121358. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121359. private _define3DName;
  121360. private _defineCubicName;
  121361. private _defineExplicitName;
  121362. private _defineProjectionName;
  121363. private _defineLocalCubicName;
  121364. private _defineSphericalName;
  121365. private _definePlanarName;
  121366. private _defineEquirectangularName;
  121367. private _defineMirroredEquirectangularFixedName;
  121368. private _defineEquirectangularFixedName;
  121369. private _defineSkyboxName;
  121370. private _cubeSamplerName;
  121371. private _2DSamplerName;
  121372. private _positionUVWName;
  121373. private _directionWName;
  121374. private _reflectionCoordsName;
  121375. private _reflection2DCoordsName;
  121376. private _reflectionColorName;
  121377. private _reflectionMatrixName;
  121378. /**
  121379. * Gets or sets the texture associated with the node
  121380. */
  121381. texture: Nullable<BaseTexture>;
  121382. /**
  121383. * Create a new TextureBlock
  121384. * @param name defines the block name
  121385. */
  121386. constructor(name: string);
  121387. /**
  121388. * Gets the current class name
  121389. * @returns the class name
  121390. */
  121391. getClassName(): string;
  121392. /**
  121393. * Gets the world position input component
  121394. */
  121395. readonly position: NodeMaterialConnectionPoint;
  121396. /**
  121397. * Gets the world position input component
  121398. */
  121399. readonly worldPosition: NodeMaterialConnectionPoint;
  121400. /**
  121401. * Gets the world normal input component
  121402. */
  121403. readonly worldNormal: NodeMaterialConnectionPoint;
  121404. /**
  121405. * Gets the world input component
  121406. */
  121407. readonly world: NodeMaterialConnectionPoint;
  121408. /**
  121409. * Gets the camera (or eye) position component
  121410. */
  121411. readonly cameraPosition: NodeMaterialConnectionPoint;
  121412. /**
  121413. * Gets the view input component
  121414. */
  121415. readonly view: NodeMaterialConnectionPoint;
  121416. /**
  121417. * Gets the rgb output component
  121418. */
  121419. readonly rgb: NodeMaterialConnectionPoint;
  121420. /**
  121421. * Gets the r output component
  121422. */
  121423. readonly r: NodeMaterialConnectionPoint;
  121424. /**
  121425. * Gets the g output component
  121426. */
  121427. readonly g: NodeMaterialConnectionPoint;
  121428. /**
  121429. * Gets the b output component
  121430. */
  121431. readonly b: NodeMaterialConnectionPoint;
  121432. autoConfigure(material: NodeMaterial): void;
  121433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121434. isReady(): boolean;
  121435. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121436. private _injectVertexCode;
  121437. private _writeOutput;
  121438. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121439. protected _dumpPropertiesCode(): string;
  121440. serialize(): any;
  121441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121442. }
  121443. }
  121444. declare module BABYLON {
  121445. /**
  121446. * Interface used to configure the node material editor
  121447. */
  121448. export interface INodeMaterialEditorOptions {
  121449. /** Define the URl to load node editor script */
  121450. editorURL?: string;
  121451. }
  121452. /** @hidden */
  121453. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121454. /** BONES */
  121455. NUM_BONE_INFLUENCERS: number;
  121456. BonesPerMesh: number;
  121457. BONETEXTURE: boolean;
  121458. /** MORPH TARGETS */
  121459. MORPHTARGETS: boolean;
  121460. MORPHTARGETS_NORMAL: boolean;
  121461. MORPHTARGETS_TANGENT: boolean;
  121462. MORPHTARGETS_UV: boolean;
  121463. NUM_MORPH_INFLUENCERS: number;
  121464. /** IMAGE PROCESSING */
  121465. IMAGEPROCESSING: boolean;
  121466. VIGNETTE: boolean;
  121467. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121468. VIGNETTEBLENDMODEOPAQUE: boolean;
  121469. TONEMAPPING: boolean;
  121470. TONEMAPPING_ACES: boolean;
  121471. CONTRAST: boolean;
  121472. EXPOSURE: boolean;
  121473. COLORCURVES: boolean;
  121474. COLORGRADING: boolean;
  121475. COLORGRADING3D: boolean;
  121476. SAMPLER3DGREENDEPTH: boolean;
  121477. SAMPLER3DBGRMAP: boolean;
  121478. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121479. /** MISC. */
  121480. BUMPDIRECTUV: number;
  121481. constructor();
  121482. setValue(name: string, value: boolean): void;
  121483. }
  121484. /**
  121485. * Class used to configure NodeMaterial
  121486. */
  121487. export interface INodeMaterialOptions {
  121488. /**
  121489. * Defines if blocks should emit comments
  121490. */
  121491. emitComments: boolean;
  121492. }
  121493. /**
  121494. * Class used to create a node based material built by assembling shader blocks
  121495. */
  121496. export class NodeMaterial extends PushMaterial {
  121497. private static _BuildIdGenerator;
  121498. private _options;
  121499. private _vertexCompilationState;
  121500. private _fragmentCompilationState;
  121501. private _sharedData;
  121502. private _buildId;
  121503. private _buildWasSuccessful;
  121504. private _cachedWorldViewMatrix;
  121505. private _cachedWorldViewProjectionMatrix;
  121506. private _optimizers;
  121507. private _animationFrame;
  121508. /** Define the URl to load node editor script */
  121509. static EditorURL: string;
  121510. private BJSNODEMATERIALEDITOR;
  121511. /** Get the inspector from bundle or global */
  121512. private _getGlobalNodeMaterialEditor;
  121513. /**
  121514. * 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)
  121515. */
  121516. ignoreAlpha: boolean;
  121517. /**
  121518. * Defines the maximum number of lights that can be used in the material
  121519. */
  121520. maxSimultaneousLights: number;
  121521. /**
  121522. * Observable raised when the material is built
  121523. */
  121524. onBuildObservable: Observable<NodeMaterial>;
  121525. /**
  121526. * Gets or sets the root nodes of the material vertex shader
  121527. */
  121528. _vertexOutputNodes: NodeMaterialBlock[];
  121529. /**
  121530. * Gets or sets the root nodes of the material fragment (pixel) shader
  121531. */
  121532. _fragmentOutputNodes: NodeMaterialBlock[];
  121533. /** Gets or sets options to control the node material overall behavior */
  121534. options: INodeMaterialOptions;
  121535. /**
  121536. * Default configuration related to image processing available in the standard Material.
  121537. */
  121538. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121539. /**
  121540. * Gets the image processing configuration used either in this material.
  121541. */
  121542. /**
  121543. * Sets the Default image processing configuration used either in the this material.
  121544. *
  121545. * If sets to null, the scene one is in use.
  121546. */
  121547. imageProcessingConfiguration: ImageProcessingConfiguration;
  121548. /**
  121549. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121550. */
  121551. attachedBlocks: NodeMaterialBlock[];
  121552. /**
  121553. * Create a new node based material
  121554. * @param name defines the material name
  121555. * @param scene defines the hosting scene
  121556. * @param options defines creation option
  121557. */
  121558. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121559. /**
  121560. * Gets the current class name of the material e.g. "NodeMaterial"
  121561. * @returns the class name
  121562. */
  121563. getClassName(): string;
  121564. /**
  121565. * Keep track of the image processing observer to allow dispose and replace.
  121566. */
  121567. private _imageProcessingObserver;
  121568. /**
  121569. * Attaches a new image processing configuration to the Standard Material.
  121570. * @param configuration
  121571. */
  121572. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121573. /**
  121574. * Get a block by its name
  121575. * @param name defines the name of the block to retrieve
  121576. * @returns the required block or null if not found
  121577. */
  121578. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121579. /**
  121580. * Get a block by its name
  121581. * @param predicate defines the predicate used to find the good candidate
  121582. * @returns the required block or null if not found
  121583. */
  121584. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121585. /**
  121586. * Get an input block by its name
  121587. * @param predicate defines the predicate used to find the good candidate
  121588. * @returns the required input block or null if not found
  121589. */
  121590. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121591. /**
  121592. * Gets the list of input blocks attached to this material
  121593. * @returns an array of InputBlocks
  121594. */
  121595. getInputBlocks(): InputBlock[];
  121596. /**
  121597. * Adds a new optimizer to the list of optimizers
  121598. * @param optimizer defines the optimizers to add
  121599. * @returns the current material
  121600. */
  121601. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121602. /**
  121603. * Remove an optimizer from the list of optimizers
  121604. * @param optimizer defines the optimizers to remove
  121605. * @returns the current material
  121606. */
  121607. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121608. /**
  121609. * Add a new block to the list of output nodes
  121610. * @param node defines the node to add
  121611. * @returns the current material
  121612. */
  121613. addOutputNode(node: NodeMaterialBlock): this;
  121614. /**
  121615. * Remove a block from the list of root nodes
  121616. * @param node defines the node to remove
  121617. * @returns the current material
  121618. */
  121619. removeOutputNode(node: NodeMaterialBlock): this;
  121620. private _addVertexOutputNode;
  121621. private _removeVertexOutputNode;
  121622. private _addFragmentOutputNode;
  121623. private _removeFragmentOutputNode;
  121624. /**
  121625. * Specifies if the material will require alpha blending
  121626. * @returns a boolean specifying if alpha blending is needed
  121627. */
  121628. needAlphaBlending(): boolean;
  121629. /**
  121630. * Specifies if this material should be rendered in alpha test mode
  121631. * @returns a boolean specifying if an alpha test is needed.
  121632. */
  121633. needAlphaTesting(): boolean;
  121634. private _initializeBlock;
  121635. private _resetDualBlocks;
  121636. /**
  121637. * Build the material and generates the inner effect
  121638. * @param verbose defines if the build should log activity
  121639. */
  121640. build(verbose?: boolean): void;
  121641. /**
  121642. * Runs an otpimization phase to try to improve the shader code
  121643. */
  121644. optimize(): void;
  121645. private _prepareDefinesForAttributes;
  121646. /**
  121647. * Get if the submesh is ready to be used and all its information available.
  121648. * Child classes can use it to update shaders
  121649. * @param mesh defines the mesh to check
  121650. * @param subMesh defines which submesh to check
  121651. * @param useInstances specifies that instances should be used
  121652. * @returns a boolean indicating that the submesh is ready or not
  121653. */
  121654. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121655. /**
  121656. * Get a string representing the shaders built by the current node graph
  121657. */
  121658. readonly compiledShaders: string;
  121659. /**
  121660. * Binds the world matrix to the material
  121661. * @param world defines the world transformation matrix
  121662. */
  121663. bindOnlyWorldMatrix(world: Matrix): void;
  121664. /**
  121665. * Binds the submesh to this material by preparing the effect and shader to draw
  121666. * @param world defines the world transformation matrix
  121667. * @param mesh defines the mesh containing the submesh
  121668. * @param subMesh defines the submesh to bind the material to
  121669. */
  121670. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121671. /**
  121672. * Gets the active textures from the material
  121673. * @returns an array of textures
  121674. */
  121675. getActiveTextures(): BaseTexture[];
  121676. /**
  121677. * Gets the list of texture blocks
  121678. * @returns an array of texture blocks
  121679. */
  121680. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121681. /**
  121682. * Specifies if the material uses a texture
  121683. * @param texture defines the texture to check against the material
  121684. * @returns a boolean specifying if the material uses the texture
  121685. */
  121686. hasTexture(texture: BaseTexture): boolean;
  121687. /**
  121688. * Disposes the material
  121689. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121690. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121691. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121692. */
  121693. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121694. /** Creates the node editor window. */
  121695. private _createNodeEditor;
  121696. /**
  121697. * Launch the node material editor
  121698. * @param config Define the configuration of the editor
  121699. * @return a promise fulfilled when the node editor is visible
  121700. */
  121701. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121702. /**
  121703. * Clear the current material
  121704. */
  121705. clear(): void;
  121706. /**
  121707. * Clear the current material and set it to a default state
  121708. */
  121709. setToDefault(): void;
  121710. /**
  121711. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121712. * @param url defines the url to load from
  121713. * @returns a promise that will fullfil when the material is fully loaded
  121714. */
  121715. loadAsync(url: string): Promise<void>;
  121716. private _gatherBlocks;
  121717. /**
  121718. * Generate a string containing the code declaration required to create an equivalent of this material
  121719. * @returns a string
  121720. */
  121721. generateCode(): string;
  121722. /**
  121723. * Serializes this material in a JSON representation
  121724. * @returns the serialized material object
  121725. */
  121726. serialize(): any;
  121727. private _restoreConnections;
  121728. /**
  121729. * Clear the current graph and load a new one from a serialization object
  121730. * @param source defines the JSON representation of the material
  121731. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121732. */
  121733. loadFromSerialization(source: any, rootUrl?: string): void;
  121734. /**
  121735. * Creates a node material from parsed material data
  121736. * @param source defines the JSON representation of the material
  121737. * @param scene defines the hosting scene
  121738. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121739. * @returns a new node material
  121740. */
  121741. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121742. /**
  121743. * Creates a new node material set to default basic configuration
  121744. * @param name defines the name of the material
  121745. * @param scene defines the hosting scene
  121746. * @returns a new NodeMaterial
  121747. */
  121748. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121749. }
  121750. }
  121751. declare module BABYLON {
  121752. /**
  121753. * Block used to read a texture from a sampler
  121754. */
  121755. export class TextureBlock extends NodeMaterialBlock {
  121756. private _defineName;
  121757. private _linearDefineName;
  121758. private _samplerName;
  121759. private _transformedUVName;
  121760. private _textureTransformName;
  121761. private _textureInfoName;
  121762. private _mainUVName;
  121763. private _mainUVDefineName;
  121764. /**
  121765. * Gets or sets the texture associated with the node
  121766. */
  121767. texture: Nullable<Texture>;
  121768. /**
  121769. * Create a new TextureBlock
  121770. * @param name defines the block name
  121771. */
  121772. constructor(name: string);
  121773. /**
  121774. * Gets the current class name
  121775. * @returns the class name
  121776. */
  121777. getClassName(): string;
  121778. /**
  121779. * Gets the uv input component
  121780. */
  121781. readonly uv: NodeMaterialConnectionPoint;
  121782. /**
  121783. * Gets the rgba output component
  121784. */
  121785. readonly rgba: NodeMaterialConnectionPoint;
  121786. /**
  121787. * Gets the rgb output component
  121788. */
  121789. readonly rgb: NodeMaterialConnectionPoint;
  121790. /**
  121791. * Gets the r output component
  121792. */
  121793. readonly r: NodeMaterialConnectionPoint;
  121794. /**
  121795. * Gets the g output component
  121796. */
  121797. readonly g: NodeMaterialConnectionPoint;
  121798. /**
  121799. * Gets the b output component
  121800. */
  121801. readonly b: NodeMaterialConnectionPoint;
  121802. /**
  121803. * Gets the a output component
  121804. */
  121805. readonly a: NodeMaterialConnectionPoint;
  121806. readonly target: NodeMaterialBlockTargets;
  121807. autoConfigure(material: NodeMaterial): void;
  121808. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121810. isReady(): boolean;
  121811. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121812. private readonly _isMixed;
  121813. private _injectVertexCode;
  121814. private _writeOutput;
  121815. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121816. protected _dumpPropertiesCode(): string;
  121817. serialize(): any;
  121818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121819. }
  121820. }
  121821. declare module BABYLON {
  121822. /**
  121823. * Class used to store shared data between 2 NodeMaterialBuildState
  121824. */
  121825. export class NodeMaterialBuildStateSharedData {
  121826. /**
  121827. * Gets the list of emitted varyings
  121828. */
  121829. temps: string[];
  121830. /**
  121831. * Gets the list of emitted varyings
  121832. */
  121833. varyings: string[];
  121834. /**
  121835. * Gets the varying declaration string
  121836. */
  121837. varyingDeclaration: string;
  121838. /**
  121839. * Input blocks
  121840. */
  121841. inputBlocks: InputBlock[];
  121842. /**
  121843. * Input blocks
  121844. */
  121845. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121846. /**
  121847. * Bindable blocks (Blocks that need to set data to the effect)
  121848. */
  121849. bindableBlocks: NodeMaterialBlock[];
  121850. /**
  121851. * List of blocks that can provide a compilation fallback
  121852. */
  121853. blocksWithFallbacks: NodeMaterialBlock[];
  121854. /**
  121855. * List of blocks that can provide a define update
  121856. */
  121857. blocksWithDefines: NodeMaterialBlock[];
  121858. /**
  121859. * List of blocks that can provide a repeatable content
  121860. */
  121861. repeatableContentBlocks: NodeMaterialBlock[];
  121862. /**
  121863. * List of blocks that can provide a dynamic list of uniforms
  121864. */
  121865. dynamicUniformBlocks: NodeMaterialBlock[];
  121866. /**
  121867. * List of blocks that can block the isReady function for the material
  121868. */
  121869. blockingBlocks: NodeMaterialBlock[];
  121870. /**
  121871. * Gets the list of animated inputs
  121872. */
  121873. animatedInputs: InputBlock[];
  121874. /**
  121875. * Build Id used to avoid multiple recompilations
  121876. */
  121877. buildId: number;
  121878. /** List of emitted variables */
  121879. variableNames: {
  121880. [key: string]: number;
  121881. };
  121882. /** List of emitted defines */
  121883. defineNames: {
  121884. [key: string]: number;
  121885. };
  121886. /** Should emit comments? */
  121887. emitComments: boolean;
  121888. /** Emit build activity */
  121889. verbose: boolean;
  121890. /** Gets or sets the hosting scene */
  121891. scene: Scene;
  121892. /**
  121893. * Gets the compilation hints emitted at compilation time
  121894. */
  121895. hints: {
  121896. needWorldViewMatrix: boolean;
  121897. needWorldViewProjectionMatrix: boolean;
  121898. needAlphaBlending: boolean;
  121899. needAlphaTesting: boolean;
  121900. };
  121901. /**
  121902. * List of compilation checks
  121903. */
  121904. checks: {
  121905. emitVertex: boolean;
  121906. emitFragment: boolean;
  121907. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121908. };
  121909. /** Creates a new shared data */
  121910. constructor();
  121911. /**
  121912. * Emits console errors and exceptions if there is a failing check
  121913. */
  121914. emitErrors(): void;
  121915. }
  121916. }
  121917. declare module BABYLON {
  121918. /**
  121919. * Class used to store node based material build state
  121920. */
  121921. export class NodeMaterialBuildState {
  121922. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121923. supportUniformBuffers: boolean;
  121924. /**
  121925. * Gets the list of emitted attributes
  121926. */
  121927. attributes: string[];
  121928. /**
  121929. * Gets the list of emitted uniforms
  121930. */
  121931. uniforms: string[];
  121932. /**
  121933. * Gets the list of emitted constants
  121934. */
  121935. constants: string[];
  121936. /**
  121937. * Gets the list of emitted samplers
  121938. */
  121939. samplers: string[];
  121940. /**
  121941. * Gets the list of emitted functions
  121942. */
  121943. functions: {
  121944. [key: string]: string;
  121945. };
  121946. /**
  121947. * Gets the list of emitted extensions
  121948. */
  121949. extensions: {
  121950. [key: string]: string;
  121951. };
  121952. /**
  121953. * Gets the target of the compilation state
  121954. */
  121955. target: NodeMaterialBlockTargets;
  121956. /**
  121957. * Gets the list of emitted counters
  121958. */
  121959. counters: {
  121960. [key: string]: number;
  121961. };
  121962. /**
  121963. * Shared data between multiple NodeMaterialBuildState instances
  121964. */
  121965. sharedData: NodeMaterialBuildStateSharedData;
  121966. /** @hidden */
  121967. _vertexState: NodeMaterialBuildState;
  121968. /** @hidden */
  121969. _attributeDeclaration: string;
  121970. /** @hidden */
  121971. _uniformDeclaration: string;
  121972. /** @hidden */
  121973. _constantDeclaration: string;
  121974. /** @hidden */
  121975. _samplerDeclaration: string;
  121976. /** @hidden */
  121977. _varyingTransfer: string;
  121978. private _repeatableContentAnchorIndex;
  121979. /** @hidden */
  121980. _builtCompilationString: string;
  121981. /**
  121982. * Gets the emitted compilation strings
  121983. */
  121984. compilationString: string;
  121985. /**
  121986. * Finalize the compilation strings
  121987. * @param state defines the current compilation state
  121988. */
  121989. finalize(state: NodeMaterialBuildState): void;
  121990. /** @hidden */
  121991. readonly _repeatableContentAnchor: string;
  121992. /** @hidden */
  121993. _getFreeVariableName(prefix: string): string;
  121994. /** @hidden */
  121995. _getFreeDefineName(prefix: string): string;
  121996. /** @hidden */
  121997. _excludeVariableName(name: string): void;
  121998. /** @hidden */
  121999. _emit2DSampler(name: string): void;
  122000. /** @hidden */
  122001. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122002. /** @hidden */
  122003. _emitExtension(name: string, extension: string): void;
  122004. /** @hidden */
  122005. _emitFunction(name: string, code: string, comments: string): void;
  122006. /** @hidden */
  122007. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122008. replaceStrings?: {
  122009. search: RegExp;
  122010. replace: string;
  122011. }[];
  122012. repeatKey?: string;
  122013. }): string;
  122014. /** @hidden */
  122015. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122016. repeatKey?: string;
  122017. removeAttributes?: boolean;
  122018. removeUniforms?: boolean;
  122019. removeVaryings?: boolean;
  122020. removeIfDef?: boolean;
  122021. replaceStrings?: {
  122022. search: RegExp;
  122023. replace: string;
  122024. }[];
  122025. }, storeKey?: string): void;
  122026. /** @hidden */
  122027. _registerTempVariable(name: string): boolean;
  122028. /** @hidden */
  122029. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122030. /** @hidden */
  122031. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122032. /** @hidden */
  122033. _emitFloat(value: number): string;
  122034. }
  122035. }
  122036. declare module BABYLON {
  122037. /**
  122038. * Defines a block that can be used inside a node based material
  122039. */
  122040. export class NodeMaterialBlock {
  122041. private _buildId;
  122042. private _buildTarget;
  122043. private _target;
  122044. private _isFinalMerger;
  122045. private _isInput;
  122046. /** @hidden */
  122047. _codeVariableName: string;
  122048. /** @hidden */
  122049. _inputs: NodeMaterialConnectionPoint[];
  122050. /** @hidden */
  122051. _outputs: NodeMaterialConnectionPoint[];
  122052. /** @hidden */
  122053. _preparationId: number;
  122054. /**
  122055. * Gets or sets the name of the block
  122056. */
  122057. name: string;
  122058. /**
  122059. * Gets or sets the unique id of the node
  122060. */
  122061. uniqueId: number;
  122062. /**
  122063. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122064. */
  122065. readonly isFinalMerger: boolean;
  122066. /**
  122067. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122068. */
  122069. readonly isInput: boolean;
  122070. /**
  122071. * Gets or sets the build Id
  122072. */
  122073. buildId: number;
  122074. /**
  122075. * Gets or sets the target of the block
  122076. */
  122077. target: NodeMaterialBlockTargets;
  122078. /**
  122079. * Gets the list of input points
  122080. */
  122081. readonly inputs: NodeMaterialConnectionPoint[];
  122082. /** Gets the list of output points */
  122083. readonly outputs: NodeMaterialConnectionPoint[];
  122084. /**
  122085. * Find an input by its name
  122086. * @param name defines the name of the input to look for
  122087. * @returns the input or null if not found
  122088. */
  122089. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122090. /**
  122091. * Find an output by its name
  122092. * @param name defines the name of the outputto look for
  122093. * @returns the output or null if not found
  122094. */
  122095. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122096. /**
  122097. * Creates a new NodeMaterialBlock
  122098. * @param name defines the block name
  122099. * @param target defines the target of that block (Vertex by default)
  122100. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122101. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122102. */
  122103. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122104. /**
  122105. * Initialize the block and prepare the context for build
  122106. * @param state defines the state that will be used for the build
  122107. */
  122108. initialize(state: NodeMaterialBuildState): void;
  122109. /**
  122110. * Bind data to effect. Will only be called for blocks with isBindable === true
  122111. * @param effect defines the effect to bind data to
  122112. * @param nodeMaterial defines the hosting NodeMaterial
  122113. * @param mesh defines the mesh that will be rendered
  122114. */
  122115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122116. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122117. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122118. protected _writeFloat(value: number): string;
  122119. /**
  122120. * Gets the current class name e.g. "NodeMaterialBlock"
  122121. * @returns the class name
  122122. */
  122123. getClassName(): string;
  122124. /**
  122125. * Register a new input. Must be called inside a block constructor
  122126. * @param name defines the connection point name
  122127. * @param type defines the connection point type
  122128. * @param isOptional defines a boolean indicating that this input can be omitted
  122129. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122130. * @returns the current block
  122131. */
  122132. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122133. /**
  122134. * Register a new output. Must be called inside a block constructor
  122135. * @param name defines the connection point name
  122136. * @param type defines the connection point type
  122137. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122138. * @returns the current block
  122139. */
  122140. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122141. /**
  122142. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122143. * @param forOutput defines an optional connection point to check compatibility with
  122144. * @returns the first available input or null
  122145. */
  122146. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122147. /**
  122148. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122149. * @param forBlock defines an optional block to check compatibility with
  122150. * @returns the first available input or null
  122151. */
  122152. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122153. /**
  122154. * Gets the sibling of the given output
  122155. * @param current defines the current output
  122156. * @returns the next output in the list or null
  122157. */
  122158. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122159. /**
  122160. * Connect current block with another block
  122161. * @param other defines the block to connect with
  122162. * @param options define the various options to help pick the right connections
  122163. * @returns the current block
  122164. */
  122165. connectTo(other: NodeMaterialBlock, options?: {
  122166. input?: string;
  122167. output?: string;
  122168. outputSwizzle?: string;
  122169. }): this | undefined;
  122170. protected _buildBlock(state: NodeMaterialBuildState): void;
  122171. /**
  122172. * Add uniforms, samplers and uniform buffers at compilation time
  122173. * @param state defines the state to update
  122174. * @param nodeMaterial defines the node material requesting the update
  122175. * @param defines defines the material defines to update
  122176. * @param uniformBuffers defines the list of uniform buffer names
  122177. */
  122178. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122179. /**
  122180. * Add potential fallbacks if shader compilation fails
  122181. * @param mesh defines the mesh to be rendered
  122182. * @param fallbacks defines the current prioritized list of fallbacks
  122183. */
  122184. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122185. /**
  122186. * Initialize defines for shader compilation
  122187. * @param mesh defines the mesh to be rendered
  122188. * @param nodeMaterial defines the node material requesting the update
  122189. * @param defines defines the material defines to update
  122190. * @param useInstances specifies that instances should be used
  122191. */
  122192. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122193. /**
  122194. * Update defines for shader compilation
  122195. * @param mesh defines the mesh to be rendered
  122196. * @param nodeMaterial defines the node material requesting the update
  122197. * @param defines defines the material defines to update
  122198. * @param useInstances specifies that instances should be used
  122199. */
  122200. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122201. /**
  122202. * Lets the block try to connect some inputs automatically
  122203. * @param material defines the hosting NodeMaterial
  122204. */
  122205. autoConfigure(material: NodeMaterial): void;
  122206. /**
  122207. * Function called when a block is declared as repeatable content generator
  122208. * @param vertexShaderState defines the current compilation state for the vertex shader
  122209. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122210. * @param mesh defines the mesh to be rendered
  122211. * @param defines defines the material defines to update
  122212. */
  122213. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122214. /**
  122215. * Checks if the block is ready
  122216. * @param mesh defines the mesh to be rendered
  122217. * @param nodeMaterial defines the node material requesting the update
  122218. * @param defines defines the material defines to update
  122219. * @param useInstances specifies that instances should be used
  122220. * @returns true if the block is ready
  122221. */
  122222. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122223. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122224. private _processBuild;
  122225. /**
  122226. * Compile the current node and generate the shader code
  122227. * @param state defines the current compilation state (uniforms, samplers, current string)
  122228. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122229. * @returns true if already built
  122230. */
  122231. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122232. protected _inputRename(name: string): string;
  122233. protected _outputRename(name: string): string;
  122234. protected _dumpPropertiesCode(): string;
  122235. /** @hidden */
  122236. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122237. /** @hidden */
  122238. _dumpCodeForOutputConnections(): string;
  122239. /**
  122240. * Clone the current block to a new identical block
  122241. * @param scene defines the hosting scene
  122242. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122243. * @returns a copy of the current block
  122244. */
  122245. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122246. /**
  122247. * Serializes this block in a JSON representation
  122248. * @returns the serialized block object
  122249. */
  122250. serialize(): any;
  122251. /** @hidden */
  122252. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122253. /**
  122254. * Release resources
  122255. */
  122256. dispose(): void;
  122257. }
  122258. }
  122259. declare module BABYLON {
  122260. /**
  122261. * Enum defining the type of animations supported by InputBlock
  122262. */
  122263. export enum AnimatedInputBlockTypes {
  122264. /** No animation */
  122265. None = 0,
  122266. /** Time based animation. Will only work for floats */
  122267. Time = 1
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Block used to expose an input value
  122273. */
  122274. export class InputBlock extends NodeMaterialBlock {
  122275. private _mode;
  122276. private _associatedVariableName;
  122277. private _storedValue;
  122278. private _valueCallback;
  122279. private _type;
  122280. private _animationType;
  122281. /** Gets or set a value used to limit the range of float values */
  122282. min: number;
  122283. /** Gets or set a value used to limit the range of float values */
  122284. max: number;
  122285. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122286. matrixMode: number;
  122287. /** @hidden */
  122288. _systemValue: Nullable<NodeMaterialSystemValues>;
  122289. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122290. visibleInInspector: boolean;
  122291. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122292. isConstant: boolean;
  122293. /**
  122294. * Gets or sets the connection point type (default is float)
  122295. */
  122296. readonly type: NodeMaterialBlockConnectionPointTypes;
  122297. /**
  122298. * Creates a new InputBlock
  122299. * @param name defines the block name
  122300. * @param target defines the target of that block (Vertex by default)
  122301. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122302. */
  122303. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122304. /**
  122305. * Gets the output component
  122306. */
  122307. readonly output: NodeMaterialConnectionPoint;
  122308. /**
  122309. * Set the source of this connection point to a vertex attribute
  122310. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122311. * @returns the current connection point
  122312. */
  122313. setAsAttribute(attributeName?: string): InputBlock;
  122314. /**
  122315. * Set the source of this connection point to a system value
  122316. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122317. * @returns the current connection point
  122318. */
  122319. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122320. /**
  122321. * Gets or sets the value of that point.
  122322. * Please note that this value will be ignored if valueCallback is defined
  122323. */
  122324. value: any;
  122325. /**
  122326. * Gets or sets a callback used to get the value of that point.
  122327. * Please note that setting this value will force the connection point to ignore the value property
  122328. */
  122329. valueCallback: () => any;
  122330. /**
  122331. * Gets or sets the associated variable name in the shader
  122332. */
  122333. associatedVariableName: string;
  122334. /** Gets or sets the type of animation applied to the input */
  122335. animationType: AnimatedInputBlockTypes;
  122336. /**
  122337. * Gets a boolean indicating that this connection point not defined yet
  122338. */
  122339. readonly isUndefined: boolean;
  122340. /**
  122341. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122342. * In this case the connection point name must be the name of the uniform to use.
  122343. * Can only be set on inputs
  122344. */
  122345. isUniform: boolean;
  122346. /**
  122347. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122348. * In this case the connection point name must be the name of the attribute to use
  122349. * Can only be set on inputs
  122350. */
  122351. isAttribute: boolean;
  122352. /**
  122353. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122354. * Can only be set on exit points
  122355. */
  122356. isVarying: boolean;
  122357. /**
  122358. * Gets a boolean indicating that the current connection point is a system value
  122359. */
  122360. readonly isSystemValue: boolean;
  122361. /**
  122362. * Gets or sets the current well known value or null if not defined as a system value
  122363. */
  122364. systemValue: Nullable<NodeMaterialSystemValues>;
  122365. /**
  122366. * Gets the current class name
  122367. * @returns the class name
  122368. */
  122369. getClassName(): string;
  122370. /**
  122371. * Animate the input if animationType !== None
  122372. * @param scene defines the rendering scene
  122373. */
  122374. animate(scene: Scene): void;
  122375. private _emitDefine;
  122376. initialize(state: NodeMaterialBuildState): void;
  122377. /**
  122378. * Set the input block to its default value (based on its type)
  122379. */
  122380. setDefaultValue(): void;
  122381. private _emitConstant;
  122382. private _emit;
  122383. /** @hidden */
  122384. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122385. /** @hidden */
  122386. _transmit(effect: Effect, scene: Scene): void;
  122387. protected _buildBlock(state: NodeMaterialBuildState): void;
  122388. protected _dumpPropertiesCode(): string;
  122389. serialize(): any;
  122390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122391. }
  122392. }
  122393. declare module BABYLON {
  122394. /**
  122395. * Defines a connection point for a block
  122396. */
  122397. export class NodeMaterialConnectionPoint {
  122398. /** @hidden */
  122399. _ownerBlock: NodeMaterialBlock;
  122400. /** @hidden */
  122401. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122402. private _endpoints;
  122403. private _associatedVariableName;
  122404. /** @hidden */
  122405. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122406. /** @hidden */
  122407. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122408. private _type;
  122409. /** @hidden */
  122410. _enforceAssociatedVariableName: boolean;
  122411. /**
  122412. * Gets or sets the additional types supported by this connection point
  122413. */
  122414. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122415. /**
  122416. * Gets or sets the additional types excluded by this connection point
  122417. */
  122418. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122419. /**
  122420. * Observable triggered when this point is connected
  122421. */
  122422. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122423. /**
  122424. * Gets or sets the associated variable name in the shader
  122425. */
  122426. associatedVariableName: string;
  122427. /**
  122428. * Gets or sets the connection point type (default is float)
  122429. */
  122430. type: NodeMaterialBlockConnectionPointTypes;
  122431. /**
  122432. * Gets or sets the connection point name
  122433. */
  122434. name: string;
  122435. /**
  122436. * Gets or sets a boolean indicating that this connection point can be omitted
  122437. */
  122438. isOptional: boolean;
  122439. /**
  122440. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122441. */
  122442. define: string;
  122443. /** @hidden */
  122444. _prioritizeVertex: boolean;
  122445. private _target;
  122446. /** Gets or sets the target of that connection point */
  122447. target: NodeMaterialBlockTargets;
  122448. /**
  122449. * Gets a boolean indicating that the current point is connected
  122450. */
  122451. readonly isConnected: boolean;
  122452. /**
  122453. * Gets a boolean indicating that the current point is connected to an input block
  122454. */
  122455. readonly isConnectedToInputBlock: boolean;
  122456. /**
  122457. * Gets a the connected input block (if any)
  122458. */
  122459. readonly connectInputBlock: Nullable<InputBlock>;
  122460. /** Get the other side of the connection (if any) */
  122461. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122462. /** Get the block that owns this connection point */
  122463. readonly ownerBlock: NodeMaterialBlock;
  122464. /** Get the block connected on the other side of this connection (if any) */
  122465. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122466. /** Get the block connected on the endpoints of this connection (if any) */
  122467. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122468. /** Gets the list of connected endpoints */
  122469. readonly endpoints: NodeMaterialConnectionPoint[];
  122470. /** Gets a boolean indicating if that output point is connected to at least one input */
  122471. readonly hasEndpoints: boolean;
  122472. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122473. readonly isConnectedInVertexShader: boolean;
  122474. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122475. readonly isConnectedInFragmentShader: boolean;
  122476. /**
  122477. * Creates a new connection point
  122478. * @param name defines the connection point name
  122479. * @param ownerBlock defines the block hosting this connection point
  122480. */
  122481. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122482. /**
  122483. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122484. * @returns the class name
  122485. */
  122486. getClassName(): string;
  122487. /**
  122488. * Gets an boolean indicating if the current point can be connected to another point
  122489. * @param connectionPoint defines the other connection point
  122490. * @returns true if the connection is possible
  122491. */
  122492. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122493. /**
  122494. * Connect this point to another connection point
  122495. * @param connectionPoint defines the other connection point
  122496. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122497. * @returns the current connection point
  122498. */
  122499. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122500. /**
  122501. * Disconnect this point from one of his endpoint
  122502. * @param endpoint defines the other connection point
  122503. * @returns the current connection point
  122504. */
  122505. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122506. /**
  122507. * Serializes this point in a JSON representation
  122508. * @returns the serialized point object
  122509. */
  122510. serialize(): any;
  122511. /**
  122512. * Release resources
  122513. */
  122514. dispose(): void;
  122515. }
  122516. }
  122517. declare module BABYLON {
  122518. /**
  122519. * Block used to add support for vertex skinning (bones)
  122520. */
  122521. export class BonesBlock extends NodeMaterialBlock {
  122522. /**
  122523. * Creates a new BonesBlock
  122524. * @param name defines the block name
  122525. */
  122526. constructor(name: string);
  122527. /**
  122528. * Initialize the block and prepare the context for build
  122529. * @param state defines the state that will be used for the build
  122530. */
  122531. initialize(state: NodeMaterialBuildState): void;
  122532. /**
  122533. * Gets the current class name
  122534. * @returns the class name
  122535. */
  122536. getClassName(): string;
  122537. /**
  122538. * Gets the matrix indices input component
  122539. */
  122540. readonly matricesIndices: NodeMaterialConnectionPoint;
  122541. /**
  122542. * Gets the matrix weights input component
  122543. */
  122544. readonly matricesWeights: NodeMaterialConnectionPoint;
  122545. /**
  122546. * Gets the extra matrix indices input component
  122547. */
  122548. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122549. /**
  122550. * Gets the extra matrix weights input component
  122551. */
  122552. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122553. /**
  122554. * Gets the world input component
  122555. */
  122556. readonly world: NodeMaterialConnectionPoint;
  122557. /**
  122558. * Gets the output component
  122559. */
  122560. readonly output: NodeMaterialConnectionPoint;
  122561. autoConfigure(material: NodeMaterial): void;
  122562. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122565. protected _buildBlock(state: NodeMaterialBuildState): this;
  122566. }
  122567. }
  122568. declare module BABYLON {
  122569. /**
  122570. * Block used to add support for instances
  122571. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122572. */
  122573. export class InstancesBlock extends NodeMaterialBlock {
  122574. /**
  122575. * Creates a new InstancesBlock
  122576. * @param name defines the block name
  122577. */
  122578. constructor(name: string);
  122579. /**
  122580. * Gets the current class name
  122581. * @returns the class name
  122582. */
  122583. getClassName(): string;
  122584. /**
  122585. * Gets the first world row input component
  122586. */
  122587. readonly world0: NodeMaterialConnectionPoint;
  122588. /**
  122589. * Gets the second world row input component
  122590. */
  122591. readonly world1: NodeMaterialConnectionPoint;
  122592. /**
  122593. * Gets the third world row input component
  122594. */
  122595. readonly world2: NodeMaterialConnectionPoint;
  122596. /**
  122597. * Gets the forth world row input component
  122598. */
  122599. readonly world3: NodeMaterialConnectionPoint;
  122600. /**
  122601. * Gets the world input component
  122602. */
  122603. readonly world: NodeMaterialConnectionPoint;
  122604. /**
  122605. * Gets the output component
  122606. */
  122607. readonly output: NodeMaterialConnectionPoint;
  122608. autoConfigure(material: NodeMaterial): void;
  122609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122610. protected _buildBlock(state: NodeMaterialBuildState): this;
  122611. }
  122612. }
  122613. declare module BABYLON {
  122614. /**
  122615. * Block used to add morph targets support to vertex shader
  122616. */
  122617. export class MorphTargetsBlock extends NodeMaterialBlock {
  122618. private _repeatableContentAnchor;
  122619. private _repeatebleContentGenerated;
  122620. /**
  122621. * Create a new MorphTargetsBlock
  122622. * @param name defines the block name
  122623. */
  122624. constructor(name: string);
  122625. /**
  122626. * Gets the current class name
  122627. * @returns the class name
  122628. */
  122629. getClassName(): string;
  122630. /**
  122631. * Gets the position input component
  122632. */
  122633. readonly position: NodeMaterialConnectionPoint;
  122634. /**
  122635. * Gets the normal input component
  122636. */
  122637. readonly normal: NodeMaterialConnectionPoint;
  122638. /**
  122639. * Gets the tangent input component
  122640. */
  122641. readonly tangent: NodeMaterialConnectionPoint;
  122642. /**
  122643. * Gets the tangent input component
  122644. */
  122645. readonly uv: NodeMaterialConnectionPoint;
  122646. /**
  122647. * Gets the position output component
  122648. */
  122649. readonly positionOutput: NodeMaterialConnectionPoint;
  122650. /**
  122651. * Gets the normal output component
  122652. */
  122653. readonly normalOutput: NodeMaterialConnectionPoint;
  122654. /**
  122655. * Gets the tangent output component
  122656. */
  122657. readonly tangentOutput: NodeMaterialConnectionPoint;
  122658. /**
  122659. * Gets the tangent output component
  122660. */
  122661. readonly uvOutput: NodeMaterialConnectionPoint;
  122662. initialize(state: NodeMaterialBuildState): void;
  122663. autoConfigure(material: NodeMaterial): void;
  122664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122666. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122667. protected _buildBlock(state: NodeMaterialBuildState): this;
  122668. }
  122669. }
  122670. declare module BABYLON {
  122671. /**
  122672. * Block used to get data information from a light
  122673. */
  122674. export class LightInformationBlock extends NodeMaterialBlock {
  122675. private _lightDataUniformName;
  122676. private _lightColorUniformName;
  122677. private _lightTypeDefineName;
  122678. /**
  122679. * Gets or sets the light associated with this block
  122680. */
  122681. light: Nullable<Light>;
  122682. /**
  122683. * Creates a new LightInformationBlock
  122684. * @param name defines the block name
  122685. */
  122686. constructor(name: string);
  122687. /**
  122688. * Gets the current class name
  122689. * @returns the class name
  122690. */
  122691. getClassName(): string;
  122692. /**
  122693. * Gets the world position input component
  122694. */
  122695. readonly worldPosition: NodeMaterialConnectionPoint;
  122696. /**
  122697. * Gets the direction output component
  122698. */
  122699. readonly direction: NodeMaterialConnectionPoint;
  122700. /**
  122701. * Gets the direction output component
  122702. */
  122703. readonly color: NodeMaterialConnectionPoint;
  122704. /**
  122705. * Gets the direction output component
  122706. */
  122707. readonly intensity: NodeMaterialConnectionPoint;
  122708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122710. protected _buildBlock(state: NodeMaterialBuildState): this;
  122711. serialize(): any;
  122712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122713. }
  122714. }
  122715. declare module BABYLON {
  122716. /**
  122717. * Block used to add image processing support to fragment shader
  122718. */
  122719. export class ImageProcessingBlock extends NodeMaterialBlock {
  122720. /**
  122721. * Create a new ImageProcessingBlock
  122722. * @param name defines the block name
  122723. */
  122724. constructor(name: string);
  122725. /**
  122726. * Gets the current class name
  122727. * @returns the class name
  122728. */
  122729. getClassName(): string;
  122730. /**
  122731. * Gets the color input component
  122732. */
  122733. readonly color: NodeMaterialConnectionPoint;
  122734. /**
  122735. * Gets the output component
  122736. */
  122737. readonly output: NodeMaterialConnectionPoint;
  122738. /**
  122739. * Initialize the block and prepare the context for build
  122740. * @param state defines the state that will be used for the build
  122741. */
  122742. initialize(state: NodeMaterialBuildState): void;
  122743. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122746. protected _buildBlock(state: NodeMaterialBuildState): this;
  122747. }
  122748. }
  122749. declare module BABYLON {
  122750. /**
  122751. * Block used to pertub normals based on a normal map
  122752. */
  122753. export class PerturbNormalBlock extends NodeMaterialBlock {
  122754. private _tangentSpaceParameterName;
  122755. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122756. invertX: boolean;
  122757. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122758. invertY: boolean;
  122759. /**
  122760. * Create a new PerturbNormalBlock
  122761. * @param name defines the block name
  122762. */
  122763. constructor(name: string);
  122764. /**
  122765. * Gets the current class name
  122766. * @returns the class name
  122767. */
  122768. getClassName(): string;
  122769. /**
  122770. * Gets the world position input component
  122771. */
  122772. readonly worldPosition: NodeMaterialConnectionPoint;
  122773. /**
  122774. * Gets the world normal input component
  122775. */
  122776. readonly worldNormal: NodeMaterialConnectionPoint;
  122777. /**
  122778. * Gets the uv input component
  122779. */
  122780. readonly uv: NodeMaterialConnectionPoint;
  122781. /**
  122782. * Gets the normal map color input component
  122783. */
  122784. readonly normalMapColor: NodeMaterialConnectionPoint;
  122785. /**
  122786. * Gets the strength input component
  122787. */
  122788. readonly strength: NodeMaterialConnectionPoint;
  122789. /**
  122790. * Gets the output component
  122791. */
  122792. readonly output: NodeMaterialConnectionPoint;
  122793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122794. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122795. autoConfigure(material: NodeMaterial): void;
  122796. protected _buildBlock(state: NodeMaterialBuildState): this;
  122797. protected _dumpPropertiesCode(): string;
  122798. serialize(): any;
  122799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122800. }
  122801. }
  122802. declare module BABYLON {
  122803. /**
  122804. * Block used to discard a pixel if a value is smaller than a cutoff
  122805. */
  122806. export class DiscardBlock extends NodeMaterialBlock {
  122807. /**
  122808. * Create a new DiscardBlock
  122809. * @param name defines the block name
  122810. */
  122811. constructor(name: string);
  122812. /**
  122813. * Gets the current class name
  122814. * @returns the class name
  122815. */
  122816. getClassName(): string;
  122817. /**
  122818. * Gets the color input component
  122819. */
  122820. readonly value: NodeMaterialConnectionPoint;
  122821. /**
  122822. * Gets the cutoff input component
  122823. */
  122824. readonly cutoff: NodeMaterialConnectionPoint;
  122825. protected _buildBlock(state: NodeMaterialBuildState): this;
  122826. }
  122827. }
  122828. declare module BABYLON {
  122829. /**
  122830. * Block used to add support for scene fog
  122831. */
  122832. export class FogBlock extends NodeMaterialBlock {
  122833. private _fogDistanceName;
  122834. private _fogParameters;
  122835. /**
  122836. * Create a new FogBlock
  122837. * @param name defines the block name
  122838. */
  122839. constructor(name: string);
  122840. /**
  122841. * Gets the current class name
  122842. * @returns the class name
  122843. */
  122844. getClassName(): string;
  122845. /**
  122846. * Gets the world position input component
  122847. */
  122848. readonly worldPosition: NodeMaterialConnectionPoint;
  122849. /**
  122850. * Gets the view input component
  122851. */
  122852. readonly view: NodeMaterialConnectionPoint;
  122853. /**
  122854. * Gets the color input component
  122855. */
  122856. readonly input: NodeMaterialConnectionPoint;
  122857. /**
  122858. * Gets the fog color input component
  122859. */
  122860. readonly fogColor: NodeMaterialConnectionPoint;
  122861. /**
  122862. * Gets the output component
  122863. */
  122864. readonly output: NodeMaterialConnectionPoint;
  122865. autoConfigure(material: NodeMaterial): void;
  122866. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122868. protected _buildBlock(state: NodeMaterialBuildState): this;
  122869. }
  122870. }
  122871. declare module BABYLON {
  122872. /**
  122873. * Block used to add light in the fragment shader
  122874. */
  122875. export class LightBlock extends NodeMaterialBlock {
  122876. private _lightId;
  122877. /**
  122878. * Gets or sets the light associated with this block
  122879. */
  122880. light: Nullable<Light>;
  122881. /**
  122882. * Create a new LightBlock
  122883. * @param name defines the block name
  122884. */
  122885. constructor(name: string);
  122886. /**
  122887. * Gets the current class name
  122888. * @returns the class name
  122889. */
  122890. getClassName(): string;
  122891. /**
  122892. * Gets the world position input component
  122893. */
  122894. readonly worldPosition: NodeMaterialConnectionPoint;
  122895. /**
  122896. * Gets the world normal input component
  122897. */
  122898. readonly worldNormal: NodeMaterialConnectionPoint;
  122899. /**
  122900. * Gets the camera (or eye) position component
  122901. */
  122902. readonly cameraPosition: NodeMaterialConnectionPoint;
  122903. /**
  122904. * Gets the glossiness component
  122905. */
  122906. readonly glossiness: NodeMaterialConnectionPoint;
  122907. /**
  122908. * Gets the glossinness power component
  122909. */
  122910. readonly glossPower: NodeMaterialConnectionPoint;
  122911. /**
  122912. * Gets the diffuse color component
  122913. */
  122914. readonly diffuseColor: NodeMaterialConnectionPoint;
  122915. /**
  122916. * Gets the specular color component
  122917. */
  122918. readonly specularColor: NodeMaterialConnectionPoint;
  122919. /**
  122920. * Gets the diffuse output component
  122921. */
  122922. readonly diffuseOutput: NodeMaterialConnectionPoint;
  122923. /**
  122924. * Gets the specular output component
  122925. */
  122926. readonly specularOutput: NodeMaterialConnectionPoint;
  122927. autoConfigure(material: NodeMaterial): void;
  122928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122929. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122931. private _injectVertexCode;
  122932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122933. serialize(): any;
  122934. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122935. }
  122936. }
  122937. declare module BABYLON {
  122938. /**
  122939. * Block used to multiply 2 values
  122940. */
  122941. export class MultiplyBlock extends NodeMaterialBlock {
  122942. /**
  122943. * Creates a new MultiplyBlock
  122944. * @param name defines the block name
  122945. */
  122946. constructor(name: string);
  122947. /**
  122948. * Gets the current class name
  122949. * @returns the class name
  122950. */
  122951. getClassName(): string;
  122952. /**
  122953. * Gets the left operand input component
  122954. */
  122955. readonly left: NodeMaterialConnectionPoint;
  122956. /**
  122957. * Gets the right operand input component
  122958. */
  122959. readonly right: NodeMaterialConnectionPoint;
  122960. /**
  122961. * Gets the output component
  122962. */
  122963. readonly output: NodeMaterialConnectionPoint;
  122964. protected _buildBlock(state: NodeMaterialBuildState): this;
  122965. }
  122966. }
  122967. declare module BABYLON {
  122968. /**
  122969. * Block used to add 2 vectors
  122970. */
  122971. export class AddBlock extends NodeMaterialBlock {
  122972. /**
  122973. * Creates a new AddBlock
  122974. * @param name defines the block name
  122975. */
  122976. constructor(name: string);
  122977. /**
  122978. * Gets the current class name
  122979. * @returns the class name
  122980. */
  122981. getClassName(): string;
  122982. /**
  122983. * Gets the left operand input component
  122984. */
  122985. readonly left: NodeMaterialConnectionPoint;
  122986. /**
  122987. * Gets the right operand input component
  122988. */
  122989. readonly right: NodeMaterialConnectionPoint;
  122990. /**
  122991. * Gets the output component
  122992. */
  122993. readonly output: NodeMaterialConnectionPoint;
  122994. protected _buildBlock(state: NodeMaterialBuildState): this;
  122995. }
  122996. }
  122997. declare module BABYLON {
  122998. /**
  122999. * Block used to scale a vector by a float
  123000. */
  123001. export class ScaleBlock extends NodeMaterialBlock {
  123002. /**
  123003. * Creates a new ScaleBlock
  123004. * @param name defines the block name
  123005. */
  123006. constructor(name: string);
  123007. /**
  123008. * Gets the current class name
  123009. * @returns the class name
  123010. */
  123011. getClassName(): string;
  123012. /**
  123013. * Gets the input component
  123014. */
  123015. readonly input: NodeMaterialConnectionPoint;
  123016. /**
  123017. * Gets the factor input component
  123018. */
  123019. readonly factor: NodeMaterialConnectionPoint;
  123020. /**
  123021. * Gets the output component
  123022. */
  123023. readonly output: NodeMaterialConnectionPoint;
  123024. protected _buildBlock(state: NodeMaterialBuildState): this;
  123025. }
  123026. }
  123027. declare module BABYLON {
  123028. /**
  123029. * Block used to clamp a float
  123030. */
  123031. export class ClampBlock extends NodeMaterialBlock {
  123032. /** Gets or sets the minimum range */
  123033. minimum: number;
  123034. /** Gets or sets the maximum range */
  123035. maximum: number;
  123036. /**
  123037. * Creates a new ClampBlock
  123038. * @param name defines the block name
  123039. */
  123040. constructor(name: string);
  123041. /**
  123042. * Gets the current class name
  123043. * @returns the class name
  123044. */
  123045. getClassName(): string;
  123046. /**
  123047. * Gets the value input component
  123048. */
  123049. readonly value: NodeMaterialConnectionPoint;
  123050. /**
  123051. * Gets the output component
  123052. */
  123053. readonly output: NodeMaterialConnectionPoint;
  123054. protected _buildBlock(state: NodeMaterialBuildState): this;
  123055. protected _dumpPropertiesCode(): string;
  123056. serialize(): any;
  123057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123058. }
  123059. }
  123060. declare module BABYLON {
  123061. /**
  123062. * Block used to apply a cross product between 2 vectors
  123063. */
  123064. export class CrossBlock extends NodeMaterialBlock {
  123065. /**
  123066. * Creates a new CrossBlock
  123067. * @param name defines the block name
  123068. */
  123069. constructor(name: string);
  123070. /**
  123071. * Gets the current class name
  123072. * @returns the class name
  123073. */
  123074. getClassName(): string;
  123075. /**
  123076. * Gets the left operand input component
  123077. */
  123078. readonly left: NodeMaterialConnectionPoint;
  123079. /**
  123080. * Gets the right operand input component
  123081. */
  123082. readonly right: NodeMaterialConnectionPoint;
  123083. /**
  123084. * Gets the output component
  123085. */
  123086. readonly output: NodeMaterialConnectionPoint;
  123087. protected _buildBlock(state: NodeMaterialBuildState): this;
  123088. }
  123089. }
  123090. declare module BABYLON {
  123091. /**
  123092. * Block used to apply a dot product between 2 vectors
  123093. */
  123094. export class DotBlock extends NodeMaterialBlock {
  123095. /**
  123096. * Creates a new DotBlock
  123097. * @param name defines the block name
  123098. */
  123099. constructor(name: string);
  123100. /**
  123101. * Gets the current class name
  123102. * @returns the class name
  123103. */
  123104. getClassName(): string;
  123105. /**
  123106. * Gets the left operand input component
  123107. */
  123108. readonly left: NodeMaterialConnectionPoint;
  123109. /**
  123110. * Gets the right operand input component
  123111. */
  123112. readonly right: NodeMaterialConnectionPoint;
  123113. /**
  123114. * Gets the output component
  123115. */
  123116. readonly output: NodeMaterialConnectionPoint;
  123117. protected _buildBlock(state: NodeMaterialBuildState): this;
  123118. }
  123119. }
  123120. declare module BABYLON {
  123121. /**
  123122. * Block used to remap a float from a range to a new one
  123123. */
  123124. export class RemapBlock extends NodeMaterialBlock {
  123125. /**
  123126. * Gets or sets the source range
  123127. */
  123128. sourceRange: Vector2;
  123129. /**
  123130. * Gets or sets the target range
  123131. */
  123132. targetRange: Vector2;
  123133. /**
  123134. * Creates a new RemapBlock
  123135. * @param name defines the block name
  123136. */
  123137. constructor(name: string);
  123138. /**
  123139. * Gets the current class name
  123140. * @returns the class name
  123141. */
  123142. getClassName(): string;
  123143. /**
  123144. * Gets the input component
  123145. */
  123146. readonly input: NodeMaterialConnectionPoint;
  123147. /**
  123148. * Gets the source min input component
  123149. */
  123150. readonly sourceMin: NodeMaterialConnectionPoint;
  123151. /**
  123152. * Gets the source max input component
  123153. */
  123154. readonly sourceMax: NodeMaterialConnectionPoint;
  123155. /**
  123156. * Gets the target min input component
  123157. */
  123158. readonly targetMin: NodeMaterialConnectionPoint;
  123159. /**
  123160. * Gets the target max input component
  123161. */
  123162. readonly targetMax: NodeMaterialConnectionPoint;
  123163. /**
  123164. * Gets the output component
  123165. */
  123166. readonly output: NodeMaterialConnectionPoint;
  123167. protected _buildBlock(state: NodeMaterialBuildState): this;
  123168. protected _dumpPropertiesCode(): string;
  123169. serialize(): any;
  123170. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123171. }
  123172. }
  123173. declare module BABYLON {
  123174. /**
  123175. * Block used to normalize a vector
  123176. */
  123177. export class NormalizeBlock extends NodeMaterialBlock {
  123178. /**
  123179. * Creates a new NormalizeBlock
  123180. * @param name defines the block name
  123181. */
  123182. constructor(name: string);
  123183. /**
  123184. * Gets the current class name
  123185. * @returns the class name
  123186. */
  123187. getClassName(): string;
  123188. /**
  123189. * Gets the input component
  123190. */
  123191. readonly input: NodeMaterialConnectionPoint;
  123192. /**
  123193. * Gets the output component
  123194. */
  123195. readonly output: NodeMaterialConnectionPoint;
  123196. protected _buildBlock(state: NodeMaterialBuildState): this;
  123197. }
  123198. }
  123199. declare module BABYLON {
  123200. /**
  123201. * Operations supported by the Trigonometry block
  123202. */
  123203. export enum TrigonometryBlockOperations {
  123204. /** Cos */
  123205. Cos = 0,
  123206. /** Sin */
  123207. Sin = 1,
  123208. /** Abs */
  123209. Abs = 2,
  123210. /** Exp */
  123211. Exp = 3,
  123212. /** Exp2 */
  123213. Exp2 = 4,
  123214. /** Round */
  123215. Round = 5,
  123216. /** Floor */
  123217. Floor = 6,
  123218. /** Ceiling */
  123219. Ceiling = 7,
  123220. /** Square root */
  123221. Sqrt = 8,
  123222. /** Log */
  123223. Log = 9,
  123224. /** Tangent */
  123225. Tan = 10,
  123226. /** Arc tangent */
  123227. ArcTan = 11,
  123228. /** Arc cosinus */
  123229. ArcCos = 12,
  123230. /** Arc sinus */
  123231. ArcSin = 13,
  123232. /** Fraction */
  123233. Fract = 14,
  123234. /** Sign */
  123235. Sign = 15,
  123236. /** To radians (from degrees) */
  123237. Radians = 16,
  123238. /** To degrees (from radians) */
  123239. Degrees = 17
  123240. }
  123241. /**
  123242. * Block used to apply trigonometry operation to floats
  123243. */
  123244. export class TrigonometryBlock extends NodeMaterialBlock {
  123245. /**
  123246. * Gets or sets the operation applied by the block
  123247. */
  123248. operation: TrigonometryBlockOperations;
  123249. /**
  123250. * Creates a new TrigonometryBlock
  123251. * @param name defines the block name
  123252. */
  123253. constructor(name: string);
  123254. /**
  123255. * Gets the current class name
  123256. * @returns the class name
  123257. */
  123258. getClassName(): string;
  123259. /**
  123260. * Gets the input component
  123261. */
  123262. readonly input: NodeMaterialConnectionPoint;
  123263. /**
  123264. * Gets the output component
  123265. */
  123266. readonly output: NodeMaterialConnectionPoint;
  123267. protected _buildBlock(state: NodeMaterialBuildState): this;
  123268. serialize(): any;
  123269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123270. }
  123271. }
  123272. declare module BABYLON {
  123273. /**
  123274. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123275. */
  123276. export class ColorMergerBlock extends NodeMaterialBlock {
  123277. /**
  123278. * Create a new ColorMergerBlock
  123279. * @param name defines the block name
  123280. */
  123281. constructor(name: string);
  123282. /**
  123283. * Gets the current class name
  123284. * @returns the class name
  123285. */
  123286. getClassName(): string;
  123287. /**
  123288. * Gets the r component (input)
  123289. */
  123290. readonly r: NodeMaterialConnectionPoint;
  123291. /**
  123292. * Gets the g component (input)
  123293. */
  123294. readonly g: NodeMaterialConnectionPoint;
  123295. /**
  123296. * Gets the b component (input)
  123297. */
  123298. readonly b: NodeMaterialConnectionPoint;
  123299. /**
  123300. * Gets the a component (input)
  123301. */
  123302. readonly a: NodeMaterialConnectionPoint;
  123303. /**
  123304. * Gets the rgba component (output)
  123305. */
  123306. readonly rgba: NodeMaterialConnectionPoint;
  123307. /**
  123308. * Gets the rgb component (output)
  123309. */
  123310. readonly rgb: NodeMaterialConnectionPoint;
  123311. protected _buildBlock(state: NodeMaterialBuildState): this;
  123312. }
  123313. }
  123314. declare module BABYLON {
  123315. /**
  123316. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123317. */
  123318. export class VectorMergerBlock extends NodeMaterialBlock {
  123319. /**
  123320. * Create a new VectorMergerBlock
  123321. * @param name defines the block name
  123322. */
  123323. constructor(name: string);
  123324. /**
  123325. * Gets the current class name
  123326. * @returns the class name
  123327. */
  123328. getClassName(): string;
  123329. /**
  123330. * Gets the x component (input)
  123331. */
  123332. readonly x: NodeMaterialConnectionPoint;
  123333. /**
  123334. * Gets the y component (input)
  123335. */
  123336. readonly y: NodeMaterialConnectionPoint;
  123337. /**
  123338. * Gets the z component (input)
  123339. */
  123340. readonly z: NodeMaterialConnectionPoint;
  123341. /**
  123342. * Gets the w component (input)
  123343. */
  123344. readonly w: NodeMaterialConnectionPoint;
  123345. /**
  123346. * Gets the xyzw component (output)
  123347. */
  123348. readonly xyzw: NodeMaterialConnectionPoint;
  123349. /**
  123350. * Gets the xyz component (output)
  123351. */
  123352. readonly xyz: NodeMaterialConnectionPoint;
  123353. /**
  123354. * Gets the xy component (output)
  123355. */
  123356. readonly xy: NodeMaterialConnectionPoint;
  123357. protected _buildBlock(state: NodeMaterialBuildState): this;
  123358. }
  123359. }
  123360. declare module BABYLON {
  123361. /**
  123362. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123363. */
  123364. export class ColorSplitterBlock extends NodeMaterialBlock {
  123365. /**
  123366. * Create a new ColorSplitterBlock
  123367. * @param name defines the block name
  123368. */
  123369. constructor(name: string);
  123370. /**
  123371. * Gets the current class name
  123372. * @returns the class name
  123373. */
  123374. getClassName(): string;
  123375. /**
  123376. * Gets the rgba component (input)
  123377. */
  123378. readonly rgba: NodeMaterialConnectionPoint;
  123379. /**
  123380. * Gets the rgb component (input)
  123381. */
  123382. readonly rgbIn: NodeMaterialConnectionPoint;
  123383. /**
  123384. * Gets the rgb component (output)
  123385. */
  123386. readonly rgbOut: NodeMaterialConnectionPoint;
  123387. /**
  123388. * Gets the r component (output)
  123389. */
  123390. readonly r: NodeMaterialConnectionPoint;
  123391. /**
  123392. * Gets the g component (output)
  123393. */
  123394. readonly g: NodeMaterialConnectionPoint;
  123395. /**
  123396. * Gets the b component (output)
  123397. */
  123398. readonly b: NodeMaterialConnectionPoint;
  123399. /**
  123400. * Gets the a component (output)
  123401. */
  123402. readonly a: NodeMaterialConnectionPoint;
  123403. protected _inputRename(name: string): string;
  123404. protected _outputRename(name: string): string;
  123405. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123406. }
  123407. }
  123408. declare module BABYLON {
  123409. /**
  123410. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123411. */
  123412. export class VectorSplitterBlock extends NodeMaterialBlock {
  123413. /**
  123414. * Create a new VectorSplitterBlock
  123415. * @param name defines the block name
  123416. */
  123417. constructor(name: string);
  123418. /**
  123419. * Gets the current class name
  123420. * @returns the class name
  123421. */
  123422. getClassName(): string;
  123423. /**
  123424. * Gets the xyzw component (input)
  123425. */
  123426. readonly xyzw: NodeMaterialConnectionPoint;
  123427. /**
  123428. * Gets the xyz component (input)
  123429. */
  123430. readonly xyzIn: NodeMaterialConnectionPoint;
  123431. /**
  123432. * Gets the xy component (input)
  123433. */
  123434. readonly xyIn: NodeMaterialConnectionPoint;
  123435. /**
  123436. * Gets the xyz component (output)
  123437. */
  123438. readonly xyzOut: NodeMaterialConnectionPoint;
  123439. /**
  123440. * Gets the xy component (output)
  123441. */
  123442. readonly xyOut: NodeMaterialConnectionPoint;
  123443. /**
  123444. * Gets the x component (output)
  123445. */
  123446. readonly x: NodeMaterialConnectionPoint;
  123447. /**
  123448. * Gets the y component (output)
  123449. */
  123450. readonly y: NodeMaterialConnectionPoint;
  123451. /**
  123452. * Gets the z component (output)
  123453. */
  123454. readonly z: NodeMaterialConnectionPoint;
  123455. /**
  123456. * Gets the w component (output)
  123457. */
  123458. readonly w: NodeMaterialConnectionPoint;
  123459. protected _inputRename(name: string): string;
  123460. protected _outputRename(name: string): string;
  123461. protected _buildBlock(state: NodeMaterialBuildState): this;
  123462. }
  123463. }
  123464. declare module BABYLON {
  123465. /**
  123466. * Block used to lerp between 2 values
  123467. */
  123468. export class LerpBlock extends NodeMaterialBlock {
  123469. /**
  123470. * Creates a new LerpBlock
  123471. * @param name defines the block name
  123472. */
  123473. constructor(name: string);
  123474. /**
  123475. * Gets the current class name
  123476. * @returns the class name
  123477. */
  123478. getClassName(): string;
  123479. /**
  123480. * Gets the left operand input component
  123481. */
  123482. readonly left: NodeMaterialConnectionPoint;
  123483. /**
  123484. * Gets the right operand input component
  123485. */
  123486. readonly right: NodeMaterialConnectionPoint;
  123487. /**
  123488. * Gets the gradient operand input component
  123489. */
  123490. readonly gradient: NodeMaterialConnectionPoint;
  123491. /**
  123492. * Gets the output component
  123493. */
  123494. readonly output: NodeMaterialConnectionPoint;
  123495. protected _buildBlock(state: NodeMaterialBuildState): this;
  123496. }
  123497. }
  123498. declare module BABYLON {
  123499. /**
  123500. * Block used to divide 2 vectors
  123501. */
  123502. export class DivideBlock extends NodeMaterialBlock {
  123503. /**
  123504. * Creates a new DivideBlock
  123505. * @param name defines the block name
  123506. */
  123507. constructor(name: string);
  123508. /**
  123509. * Gets the current class name
  123510. * @returns the class name
  123511. */
  123512. getClassName(): string;
  123513. /**
  123514. * Gets the left operand input component
  123515. */
  123516. readonly left: NodeMaterialConnectionPoint;
  123517. /**
  123518. * Gets the right operand input component
  123519. */
  123520. readonly right: NodeMaterialConnectionPoint;
  123521. /**
  123522. * Gets the output component
  123523. */
  123524. readonly output: NodeMaterialConnectionPoint;
  123525. protected _buildBlock(state: NodeMaterialBuildState): this;
  123526. }
  123527. }
  123528. declare module BABYLON {
  123529. /**
  123530. * Block used to subtract 2 vectors
  123531. */
  123532. export class SubtractBlock extends NodeMaterialBlock {
  123533. /**
  123534. * Creates a new SubtractBlock
  123535. * @param name defines the block name
  123536. */
  123537. constructor(name: string);
  123538. /**
  123539. * Gets the current class name
  123540. * @returns the class name
  123541. */
  123542. getClassName(): string;
  123543. /**
  123544. * Gets the left operand input component
  123545. */
  123546. readonly left: NodeMaterialConnectionPoint;
  123547. /**
  123548. * Gets the right operand input component
  123549. */
  123550. readonly right: NodeMaterialConnectionPoint;
  123551. /**
  123552. * Gets the output component
  123553. */
  123554. readonly output: NodeMaterialConnectionPoint;
  123555. protected _buildBlock(state: NodeMaterialBuildState): this;
  123556. }
  123557. }
  123558. declare module BABYLON {
  123559. /**
  123560. * Block used to step a value
  123561. */
  123562. export class StepBlock extends NodeMaterialBlock {
  123563. /**
  123564. * Creates a new StepBlock
  123565. * @param name defines the block name
  123566. */
  123567. constructor(name: string);
  123568. /**
  123569. * Gets the current class name
  123570. * @returns the class name
  123571. */
  123572. getClassName(): string;
  123573. /**
  123574. * Gets the value operand input component
  123575. */
  123576. readonly value: NodeMaterialConnectionPoint;
  123577. /**
  123578. * Gets the edge operand input component
  123579. */
  123580. readonly edge: NodeMaterialConnectionPoint;
  123581. /**
  123582. * Gets the output component
  123583. */
  123584. readonly output: NodeMaterialConnectionPoint;
  123585. protected _buildBlock(state: NodeMaterialBuildState): this;
  123586. }
  123587. }
  123588. declare module BABYLON {
  123589. /**
  123590. * Block used to get the opposite (1 - x) of a value
  123591. */
  123592. export class OneMinusBlock extends NodeMaterialBlock {
  123593. /**
  123594. * Creates a new OneMinusBlock
  123595. * @param name defines the block name
  123596. */
  123597. constructor(name: string);
  123598. /**
  123599. * Gets the current class name
  123600. * @returns the class name
  123601. */
  123602. getClassName(): string;
  123603. /**
  123604. * Gets the input component
  123605. */
  123606. readonly input: NodeMaterialConnectionPoint;
  123607. /**
  123608. * Gets the output component
  123609. */
  123610. readonly output: NodeMaterialConnectionPoint;
  123611. protected _buildBlock(state: NodeMaterialBuildState): this;
  123612. }
  123613. }
  123614. declare module BABYLON {
  123615. /**
  123616. * Block used to get the view direction
  123617. */
  123618. export class ViewDirectionBlock extends NodeMaterialBlock {
  123619. /**
  123620. * Creates a new ViewDirectionBlock
  123621. * @param name defines the block name
  123622. */
  123623. constructor(name: string);
  123624. /**
  123625. * Gets the current class name
  123626. * @returns the class name
  123627. */
  123628. getClassName(): string;
  123629. /**
  123630. * Gets the world position component
  123631. */
  123632. readonly worldPosition: NodeMaterialConnectionPoint;
  123633. /**
  123634. * Gets the camera position component
  123635. */
  123636. readonly cameraPosition: NodeMaterialConnectionPoint;
  123637. /**
  123638. * Gets the output component
  123639. */
  123640. readonly output: NodeMaterialConnectionPoint;
  123641. autoConfigure(material: NodeMaterial): void;
  123642. protected _buildBlock(state: NodeMaterialBuildState): this;
  123643. }
  123644. }
  123645. declare module BABYLON {
  123646. /**
  123647. * Block used to compute fresnel value
  123648. */
  123649. export class FresnelBlock extends NodeMaterialBlock {
  123650. /**
  123651. * Create a new FresnelBlock
  123652. * @param name defines the block name
  123653. */
  123654. constructor(name: string);
  123655. /**
  123656. * Gets the current class name
  123657. * @returns the class name
  123658. */
  123659. getClassName(): string;
  123660. /**
  123661. * Gets the world normal input component
  123662. */
  123663. readonly worldNormal: NodeMaterialConnectionPoint;
  123664. /**
  123665. * Gets the view direction input component
  123666. */
  123667. readonly viewDirection: NodeMaterialConnectionPoint;
  123668. /**
  123669. * Gets the bias input component
  123670. */
  123671. readonly bias: NodeMaterialConnectionPoint;
  123672. /**
  123673. * Gets the camera (or eye) position component
  123674. */
  123675. readonly power: NodeMaterialConnectionPoint;
  123676. /**
  123677. * Gets the fresnel output component
  123678. */
  123679. readonly fresnel: NodeMaterialConnectionPoint;
  123680. autoConfigure(material: NodeMaterial): void;
  123681. protected _buildBlock(state: NodeMaterialBuildState): this;
  123682. }
  123683. }
  123684. declare module BABYLON {
  123685. /**
  123686. * Block used to get the max of 2 values
  123687. */
  123688. export class MaxBlock extends NodeMaterialBlock {
  123689. /**
  123690. * Creates a new MaxBlock
  123691. * @param name defines the block name
  123692. */
  123693. constructor(name: string);
  123694. /**
  123695. * Gets the current class name
  123696. * @returns the class name
  123697. */
  123698. getClassName(): string;
  123699. /**
  123700. * Gets the left operand input component
  123701. */
  123702. readonly left: NodeMaterialConnectionPoint;
  123703. /**
  123704. * Gets the right operand input component
  123705. */
  123706. readonly right: NodeMaterialConnectionPoint;
  123707. /**
  123708. * Gets the output component
  123709. */
  123710. readonly output: NodeMaterialConnectionPoint;
  123711. protected _buildBlock(state: NodeMaterialBuildState): this;
  123712. }
  123713. }
  123714. declare module BABYLON {
  123715. /**
  123716. * Block used to get the min of 2 values
  123717. */
  123718. export class MinBlock extends NodeMaterialBlock {
  123719. /**
  123720. * Creates a new MinBlock
  123721. * @param name defines the block name
  123722. */
  123723. constructor(name: string);
  123724. /**
  123725. * Gets the current class name
  123726. * @returns the class name
  123727. */
  123728. getClassName(): string;
  123729. /**
  123730. * Gets the left operand input component
  123731. */
  123732. readonly left: NodeMaterialConnectionPoint;
  123733. /**
  123734. * Gets the right operand input component
  123735. */
  123736. readonly right: NodeMaterialConnectionPoint;
  123737. /**
  123738. * Gets the output component
  123739. */
  123740. readonly output: NodeMaterialConnectionPoint;
  123741. protected _buildBlock(state: NodeMaterialBuildState): this;
  123742. }
  123743. }
  123744. declare module BABYLON {
  123745. /**
  123746. * Block used to get the distance between 2 values
  123747. */
  123748. export class DistanceBlock extends NodeMaterialBlock {
  123749. /**
  123750. * Creates a new DistanceBlock
  123751. * @param name defines the block name
  123752. */
  123753. constructor(name: string);
  123754. /**
  123755. * Gets the current class name
  123756. * @returns the class name
  123757. */
  123758. getClassName(): string;
  123759. /**
  123760. * Gets the left operand input component
  123761. */
  123762. readonly left: NodeMaterialConnectionPoint;
  123763. /**
  123764. * Gets the right operand input component
  123765. */
  123766. readonly right: NodeMaterialConnectionPoint;
  123767. /**
  123768. * Gets the output component
  123769. */
  123770. readonly output: NodeMaterialConnectionPoint;
  123771. protected _buildBlock(state: NodeMaterialBuildState): this;
  123772. }
  123773. }
  123774. declare module BABYLON {
  123775. /**
  123776. * Block used to get the length of a vector
  123777. */
  123778. export class LengthBlock extends NodeMaterialBlock {
  123779. /**
  123780. * Creates a new LengthBlock
  123781. * @param name defines the block name
  123782. */
  123783. constructor(name: string);
  123784. /**
  123785. * Gets the current class name
  123786. * @returns the class name
  123787. */
  123788. getClassName(): string;
  123789. /**
  123790. * Gets the value input component
  123791. */
  123792. readonly value: NodeMaterialConnectionPoint;
  123793. /**
  123794. * Gets the output component
  123795. */
  123796. readonly output: NodeMaterialConnectionPoint;
  123797. protected _buildBlock(state: NodeMaterialBuildState): this;
  123798. }
  123799. }
  123800. declare module BABYLON {
  123801. /**
  123802. * Block used to get negative version of a value (i.e. x * -1)
  123803. */
  123804. export class NegateBlock extends NodeMaterialBlock {
  123805. /**
  123806. * Creates a new NegateBlock
  123807. * @param name defines the block name
  123808. */
  123809. constructor(name: string);
  123810. /**
  123811. * Gets the current class name
  123812. * @returns the class name
  123813. */
  123814. getClassName(): string;
  123815. /**
  123816. * Gets the value input component
  123817. */
  123818. readonly value: NodeMaterialConnectionPoint;
  123819. /**
  123820. * Gets the output component
  123821. */
  123822. readonly output: NodeMaterialConnectionPoint;
  123823. protected _buildBlock(state: NodeMaterialBuildState): this;
  123824. }
  123825. }
  123826. declare module BABYLON {
  123827. /**
  123828. * Block used to get the value of the first parameter raised to the power of the second
  123829. */
  123830. export class PowBlock extends NodeMaterialBlock {
  123831. /**
  123832. * Creates a new PowBlock
  123833. * @param name defines the block name
  123834. */
  123835. constructor(name: string);
  123836. /**
  123837. * Gets the current class name
  123838. * @returns the class name
  123839. */
  123840. getClassName(): string;
  123841. /**
  123842. * Gets the value operand input component
  123843. */
  123844. readonly value: NodeMaterialConnectionPoint;
  123845. /**
  123846. * Gets the power operand input component
  123847. */
  123848. readonly power: NodeMaterialConnectionPoint;
  123849. /**
  123850. * Gets the output component
  123851. */
  123852. readonly output: NodeMaterialConnectionPoint;
  123853. protected _buildBlock(state: NodeMaterialBuildState): this;
  123854. }
  123855. }
  123856. declare module BABYLON {
  123857. /**
  123858. * Block used to get a random number
  123859. */
  123860. export class RandomNumberBlock extends NodeMaterialBlock {
  123861. /**
  123862. * Creates a new RandomNumberBlock
  123863. * @param name defines the block name
  123864. */
  123865. constructor(name: string);
  123866. /**
  123867. * Gets the current class name
  123868. * @returns the class name
  123869. */
  123870. getClassName(): string;
  123871. /**
  123872. * Gets the seed input component
  123873. */
  123874. readonly seed: NodeMaterialConnectionPoint;
  123875. /**
  123876. * Gets the output component
  123877. */
  123878. readonly output: NodeMaterialConnectionPoint;
  123879. protected _buildBlock(state: NodeMaterialBuildState): this;
  123880. }
  123881. }
  123882. declare module BABYLON {
  123883. /**
  123884. * Block used to compute arc tangent of 2 values
  123885. */
  123886. export class ArcTan2Block extends NodeMaterialBlock {
  123887. /**
  123888. * Creates a new ArcTan2Block
  123889. * @param name defines the block name
  123890. */
  123891. constructor(name: string);
  123892. /**
  123893. * Gets the current class name
  123894. * @returns the class name
  123895. */
  123896. getClassName(): string;
  123897. /**
  123898. * Gets the x operand input component
  123899. */
  123900. readonly x: NodeMaterialConnectionPoint;
  123901. /**
  123902. * Gets the y operand input component
  123903. */
  123904. readonly y: NodeMaterialConnectionPoint;
  123905. /**
  123906. * Gets the output component
  123907. */
  123908. readonly output: NodeMaterialConnectionPoint;
  123909. protected _buildBlock(state: NodeMaterialBuildState): this;
  123910. }
  123911. }
  123912. declare module BABYLON {
  123913. /**
  123914. * Block used to smooth step a value
  123915. */
  123916. export class SmoothStepBlock extends NodeMaterialBlock {
  123917. /**
  123918. * Creates a new SmoothStepBlock
  123919. * @param name defines the block name
  123920. */
  123921. constructor(name: string);
  123922. /**
  123923. * Gets the current class name
  123924. * @returns the class name
  123925. */
  123926. getClassName(): string;
  123927. /**
  123928. * Gets the value operand input component
  123929. */
  123930. readonly value: NodeMaterialConnectionPoint;
  123931. /**
  123932. * Gets the first edge operand input component
  123933. */
  123934. readonly edge0: NodeMaterialConnectionPoint;
  123935. /**
  123936. * Gets the second edge operand input component
  123937. */
  123938. readonly edge1: NodeMaterialConnectionPoint;
  123939. /**
  123940. * Gets the output component
  123941. */
  123942. readonly output: NodeMaterialConnectionPoint;
  123943. protected _buildBlock(state: NodeMaterialBuildState): this;
  123944. }
  123945. }
  123946. declare module BABYLON {
  123947. /**
  123948. * Block used to get the reciprocal (1 / x) of a value
  123949. */
  123950. export class ReciprocalBlock extends NodeMaterialBlock {
  123951. /**
  123952. * Creates a new ReciprocalBlock
  123953. * @param name defines the block name
  123954. */
  123955. constructor(name: string);
  123956. /**
  123957. * Gets the current class name
  123958. * @returns the class name
  123959. */
  123960. getClassName(): string;
  123961. /**
  123962. * Gets the input component
  123963. */
  123964. readonly input: NodeMaterialConnectionPoint;
  123965. /**
  123966. * Gets the output component
  123967. */
  123968. readonly output: NodeMaterialConnectionPoint;
  123969. protected _buildBlock(state: NodeMaterialBuildState): this;
  123970. }
  123971. }
  123972. declare module BABYLON {
  123973. /**
  123974. * Block used to replace a color by another one
  123975. */
  123976. export class ReplaceColorBlock extends NodeMaterialBlock {
  123977. /**
  123978. * Creates a new ReplaceColorBlock
  123979. * @param name defines the block name
  123980. */
  123981. constructor(name: string);
  123982. /**
  123983. * Gets the current class name
  123984. * @returns the class name
  123985. */
  123986. getClassName(): string;
  123987. /**
  123988. * Gets the value input component
  123989. */
  123990. readonly value: NodeMaterialConnectionPoint;
  123991. /**
  123992. * Gets the reference input component
  123993. */
  123994. readonly reference: NodeMaterialConnectionPoint;
  123995. /**
  123996. * Gets the distance input component
  123997. */
  123998. readonly distance: NodeMaterialConnectionPoint;
  123999. /**
  124000. * Gets the replacement input component
  124001. */
  124002. readonly replacement: NodeMaterialConnectionPoint;
  124003. /**
  124004. * Gets the output component
  124005. */
  124006. readonly output: NodeMaterialConnectionPoint;
  124007. protected _buildBlock(state: NodeMaterialBuildState): this;
  124008. }
  124009. }
  124010. declare module BABYLON {
  124011. /**
  124012. * Block used to posterize a value
  124013. * @see https://en.wikipedia.org/wiki/Posterization
  124014. */
  124015. export class PosterizeBlock extends NodeMaterialBlock {
  124016. /**
  124017. * Creates a new PosterizeBlock
  124018. * @param name defines the block name
  124019. */
  124020. constructor(name: string);
  124021. /**
  124022. * Gets the current class name
  124023. * @returns the class name
  124024. */
  124025. getClassName(): string;
  124026. /**
  124027. * Gets the value input component
  124028. */
  124029. readonly value: NodeMaterialConnectionPoint;
  124030. /**
  124031. * Gets the steps input component
  124032. */
  124033. readonly steps: NodeMaterialConnectionPoint;
  124034. /**
  124035. * Gets the output component
  124036. */
  124037. readonly output: NodeMaterialConnectionPoint;
  124038. protected _buildBlock(state: NodeMaterialBuildState): this;
  124039. }
  124040. }
  124041. declare module BABYLON {
  124042. /**
  124043. * Operations supported by the Wave block
  124044. */
  124045. export enum WaveBlockKind {
  124046. /** SawTooth */
  124047. SawTooth = 0,
  124048. /** Square */
  124049. Square = 1,
  124050. /** Triangle */
  124051. Triangle = 2
  124052. }
  124053. /**
  124054. * Block used to apply wave operation to floats
  124055. */
  124056. export class WaveBlock extends NodeMaterialBlock {
  124057. /**
  124058. * Gets or sets the kibnd of wave to be applied by the block
  124059. */
  124060. kind: WaveBlockKind;
  124061. /**
  124062. * Creates a new WaveBlock
  124063. * @param name defines the block name
  124064. */
  124065. constructor(name: string);
  124066. /**
  124067. * Gets the current class name
  124068. * @returns the class name
  124069. */
  124070. getClassName(): string;
  124071. /**
  124072. * Gets the input component
  124073. */
  124074. readonly input: NodeMaterialConnectionPoint;
  124075. /**
  124076. * Gets the output component
  124077. */
  124078. readonly output: NodeMaterialConnectionPoint;
  124079. protected _buildBlock(state: NodeMaterialBuildState): this;
  124080. serialize(): any;
  124081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124082. }
  124083. }
  124084. declare module BABYLON {
  124085. /**
  124086. * Class used to store a color step for the GradientBlock
  124087. */
  124088. export class GradientBlockColorStep {
  124089. /**
  124090. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124091. */
  124092. step: number;
  124093. /**
  124094. * Gets or sets the color associated with this step
  124095. */
  124096. color: Color3;
  124097. /**
  124098. * Creates a new GradientBlockColorStep
  124099. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124100. * @param color defines the color associated with this step
  124101. */
  124102. constructor(
  124103. /**
  124104. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124105. */
  124106. step: number,
  124107. /**
  124108. * Gets or sets the color associated with this step
  124109. */
  124110. color: Color3);
  124111. }
  124112. /**
  124113. * Block used to return a color from a gradient based on an input value between 0 and 1
  124114. */
  124115. export class GradientBlock extends NodeMaterialBlock {
  124116. /**
  124117. * Gets or sets the list of color steps
  124118. */
  124119. colorSteps: GradientBlockColorStep[];
  124120. /**
  124121. * Creates a new GradientBlock
  124122. * @param name defines the block name
  124123. */
  124124. constructor(name: string);
  124125. /**
  124126. * Gets the current class name
  124127. * @returns the class name
  124128. */
  124129. getClassName(): string;
  124130. /**
  124131. * Gets the gradient input component
  124132. */
  124133. readonly gradient: NodeMaterialConnectionPoint;
  124134. /**
  124135. * Gets the output component
  124136. */
  124137. readonly output: NodeMaterialConnectionPoint;
  124138. private _writeColorConstant;
  124139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124140. serialize(): any;
  124141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124142. protected _dumpPropertiesCode(): string;
  124143. }
  124144. }
  124145. declare module BABYLON {
  124146. /**
  124147. * Block used to normalize lerp between 2 values
  124148. */
  124149. export class NLerpBlock extends NodeMaterialBlock {
  124150. /**
  124151. * Creates a new NLerpBlock
  124152. * @param name defines the block name
  124153. */
  124154. constructor(name: string);
  124155. /**
  124156. * Gets the current class name
  124157. * @returns the class name
  124158. */
  124159. getClassName(): string;
  124160. /**
  124161. * Gets the left operand input component
  124162. */
  124163. readonly left: NodeMaterialConnectionPoint;
  124164. /**
  124165. * Gets the right operand input component
  124166. */
  124167. readonly right: NodeMaterialConnectionPoint;
  124168. /**
  124169. * Gets the gradient operand input component
  124170. */
  124171. readonly gradient: NodeMaterialConnectionPoint;
  124172. /**
  124173. * Gets the output component
  124174. */
  124175. readonly output: NodeMaterialConnectionPoint;
  124176. protected _buildBlock(state: NodeMaterialBuildState): this;
  124177. }
  124178. }
  124179. declare module BABYLON {
  124180. /**
  124181. * Block used to test if the fragment shader is front facing
  124182. */
  124183. export class FrontFacingBlock extends NodeMaterialBlock {
  124184. /**
  124185. * Creates a new FrontFacingBlock
  124186. * @param name defines the block name
  124187. */
  124188. constructor(name: string);
  124189. /**
  124190. * Gets the current class name
  124191. * @returns the class name
  124192. */
  124193. getClassName(): string;
  124194. /**
  124195. * Gets the world normal component
  124196. */
  124197. readonly worldNormal: NodeMaterialConnectionPoint;
  124198. /**
  124199. * Gets the view direction input component
  124200. */
  124201. readonly viewDirection: NodeMaterialConnectionPoint;
  124202. /**
  124203. * Gets the output component
  124204. */
  124205. readonly output: NodeMaterialConnectionPoint;
  124206. autoConfigure(material: NodeMaterial): void;
  124207. protected _buildBlock(state: NodeMaterialBuildState): this;
  124208. }
  124209. }
  124210. declare module BABYLON {
  124211. /**
  124212. * Effect Render Options
  124213. */
  124214. export interface IEffectRendererOptions {
  124215. /**
  124216. * Defines the vertices positions.
  124217. */
  124218. positions?: number[];
  124219. /**
  124220. * Defines the indices.
  124221. */
  124222. indices?: number[];
  124223. }
  124224. /**
  124225. * Helper class to render one or more effects
  124226. */
  124227. export class EffectRenderer {
  124228. private engine;
  124229. private static _DefaultOptions;
  124230. private _vertexBuffers;
  124231. private _indexBuffer;
  124232. private _ringBufferIndex;
  124233. private _ringScreenBuffer;
  124234. private _fullscreenViewport;
  124235. private _getNextFrameBuffer;
  124236. /**
  124237. * Creates an effect renderer
  124238. * @param engine the engine to use for rendering
  124239. * @param options defines the options of the effect renderer
  124240. */
  124241. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124242. /**
  124243. * Sets the current viewport in normalized coordinates 0-1
  124244. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124245. */
  124246. setViewport(viewport?: Viewport): void;
  124247. /**
  124248. * Binds the embedded attributes buffer to the effect.
  124249. * @param effect Defines the effect to bind the attributes for
  124250. */
  124251. bindBuffers(effect: Effect): void;
  124252. /**
  124253. * Sets the current effect wrapper to use during draw.
  124254. * The effect needs to be ready before calling this api.
  124255. * This also sets the default full screen position attribute.
  124256. * @param effectWrapper Defines the effect to draw with
  124257. */
  124258. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124259. /**
  124260. * Draws a full screen quad.
  124261. */
  124262. draw(): void;
  124263. /**
  124264. * renders one or more effects to a specified texture
  124265. * @param effectWrappers list of effects to renderer
  124266. * @param outputTexture texture to draw to, if null it will render to the screen
  124267. */
  124268. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124269. /**
  124270. * Disposes of the effect renderer
  124271. */
  124272. dispose(): void;
  124273. }
  124274. /**
  124275. * Options to create an EffectWrapper
  124276. */
  124277. interface EffectWrapperCreationOptions {
  124278. /**
  124279. * Engine to use to create the effect
  124280. */
  124281. engine: ThinEngine;
  124282. /**
  124283. * Fragment shader for the effect
  124284. */
  124285. fragmentShader: string;
  124286. /**
  124287. * Vertex shader for the effect
  124288. */
  124289. vertexShader?: string;
  124290. /**
  124291. * Attributes to use in the shader
  124292. */
  124293. attributeNames?: Array<string>;
  124294. /**
  124295. * Uniforms to use in the shader
  124296. */
  124297. uniformNames?: Array<string>;
  124298. /**
  124299. * Texture sampler names to use in the shader
  124300. */
  124301. samplerNames?: Array<string>;
  124302. /**
  124303. * The friendly name of the effect displayed in Spector.
  124304. */
  124305. name?: string;
  124306. }
  124307. /**
  124308. * Wraps an effect to be used for rendering
  124309. */
  124310. export class EffectWrapper {
  124311. /**
  124312. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124313. */
  124314. onApplyObservable: Observable<{}>;
  124315. /**
  124316. * The underlying effect
  124317. */
  124318. effect: Effect;
  124319. /**
  124320. * Creates an effect to be renderer
  124321. * @param creationOptions options to create the effect
  124322. */
  124323. constructor(creationOptions: EffectWrapperCreationOptions);
  124324. /**
  124325. * Disposes of the effect wrapper
  124326. */
  124327. dispose(): void;
  124328. }
  124329. }
  124330. declare module BABYLON {
  124331. /**
  124332. * Helper class to push actions to a pool of workers.
  124333. */
  124334. export class WorkerPool implements IDisposable {
  124335. private _workerInfos;
  124336. private _pendingActions;
  124337. /**
  124338. * Constructor
  124339. * @param workers Array of workers to use for actions
  124340. */
  124341. constructor(workers: Array<Worker>);
  124342. /**
  124343. * Terminates all workers and clears any pending actions.
  124344. */
  124345. dispose(): void;
  124346. /**
  124347. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124348. * pended until a worker has completed its action.
  124349. * @param action The action to perform. Call onComplete when the action is complete.
  124350. */
  124351. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124352. private _execute;
  124353. }
  124354. }
  124355. declare module BABYLON {
  124356. /**
  124357. * Configuration for Draco compression
  124358. */
  124359. export interface IDracoCompressionConfiguration {
  124360. /**
  124361. * Configuration for the decoder.
  124362. */
  124363. decoder: {
  124364. /**
  124365. * The url to the WebAssembly module.
  124366. */
  124367. wasmUrl?: string;
  124368. /**
  124369. * The url to the WebAssembly binary.
  124370. */
  124371. wasmBinaryUrl?: string;
  124372. /**
  124373. * The url to the fallback JavaScript module.
  124374. */
  124375. fallbackUrl?: string;
  124376. };
  124377. }
  124378. /**
  124379. * Draco compression (https://google.github.io/draco/)
  124380. *
  124381. * This class wraps the Draco module.
  124382. *
  124383. * **Encoder**
  124384. *
  124385. * The encoder is not currently implemented.
  124386. *
  124387. * **Decoder**
  124388. *
  124389. * 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.
  124390. *
  124391. * To update the configuration, use the following code:
  124392. * ```javascript
  124393. * DracoCompression.Configuration = {
  124394. * decoder: {
  124395. * wasmUrl: "<url to the WebAssembly library>",
  124396. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124397. * fallbackUrl: "<url to the fallback JavaScript library>",
  124398. * }
  124399. * };
  124400. * ```
  124401. *
  124402. * 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.
  124403. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124404. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124405. *
  124406. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124407. * ```javascript
  124408. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124409. * ```
  124410. *
  124411. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124412. */
  124413. export class DracoCompression implements IDisposable {
  124414. private _workerPoolPromise?;
  124415. private _decoderModulePromise?;
  124416. /**
  124417. * The configuration. Defaults to the following urls:
  124418. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124419. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124420. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124421. */
  124422. static Configuration: IDracoCompressionConfiguration;
  124423. /**
  124424. * Returns true if the decoder configuration is available.
  124425. */
  124426. static readonly DecoderAvailable: boolean;
  124427. /**
  124428. * Default number of workers to create when creating the draco compression object.
  124429. */
  124430. static DefaultNumWorkers: number;
  124431. private static GetDefaultNumWorkers;
  124432. private static _Default;
  124433. /**
  124434. * Default instance for the draco compression object.
  124435. */
  124436. static readonly Default: DracoCompression;
  124437. /**
  124438. * Constructor
  124439. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124440. */
  124441. constructor(numWorkers?: number);
  124442. /**
  124443. * Stop all async operations and release resources.
  124444. */
  124445. dispose(): void;
  124446. /**
  124447. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124448. * @returns a promise that resolves when ready
  124449. */
  124450. whenReadyAsync(): Promise<void>;
  124451. /**
  124452. * Decode Draco compressed mesh data to vertex data.
  124453. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124454. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124455. * @returns A promise that resolves with the decoded vertex data
  124456. */
  124457. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124458. [kind: string]: number;
  124459. }): Promise<VertexData>;
  124460. }
  124461. }
  124462. declare module BABYLON {
  124463. /**
  124464. * Class for building Constructive Solid Geometry
  124465. */
  124466. export class CSG {
  124467. private polygons;
  124468. /**
  124469. * The world matrix
  124470. */
  124471. matrix: Matrix;
  124472. /**
  124473. * Stores the position
  124474. */
  124475. position: Vector3;
  124476. /**
  124477. * Stores the rotation
  124478. */
  124479. rotation: Vector3;
  124480. /**
  124481. * Stores the rotation quaternion
  124482. */
  124483. rotationQuaternion: Nullable<Quaternion>;
  124484. /**
  124485. * Stores the scaling vector
  124486. */
  124487. scaling: Vector3;
  124488. /**
  124489. * Convert the Mesh to CSG
  124490. * @param mesh The Mesh to convert to CSG
  124491. * @returns A new CSG from the Mesh
  124492. */
  124493. static FromMesh(mesh: Mesh): CSG;
  124494. /**
  124495. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124496. * @param polygons Polygons used to construct a CSG solid
  124497. */
  124498. private static FromPolygons;
  124499. /**
  124500. * Clones, or makes a deep copy, of the CSG
  124501. * @returns A new CSG
  124502. */
  124503. clone(): CSG;
  124504. /**
  124505. * Unions this CSG with another CSG
  124506. * @param csg The CSG to union against this CSG
  124507. * @returns The unioned CSG
  124508. */
  124509. union(csg: CSG): CSG;
  124510. /**
  124511. * Unions this CSG with another CSG in place
  124512. * @param csg The CSG to union against this CSG
  124513. */
  124514. unionInPlace(csg: CSG): void;
  124515. /**
  124516. * Subtracts this CSG with another CSG
  124517. * @param csg The CSG to subtract against this CSG
  124518. * @returns A new CSG
  124519. */
  124520. subtract(csg: CSG): CSG;
  124521. /**
  124522. * Subtracts this CSG with another CSG in place
  124523. * @param csg The CSG to subtact against this CSG
  124524. */
  124525. subtractInPlace(csg: CSG): void;
  124526. /**
  124527. * Intersect this CSG with another CSG
  124528. * @param csg The CSG to intersect against this CSG
  124529. * @returns A new CSG
  124530. */
  124531. intersect(csg: CSG): CSG;
  124532. /**
  124533. * Intersects this CSG with another CSG in place
  124534. * @param csg The CSG to intersect against this CSG
  124535. */
  124536. intersectInPlace(csg: CSG): void;
  124537. /**
  124538. * Return a new CSG solid with solid and empty space switched. This solid is
  124539. * not modified.
  124540. * @returns A new CSG solid with solid and empty space switched
  124541. */
  124542. inverse(): CSG;
  124543. /**
  124544. * Inverses the CSG in place
  124545. */
  124546. inverseInPlace(): void;
  124547. /**
  124548. * This is used to keep meshes transformations so they can be restored
  124549. * when we build back a Babylon Mesh
  124550. * NB : All CSG operations are performed in world coordinates
  124551. * @param csg The CSG to copy the transform attributes from
  124552. * @returns This CSG
  124553. */
  124554. copyTransformAttributes(csg: CSG): CSG;
  124555. /**
  124556. * Build Raw mesh from CSG
  124557. * Coordinates here are in world space
  124558. * @param name The name of the mesh geometry
  124559. * @param scene The Scene
  124560. * @param keepSubMeshes Specifies if the submeshes should be kept
  124561. * @returns A new Mesh
  124562. */
  124563. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124564. /**
  124565. * Build Mesh from CSG taking material and transforms into account
  124566. * @param name The name of the Mesh
  124567. * @param material The material of the Mesh
  124568. * @param scene The Scene
  124569. * @param keepSubMeshes Specifies if submeshes should be kept
  124570. * @returns The new Mesh
  124571. */
  124572. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124573. }
  124574. }
  124575. declare module BABYLON {
  124576. /**
  124577. * Class used to create a trail following a mesh
  124578. */
  124579. export class TrailMesh extends Mesh {
  124580. private _generator;
  124581. private _autoStart;
  124582. private _running;
  124583. private _diameter;
  124584. private _length;
  124585. private _sectionPolygonPointsCount;
  124586. private _sectionVectors;
  124587. private _sectionNormalVectors;
  124588. private _beforeRenderObserver;
  124589. /**
  124590. * @constructor
  124591. * @param name The value used by scene.getMeshByName() to do a lookup.
  124592. * @param generator The mesh to generate a trail.
  124593. * @param scene The scene to add this mesh to.
  124594. * @param diameter Diameter of trailing mesh. Default is 1.
  124595. * @param length Length of trailing mesh. Default is 60.
  124596. * @param autoStart Automatically start trailing mesh. Default true.
  124597. */
  124598. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124599. /**
  124600. * "TrailMesh"
  124601. * @returns "TrailMesh"
  124602. */
  124603. getClassName(): string;
  124604. private _createMesh;
  124605. /**
  124606. * Start trailing mesh.
  124607. */
  124608. start(): void;
  124609. /**
  124610. * Stop trailing mesh.
  124611. */
  124612. stop(): void;
  124613. /**
  124614. * Update trailing mesh geometry.
  124615. */
  124616. update(): void;
  124617. /**
  124618. * Returns a new TrailMesh object.
  124619. * @param name is a string, the name given to the new mesh
  124620. * @param newGenerator use new generator object for cloned trail mesh
  124621. * @returns a new mesh
  124622. */
  124623. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124624. /**
  124625. * Serializes this trail mesh
  124626. * @param serializationObject object to write serialization to
  124627. */
  124628. serialize(serializationObject: any): void;
  124629. /**
  124630. * Parses a serialized trail mesh
  124631. * @param parsedMesh the serialized mesh
  124632. * @param scene the scene to create the trail mesh in
  124633. * @returns the created trail mesh
  124634. */
  124635. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124636. }
  124637. }
  124638. declare module BABYLON {
  124639. /**
  124640. * Class containing static functions to help procedurally build meshes
  124641. */
  124642. export class TiledBoxBuilder {
  124643. /**
  124644. * Creates a box mesh
  124645. * 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)
  124646. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124650. * @param name defines the name of the mesh
  124651. * @param options defines the options used to create the mesh
  124652. * @param scene defines the hosting scene
  124653. * @returns the box mesh
  124654. */
  124655. static CreateTiledBox(name: string, options: {
  124656. pattern?: number;
  124657. width?: number;
  124658. height?: number;
  124659. depth?: number;
  124660. tileSize?: number;
  124661. tileWidth?: number;
  124662. tileHeight?: number;
  124663. alignHorizontal?: number;
  124664. alignVertical?: number;
  124665. faceUV?: Vector4[];
  124666. faceColors?: Color4[];
  124667. sideOrientation?: number;
  124668. updatable?: boolean;
  124669. }, scene?: Nullable<Scene>): Mesh;
  124670. }
  124671. }
  124672. declare module BABYLON {
  124673. /**
  124674. * Class containing static functions to help procedurally build meshes
  124675. */
  124676. export class TorusKnotBuilder {
  124677. /**
  124678. * Creates a torus knot mesh
  124679. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124680. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124681. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124682. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124686. * @param name defines the name of the mesh
  124687. * @param options defines the options used to create the mesh
  124688. * @param scene defines the hosting scene
  124689. * @returns the torus knot mesh
  124690. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124691. */
  124692. static CreateTorusKnot(name: string, options: {
  124693. radius?: number;
  124694. tube?: number;
  124695. radialSegments?: number;
  124696. tubularSegments?: number;
  124697. p?: number;
  124698. q?: number;
  124699. updatable?: boolean;
  124700. sideOrientation?: number;
  124701. frontUVs?: Vector4;
  124702. backUVs?: Vector4;
  124703. }, scene: any): Mesh;
  124704. }
  124705. }
  124706. declare module BABYLON {
  124707. /**
  124708. * Polygon
  124709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124710. */
  124711. export class Polygon {
  124712. /**
  124713. * Creates a rectangle
  124714. * @param xmin bottom X coord
  124715. * @param ymin bottom Y coord
  124716. * @param xmax top X coord
  124717. * @param ymax top Y coord
  124718. * @returns points that make the resulting rectation
  124719. */
  124720. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124721. /**
  124722. * Creates a circle
  124723. * @param radius radius of circle
  124724. * @param cx scale in x
  124725. * @param cy scale in y
  124726. * @param numberOfSides number of sides that make up the circle
  124727. * @returns points that make the resulting circle
  124728. */
  124729. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124730. /**
  124731. * Creates a polygon from input string
  124732. * @param input Input polygon data
  124733. * @returns the parsed points
  124734. */
  124735. static Parse(input: string): Vector2[];
  124736. /**
  124737. * Starts building a polygon from x and y coordinates
  124738. * @param x x coordinate
  124739. * @param y y coordinate
  124740. * @returns the started path2
  124741. */
  124742. static StartingAt(x: number, y: number): Path2;
  124743. }
  124744. /**
  124745. * Builds a polygon
  124746. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124747. */
  124748. export class PolygonMeshBuilder {
  124749. private _points;
  124750. private _outlinepoints;
  124751. private _holes;
  124752. private _name;
  124753. private _scene;
  124754. private _epoints;
  124755. private _eholes;
  124756. private _addToepoint;
  124757. /**
  124758. * Babylon reference to the earcut plugin.
  124759. */
  124760. bjsEarcut: any;
  124761. /**
  124762. * Creates a PolygonMeshBuilder
  124763. * @param name name of the builder
  124764. * @param contours Path of the polygon
  124765. * @param scene scene to add to when creating the mesh
  124766. * @param earcutInjection can be used to inject your own earcut reference
  124767. */
  124768. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124769. /**
  124770. * Adds a whole within the polygon
  124771. * @param hole Array of points defining the hole
  124772. * @returns this
  124773. */
  124774. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124775. /**
  124776. * Creates the polygon
  124777. * @param updatable If the mesh should be updatable
  124778. * @param depth The depth of the mesh created
  124779. * @returns the created mesh
  124780. */
  124781. build(updatable?: boolean, depth?: number): Mesh;
  124782. /**
  124783. * Creates the polygon
  124784. * @param depth The depth of the mesh created
  124785. * @returns the created VertexData
  124786. */
  124787. buildVertexData(depth?: number): VertexData;
  124788. /**
  124789. * Adds a side to the polygon
  124790. * @param positions points that make the polygon
  124791. * @param normals normals of the polygon
  124792. * @param uvs uvs of the polygon
  124793. * @param indices indices of the polygon
  124794. * @param bounds bounds of the polygon
  124795. * @param points points of the polygon
  124796. * @param depth depth of the polygon
  124797. * @param flip flip of the polygon
  124798. */
  124799. private addSide;
  124800. }
  124801. }
  124802. declare module BABYLON {
  124803. /**
  124804. * Class containing static functions to help procedurally build meshes
  124805. */
  124806. export class PolygonBuilder {
  124807. /**
  124808. * Creates a polygon mesh
  124809. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124810. * * 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
  124811. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124814. * * Remember you can only change the shape positions, not their number when updating a polygon
  124815. * @param name defines the name of the mesh
  124816. * @param options defines the options used to create the mesh
  124817. * @param scene defines the hosting scene
  124818. * @param earcutInjection can be used to inject your own earcut reference
  124819. * @returns the polygon mesh
  124820. */
  124821. static CreatePolygon(name: string, options: {
  124822. shape: Vector3[];
  124823. holes?: Vector3[][];
  124824. depth?: number;
  124825. faceUV?: Vector4[];
  124826. faceColors?: Color4[];
  124827. updatable?: boolean;
  124828. sideOrientation?: number;
  124829. frontUVs?: Vector4;
  124830. backUVs?: Vector4;
  124831. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124832. /**
  124833. * Creates an extruded polygon mesh, with depth in the Y direction.
  124834. * * 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)
  124835. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124836. * @param name defines the name of the mesh
  124837. * @param options defines the options used to create the mesh
  124838. * @param scene defines the hosting scene
  124839. * @param earcutInjection can be used to inject your own earcut reference
  124840. * @returns the polygon mesh
  124841. */
  124842. static ExtrudePolygon(name: string, options: {
  124843. shape: Vector3[];
  124844. holes?: Vector3[][];
  124845. depth?: number;
  124846. faceUV?: Vector4[];
  124847. faceColors?: Color4[];
  124848. updatable?: boolean;
  124849. sideOrientation?: number;
  124850. frontUVs?: Vector4;
  124851. backUVs?: Vector4;
  124852. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124853. }
  124854. }
  124855. declare module BABYLON {
  124856. /**
  124857. * Class containing static functions to help procedurally build meshes
  124858. */
  124859. export class LatheBuilder {
  124860. /**
  124861. * Creates lathe mesh.
  124862. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124863. * * 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
  124864. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124865. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124866. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124867. * * 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
  124868. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124869. * * 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
  124870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124874. * @param name defines the name of the mesh
  124875. * @param options defines the options used to create the mesh
  124876. * @param scene defines the hosting scene
  124877. * @returns the lathe mesh
  124878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124879. */
  124880. static CreateLathe(name: string, options: {
  124881. shape: Vector3[];
  124882. radius?: number;
  124883. tessellation?: number;
  124884. clip?: number;
  124885. arc?: number;
  124886. closed?: boolean;
  124887. updatable?: boolean;
  124888. sideOrientation?: number;
  124889. frontUVs?: Vector4;
  124890. backUVs?: Vector4;
  124891. cap?: number;
  124892. invertUV?: boolean;
  124893. }, scene?: Nullable<Scene>): Mesh;
  124894. }
  124895. }
  124896. declare module BABYLON {
  124897. /**
  124898. * Class containing static functions to help procedurally build meshes
  124899. */
  124900. export class TiledPlaneBuilder {
  124901. /**
  124902. * Creates a tiled plane mesh
  124903. * * The parameter `pattern` will, depending on value, do nothing or
  124904. * * * flip (reflect about central vertical) alternate tiles across and up
  124905. * * * flip every tile on alternate rows
  124906. * * * rotate (180 degs) alternate tiles across and up
  124907. * * * rotate every tile on alternate rows
  124908. * * * flip and rotate alternate tiles across and up
  124909. * * * flip and rotate every tile on alternate rows
  124910. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124911. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124914. * * 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)
  124915. * * 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)
  124916. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124917. * @param name defines the name of the mesh
  124918. * @param options defines the options used to create the mesh
  124919. * @param scene defines the hosting scene
  124920. * @returns the box mesh
  124921. */
  124922. static CreateTiledPlane(name: string, options: {
  124923. pattern?: number;
  124924. tileSize?: number;
  124925. tileWidth?: number;
  124926. tileHeight?: number;
  124927. size?: number;
  124928. width?: number;
  124929. height?: number;
  124930. alignHorizontal?: number;
  124931. alignVertical?: number;
  124932. sideOrientation?: number;
  124933. frontUVs?: Vector4;
  124934. backUVs?: Vector4;
  124935. updatable?: boolean;
  124936. }, scene?: Nullable<Scene>): Mesh;
  124937. }
  124938. }
  124939. declare module BABYLON {
  124940. /**
  124941. * Class containing static functions to help procedurally build meshes
  124942. */
  124943. export class TubeBuilder {
  124944. /**
  124945. * Creates a tube mesh.
  124946. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124947. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124948. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124949. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124950. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124951. * * 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)
  124952. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124953. * * 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
  124954. * * 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
  124955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124959. * @param name defines the name of the mesh
  124960. * @param options defines the options used to create the mesh
  124961. * @param scene defines the hosting scene
  124962. * @returns the tube mesh
  124963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124964. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124965. */
  124966. static CreateTube(name: string, options: {
  124967. path: Vector3[];
  124968. radius?: number;
  124969. tessellation?: number;
  124970. radiusFunction?: {
  124971. (i: number, distance: number): number;
  124972. };
  124973. cap?: number;
  124974. arc?: number;
  124975. updatable?: boolean;
  124976. sideOrientation?: number;
  124977. frontUVs?: Vector4;
  124978. backUVs?: Vector4;
  124979. instance?: Mesh;
  124980. invertUV?: boolean;
  124981. }, scene?: Nullable<Scene>): Mesh;
  124982. }
  124983. }
  124984. declare module BABYLON {
  124985. /**
  124986. * Class containing static functions to help procedurally build meshes
  124987. */
  124988. export class IcoSphereBuilder {
  124989. /**
  124990. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124991. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124992. * * 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`)
  124993. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124994. * * 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
  124995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124998. * @param name defines the name of the mesh
  124999. * @param options defines the options used to create the mesh
  125000. * @param scene defines the hosting scene
  125001. * @returns the icosahedron mesh
  125002. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125003. */
  125004. static CreateIcoSphere(name: string, options: {
  125005. radius?: number;
  125006. radiusX?: number;
  125007. radiusY?: number;
  125008. radiusZ?: number;
  125009. flat?: boolean;
  125010. subdivisions?: number;
  125011. sideOrientation?: number;
  125012. frontUVs?: Vector4;
  125013. backUVs?: Vector4;
  125014. updatable?: boolean;
  125015. }, scene?: Nullable<Scene>): Mesh;
  125016. }
  125017. }
  125018. declare module BABYLON {
  125019. /**
  125020. * Class containing static functions to help procedurally build meshes
  125021. */
  125022. export class DecalBuilder {
  125023. /**
  125024. * Creates a decal mesh.
  125025. * 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
  125026. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125027. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125028. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125029. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125030. * @param name defines the name of the mesh
  125031. * @param sourceMesh defines the mesh where the decal must be applied
  125032. * @param options defines the options used to create the mesh
  125033. * @param scene defines the hosting scene
  125034. * @returns the decal mesh
  125035. * @see https://doc.babylonjs.com/how_to/decals
  125036. */
  125037. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125038. position?: Vector3;
  125039. normal?: Vector3;
  125040. size?: Vector3;
  125041. angle?: number;
  125042. }): Mesh;
  125043. }
  125044. }
  125045. declare module BABYLON {
  125046. /**
  125047. * Class containing static functions to help procedurally build meshes
  125048. */
  125049. export class MeshBuilder {
  125050. /**
  125051. * Creates a box mesh
  125052. * * The parameter `size` sets the size (float) of each box side (default 1)
  125053. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125054. * * 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)
  125055. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125059. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125060. * @param name defines the name of the mesh
  125061. * @param options defines the options used to create the mesh
  125062. * @param scene defines the hosting scene
  125063. * @returns the box mesh
  125064. */
  125065. static CreateBox(name: string, options: {
  125066. size?: number;
  125067. width?: number;
  125068. height?: number;
  125069. depth?: number;
  125070. faceUV?: Vector4[];
  125071. faceColors?: Color4[];
  125072. sideOrientation?: number;
  125073. frontUVs?: Vector4;
  125074. backUVs?: Vector4;
  125075. updatable?: boolean;
  125076. }, scene?: Nullable<Scene>): Mesh;
  125077. /**
  125078. * Creates a tiled box mesh
  125079. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125081. * @param name defines the name of the mesh
  125082. * @param options defines the options used to create the mesh
  125083. * @param scene defines the hosting scene
  125084. * @returns the tiled box mesh
  125085. */
  125086. static CreateTiledBox(name: string, options: {
  125087. pattern?: number;
  125088. size?: number;
  125089. width?: number;
  125090. height?: number;
  125091. depth: number;
  125092. tileSize?: number;
  125093. tileWidth?: number;
  125094. tileHeight?: number;
  125095. faceUV?: Vector4[];
  125096. faceColors?: Color4[];
  125097. alignHorizontal?: number;
  125098. alignVertical?: number;
  125099. sideOrientation?: number;
  125100. updatable?: boolean;
  125101. }, scene?: Nullable<Scene>): Mesh;
  125102. /**
  125103. * Creates a sphere mesh
  125104. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125105. * * 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`)
  125106. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125107. * * 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
  125108. * * 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)
  125109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125112. * @param name defines the name of the mesh
  125113. * @param options defines the options used to create the mesh
  125114. * @param scene defines the hosting scene
  125115. * @returns the sphere mesh
  125116. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125117. */
  125118. static CreateSphere(name: string, options: {
  125119. segments?: number;
  125120. diameter?: number;
  125121. diameterX?: number;
  125122. diameterY?: number;
  125123. diameterZ?: number;
  125124. arc?: number;
  125125. slice?: number;
  125126. sideOrientation?: number;
  125127. frontUVs?: Vector4;
  125128. backUVs?: Vector4;
  125129. updatable?: boolean;
  125130. }, scene?: Nullable<Scene>): Mesh;
  125131. /**
  125132. * Creates a plane polygonal mesh. By default, this is a disc
  125133. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125134. * * 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
  125135. * * 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
  125136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125139. * @param name defines the name of the mesh
  125140. * @param options defines the options used to create the mesh
  125141. * @param scene defines the hosting scene
  125142. * @returns the plane polygonal mesh
  125143. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125144. */
  125145. static CreateDisc(name: string, options: {
  125146. radius?: number;
  125147. tessellation?: number;
  125148. arc?: number;
  125149. updatable?: boolean;
  125150. sideOrientation?: number;
  125151. frontUVs?: Vector4;
  125152. backUVs?: Vector4;
  125153. }, scene?: Nullable<Scene>): Mesh;
  125154. /**
  125155. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125156. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125157. * * 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`)
  125158. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125159. * * 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
  125160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125163. * @param name defines the name of the mesh
  125164. * @param options defines the options used to create the mesh
  125165. * @param scene defines the hosting scene
  125166. * @returns the icosahedron mesh
  125167. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125168. */
  125169. static CreateIcoSphere(name: string, options: {
  125170. radius?: number;
  125171. radiusX?: number;
  125172. radiusY?: number;
  125173. radiusZ?: number;
  125174. flat?: boolean;
  125175. subdivisions?: number;
  125176. sideOrientation?: number;
  125177. frontUVs?: Vector4;
  125178. backUVs?: Vector4;
  125179. updatable?: boolean;
  125180. }, scene?: Nullable<Scene>): Mesh;
  125181. /**
  125182. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125183. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125184. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125185. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125186. * * 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
  125187. * * 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
  125188. * * 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
  125189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125192. * * 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
  125193. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125194. * * 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
  125195. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125197. * @param name defines the name of the mesh
  125198. * @param options defines the options used to create the mesh
  125199. * @param scene defines the hosting scene
  125200. * @returns the ribbon mesh
  125201. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125203. */
  125204. static CreateRibbon(name: string, options: {
  125205. pathArray: Vector3[][];
  125206. closeArray?: boolean;
  125207. closePath?: boolean;
  125208. offset?: number;
  125209. updatable?: boolean;
  125210. sideOrientation?: number;
  125211. frontUVs?: Vector4;
  125212. backUVs?: Vector4;
  125213. instance?: Mesh;
  125214. invertUV?: boolean;
  125215. uvs?: Vector2[];
  125216. colors?: Color4[];
  125217. }, scene?: Nullable<Scene>): Mesh;
  125218. /**
  125219. * Creates a cylinder or a cone mesh
  125220. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125221. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125222. * * 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.
  125223. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125224. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125225. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125226. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125227. * * 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).
  125228. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125229. * * 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).
  125230. * * 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
  125231. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125232. * * 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
  125233. * * 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.
  125234. * * If `enclose` is false, a ring surface is one element.
  125235. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125236. * * 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
  125237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125240. * @param name defines the name of the mesh
  125241. * @param options defines the options used to create the mesh
  125242. * @param scene defines the hosting scene
  125243. * @returns the cylinder mesh
  125244. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125245. */
  125246. static CreateCylinder(name: string, options: {
  125247. height?: number;
  125248. diameterTop?: number;
  125249. diameterBottom?: number;
  125250. diameter?: number;
  125251. tessellation?: number;
  125252. subdivisions?: number;
  125253. arc?: number;
  125254. faceColors?: Color4[];
  125255. faceUV?: Vector4[];
  125256. updatable?: boolean;
  125257. hasRings?: boolean;
  125258. enclose?: boolean;
  125259. cap?: number;
  125260. sideOrientation?: number;
  125261. frontUVs?: Vector4;
  125262. backUVs?: Vector4;
  125263. }, scene?: Nullable<Scene>): Mesh;
  125264. /**
  125265. * Creates a torus mesh
  125266. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125267. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125268. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125272. * @param name defines the name of the mesh
  125273. * @param options defines the options used to create the mesh
  125274. * @param scene defines the hosting scene
  125275. * @returns the torus mesh
  125276. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125277. */
  125278. static CreateTorus(name: string, options: {
  125279. diameter?: number;
  125280. thickness?: number;
  125281. tessellation?: number;
  125282. updatable?: boolean;
  125283. sideOrientation?: number;
  125284. frontUVs?: Vector4;
  125285. backUVs?: Vector4;
  125286. }, scene?: Nullable<Scene>): Mesh;
  125287. /**
  125288. * Creates a torus knot mesh
  125289. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125290. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125291. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125292. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125296. * @param name defines the name of the mesh
  125297. * @param options defines the options used to create the mesh
  125298. * @param scene defines the hosting scene
  125299. * @returns the torus knot mesh
  125300. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125301. */
  125302. static CreateTorusKnot(name: string, options: {
  125303. radius?: number;
  125304. tube?: number;
  125305. radialSegments?: number;
  125306. tubularSegments?: number;
  125307. p?: number;
  125308. q?: number;
  125309. updatable?: boolean;
  125310. sideOrientation?: number;
  125311. frontUVs?: Vector4;
  125312. backUVs?: Vector4;
  125313. }, scene?: Nullable<Scene>): Mesh;
  125314. /**
  125315. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125316. * * 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
  125317. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125318. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125319. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125320. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125321. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125322. * * 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
  125323. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125326. * @param name defines the name of the new line system
  125327. * @param options defines the options used to create the line system
  125328. * @param scene defines the hosting scene
  125329. * @returns a new line system mesh
  125330. */
  125331. static CreateLineSystem(name: string, options: {
  125332. lines: Vector3[][];
  125333. updatable?: boolean;
  125334. instance?: Nullable<LinesMesh>;
  125335. colors?: Nullable<Color4[][]>;
  125336. useVertexAlpha?: boolean;
  125337. }, scene: Nullable<Scene>): LinesMesh;
  125338. /**
  125339. * Creates a line mesh
  125340. * 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
  125341. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125342. * * The parameter `points` is an array successive Vector3
  125343. * * 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
  125344. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125345. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125346. * * When updating an instance, remember that only point positions can change, not the number of points
  125347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125349. * @param name defines the name of the new line system
  125350. * @param options defines the options used to create the line system
  125351. * @param scene defines the hosting scene
  125352. * @returns a new line mesh
  125353. */
  125354. static CreateLines(name: string, options: {
  125355. points: Vector3[];
  125356. updatable?: boolean;
  125357. instance?: Nullable<LinesMesh>;
  125358. colors?: Color4[];
  125359. useVertexAlpha?: boolean;
  125360. }, scene?: Nullable<Scene>): LinesMesh;
  125361. /**
  125362. * Creates a dashed line mesh
  125363. * * 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
  125364. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125365. * * The parameter `points` is an array successive Vector3
  125366. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125367. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125368. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125369. * * 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
  125370. * * When updating an instance, remember that only point positions can change, not the number of points
  125371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125372. * @param name defines the name of the mesh
  125373. * @param options defines the options used to create the mesh
  125374. * @param scene defines the hosting scene
  125375. * @returns the dashed line mesh
  125376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125377. */
  125378. static CreateDashedLines(name: string, options: {
  125379. points: Vector3[];
  125380. dashSize?: number;
  125381. gapSize?: number;
  125382. dashNb?: number;
  125383. updatable?: boolean;
  125384. instance?: LinesMesh;
  125385. }, scene?: Nullable<Scene>): LinesMesh;
  125386. /**
  125387. * 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.
  125388. * * 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.
  125389. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125390. * * 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.
  125391. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125392. * * 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
  125393. * * 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
  125394. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125399. * @param name defines the name of the mesh
  125400. * @param options defines the options used to create the mesh
  125401. * @param scene defines the hosting scene
  125402. * @returns the extruded shape mesh
  125403. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125405. */
  125406. static ExtrudeShape(name: string, options: {
  125407. shape: Vector3[];
  125408. path: Vector3[];
  125409. scale?: number;
  125410. rotation?: number;
  125411. cap?: number;
  125412. updatable?: boolean;
  125413. sideOrientation?: number;
  125414. frontUVs?: Vector4;
  125415. backUVs?: Vector4;
  125416. instance?: Mesh;
  125417. invertUV?: boolean;
  125418. }, scene?: Nullable<Scene>): Mesh;
  125419. /**
  125420. * Creates an custom extruded shape mesh.
  125421. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125422. * * 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.
  125423. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125424. * * 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
  125425. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125426. * * 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
  125427. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125428. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125429. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125430. * * 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
  125431. * * 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
  125432. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125437. * @param name defines the name of the mesh
  125438. * @param options defines the options used to create the mesh
  125439. * @param scene defines the hosting scene
  125440. * @returns the custom extruded shape mesh
  125441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125442. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125444. */
  125445. static ExtrudeShapeCustom(name: string, options: {
  125446. shape: Vector3[];
  125447. path: Vector3[];
  125448. scaleFunction?: any;
  125449. rotationFunction?: any;
  125450. ribbonCloseArray?: boolean;
  125451. ribbonClosePath?: boolean;
  125452. cap?: number;
  125453. updatable?: boolean;
  125454. sideOrientation?: number;
  125455. frontUVs?: Vector4;
  125456. backUVs?: Vector4;
  125457. instance?: Mesh;
  125458. invertUV?: boolean;
  125459. }, scene?: Nullable<Scene>): Mesh;
  125460. /**
  125461. * Creates lathe mesh.
  125462. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125463. * * 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
  125464. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125465. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125466. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125467. * * 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
  125468. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125469. * * 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
  125470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125474. * @param name defines the name of the mesh
  125475. * @param options defines the options used to create the mesh
  125476. * @param scene defines the hosting scene
  125477. * @returns the lathe mesh
  125478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125479. */
  125480. static CreateLathe(name: string, options: {
  125481. shape: Vector3[];
  125482. radius?: number;
  125483. tessellation?: number;
  125484. clip?: number;
  125485. arc?: number;
  125486. closed?: boolean;
  125487. updatable?: boolean;
  125488. sideOrientation?: number;
  125489. frontUVs?: Vector4;
  125490. backUVs?: Vector4;
  125491. cap?: number;
  125492. invertUV?: boolean;
  125493. }, scene?: Nullable<Scene>): Mesh;
  125494. /**
  125495. * Creates a tiled plane mesh
  125496. * * You can set a limited pattern arrangement with the tiles
  125497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125500. * @param name defines the name of the mesh
  125501. * @param options defines the options used to create the mesh
  125502. * @param scene defines the hosting scene
  125503. * @returns the plane mesh
  125504. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125505. */
  125506. static CreateTiledPlane(name: string, options: {
  125507. pattern?: number;
  125508. tileSize?: number;
  125509. tileWidth?: number;
  125510. tileHeight?: number;
  125511. size?: number;
  125512. width?: number;
  125513. height?: number;
  125514. alignHorizontal?: number;
  125515. alignVertical?: number;
  125516. sideOrientation?: number;
  125517. frontUVs?: Vector4;
  125518. backUVs?: Vector4;
  125519. updatable?: boolean;
  125520. }, scene?: Nullable<Scene>): Mesh;
  125521. /**
  125522. * Creates a plane mesh
  125523. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125524. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125525. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125529. * @param name defines the name of the mesh
  125530. * @param options defines the options used to create the mesh
  125531. * @param scene defines the hosting scene
  125532. * @returns the plane mesh
  125533. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125534. */
  125535. static CreatePlane(name: string, options: {
  125536. size?: number;
  125537. width?: number;
  125538. height?: number;
  125539. sideOrientation?: number;
  125540. frontUVs?: Vector4;
  125541. backUVs?: Vector4;
  125542. updatable?: boolean;
  125543. sourcePlane?: Plane;
  125544. }, scene?: Nullable<Scene>): Mesh;
  125545. /**
  125546. * Creates a ground mesh
  125547. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125548. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125550. * @param name defines the name of the mesh
  125551. * @param options defines the options used to create the mesh
  125552. * @param scene defines the hosting scene
  125553. * @returns the ground mesh
  125554. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125555. */
  125556. static CreateGround(name: string, options: {
  125557. width?: number;
  125558. height?: number;
  125559. subdivisions?: number;
  125560. subdivisionsX?: number;
  125561. subdivisionsY?: number;
  125562. updatable?: boolean;
  125563. }, scene?: Nullable<Scene>): Mesh;
  125564. /**
  125565. * Creates a tiled ground mesh
  125566. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125567. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125568. * * 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
  125569. * * 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
  125570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125571. * @param name defines the name of the mesh
  125572. * @param options defines the options used to create the mesh
  125573. * @param scene defines the hosting scene
  125574. * @returns the tiled ground mesh
  125575. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125576. */
  125577. static CreateTiledGround(name: string, options: {
  125578. xmin: number;
  125579. zmin: number;
  125580. xmax: number;
  125581. zmax: number;
  125582. subdivisions?: {
  125583. w: number;
  125584. h: number;
  125585. };
  125586. precision?: {
  125587. w: number;
  125588. h: number;
  125589. };
  125590. updatable?: boolean;
  125591. }, scene?: Nullable<Scene>): Mesh;
  125592. /**
  125593. * Creates a ground mesh from a height map
  125594. * * The parameter `url` sets the URL of the height map image resource.
  125595. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125596. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125597. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125598. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125599. * * 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.
  125600. * * 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).
  125601. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125603. * @param name defines the name of the mesh
  125604. * @param url defines the url to the height map
  125605. * @param options defines the options used to create the mesh
  125606. * @param scene defines the hosting scene
  125607. * @returns the ground mesh
  125608. * @see https://doc.babylonjs.com/babylon101/height_map
  125609. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125610. */
  125611. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125612. width?: number;
  125613. height?: number;
  125614. subdivisions?: number;
  125615. minHeight?: number;
  125616. maxHeight?: number;
  125617. colorFilter?: Color3;
  125618. alphaFilter?: number;
  125619. updatable?: boolean;
  125620. onReady?: (mesh: GroundMesh) => void;
  125621. }, scene?: Nullable<Scene>): GroundMesh;
  125622. /**
  125623. * Creates a polygon mesh
  125624. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125625. * * 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
  125626. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125629. * * Remember you can only change the shape positions, not their number when updating a polygon
  125630. * @param name defines the name of the mesh
  125631. * @param options defines the options used to create the mesh
  125632. * @param scene defines the hosting scene
  125633. * @param earcutInjection can be used to inject your own earcut reference
  125634. * @returns the polygon mesh
  125635. */
  125636. static CreatePolygon(name: string, options: {
  125637. shape: Vector3[];
  125638. holes?: Vector3[][];
  125639. depth?: number;
  125640. faceUV?: Vector4[];
  125641. faceColors?: Color4[];
  125642. updatable?: boolean;
  125643. sideOrientation?: number;
  125644. frontUVs?: Vector4;
  125645. backUVs?: Vector4;
  125646. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125647. /**
  125648. * Creates an extruded polygon mesh, with depth in the Y direction.
  125649. * * 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)
  125650. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125651. * @param name defines the name of the mesh
  125652. * @param options defines the options used to create the mesh
  125653. * @param scene defines the hosting scene
  125654. * @param earcutInjection can be used to inject your own earcut reference
  125655. * @returns the polygon mesh
  125656. */
  125657. static ExtrudePolygon(name: string, options: {
  125658. shape: Vector3[];
  125659. holes?: Vector3[][];
  125660. depth?: number;
  125661. faceUV?: Vector4[];
  125662. faceColors?: Color4[];
  125663. updatable?: boolean;
  125664. sideOrientation?: number;
  125665. frontUVs?: Vector4;
  125666. backUVs?: Vector4;
  125667. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125668. /**
  125669. * Creates a tube mesh.
  125670. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125671. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125672. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125673. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125674. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125675. * * 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)
  125676. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125677. * * 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
  125678. * * 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
  125679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125683. * @param name defines the name of the mesh
  125684. * @param options defines the options used to create the mesh
  125685. * @param scene defines the hosting scene
  125686. * @returns the tube mesh
  125687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125688. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125689. */
  125690. static CreateTube(name: string, options: {
  125691. path: Vector3[];
  125692. radius?: number;
  125693. tessellation?: number;
  125694. radiusFunction?: {
  125695. (i: number, distance: number): number;
  125696. };
  125697. cap?: number;
  125698. arc?: number;
  125699. updatable?: boolean;
  125700. sideOrientation?: number;
  125701. frontUVs?: Vector4;
  125702. backUVs?: Vector4;
  125703. instance?: Mesh;
  125704. invertUV?: boolean;
  125705. }, scene?: Nullable<Scene>): Mesh;
  125706. /**
  125707. * Creates a polyhedron mesh
  125708. * * 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
  125709. * * The parameter `size` (positive float, default 1) sets the polygon size
  125710. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125711. * * 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`
  125712. * * 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
  125713. * * 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)`)
  125714. * * 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
  125715. * * 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
  125716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125719. * @param name defines the name of the mesh
  125720. * @param options defines the options used to create the mesh
  125721. * @param scene defines the hosting scene
  125722. * @returns the polyhedron mesh
  125723. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125724. */
  125725. static CreatePolyhedron(name: string, options: {
  125726. type?: number;
  125727. size?: number;
  125728. sizeX?: number;
  125729. sizeY?: number;
  125730. sizeZ?: number;
  125731. custom?: any;
  125732. faceUV?: Vector4[];
  125733. faceColors?: Color4[];
  125734. flat?: boolean;
  125735. updatable?: boolean;
  125736. sideOrientation?: number;
  125737. frontUVs?: Vector4;
  125738. backUVs?: Vector4;
  125739. }, scene?: Nullable<Scene>): Mesh;
  125740. /**
  125741. * Creates a decal mesh.
  125742. * 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
  125743. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125744. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125745. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125746. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125747. * @param name defines the name of the mesh
  125748. * @param sourceMesh defines the mesh where the decal must be applied
  125749. * @param options defines the options used to create the mesh
  125750. * @param scene defines the hosting scene
  125751. * @returns the decal mesh
  125752. * @see https://doc.babylonjs.com/how_to/decals
  125753. */
  125754. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125755. position?: Vector3;
  125756. normal?: Vector3;
  125757. size?: Vector3;
  125758. angle?: number;
  125759. }): Mesh;
  125760. }
  125761. }
  125762. declare module BABYLON {
  125763. /**
  125764. * A simplifier interface for future simplification implementations
  125765. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125766. */
  125767. export interface ISimplifier {
  125768. /**
  125769. * Simplification of a given mesh according to the given settings.
  125770. * Since this requires computation, it is assumed that the function runs async.
  125771. * @param settings The settings of the simplification, including quality and distance
  125772. * @param successCallback A callback that will be called after the mesh was simplified.
  125773. * @param errorCallback in case of an error, this callback will be called. optional.
  125774. */
  125775. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125776. }
  125777. /**
  125778. * Expected simplification settings.
  125779. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125780. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125781. */
  125782. export interface ISimplificationSettings {
  125783. /**
  125784. * Gets or sets the expected quality
  125785. */
  125786. quality: number;
  125787. /**
  125788. * Gets or sets the distance when this optimized version should be used
  125789. */
  125790. distance: number;
  125791. /**
  125792. * Gets an already optimized mesh
  125793. */
  125794. optimizeMesh?: boolean;
  125795. }
  125796. /**
  125797. * Class used to specify simplification options
  125798. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125799. */
  125800. export class SimplificationSettings implements ISimplificationSettings {
  125801. /** expected quality */
  125802. quality: number;
  125803. /** distance when this optimized version should be used */
  125804. distance: number;
  125805. /** already optimized mesh */
  125806. optimizeMesh?: boolean | undefined;
  125807. /**
  125808. * Creates a SimplificationSettings
  125809. * @param quality expected quality
  125810. * @param distance distance when this optimized version should be used
  125811. * @param optimizeMesh already optimized mesh
  125812. */
  125813. constructor(
  125814. /** expected quality */
  125815. quality: number,
  125816. /** distance when this optimized version should be used */
  125817. distance: number,
  125818. /** already optimized mesh */
  125819. optimizeMesh?: boolean | undefined);
  125820. }
  125821. /**
  125822. * Interface used to define a simplification task
  125823. */
  125824. export interface ISimplificationTask {
  125825. /**
  125826. * Array of settings
  125827. */
  125828. settings: Array<ISimplificationSettings>;
  125829. /**
  125830. * Simplification type
  125831. */
  125832. simplificationType: SimplificationType;
  125833. /**
  125834. * Mesh to simplify
  125835. */
  125836. mesh: Mesh;
  125837. /**
  125838. * Callback called on success
  125839. */
  125840. successCallback?: () => void;
  125841. /**
  125842. * Defines if parallel processing can be used
  125843. */
  125844. parallelProcessing: boolean;
  125845. }
  125846. /**
  125847. * Queue used to order the simplification tasks
  125848. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125849. */
  125850. export class SimplificationQueue {
  125851. private _simplificationArray;
  125852. /**
  125853. * Gets a boolean indicating that the process is still running
  125854. */
  125855. running: boolean;
  125856. /**
  125857. * Creates a new queue
  125858. */
  125859. constructor();
  125860. /**
  125861. * Adds a new simplification task
  125862. * @param task defines a task to add
  125863. */
  125864. addTask(task: ISimplificationTask): void;
  125865. /**
  125866. * Execute next task
  125867. */
  125868. executeNext(): void;
  125869. /**
  125870. * Execute a simplification task
  125871. * @param task defines the task to run
  125872. */
  125873. runSimplification(task: ISimplificationTask): void;
  125874. private getSimplifier;
  125875. }
  125876. /**
  125877. * The implemented types of simplification
  125878. * At the moment only Quadratic Error Decimation is implemented
  125879. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125880. */
  125881. export enum SimplificationType {
  125882. /** Quadratic error decimation */
  125883. QUADRATIC = 0
  125884. }
  125885. }
  125886. declare module BABYLON {
  125887. interface Scene {
  125888. /** @hidden (Backing field) */
  125889. _simplificationQueue: SimplificationQueue;
  125890. /**
  125891. * Gets or sets the simplification queue attached to the scene
  125892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125893. */
  125894. simplificationQueue: SimplificationQueue;
  125895. }
  125896. interface Mesh {
  125897. /**
  125898. * Simplify the mesh according to the given array of settings.
  125899. * Function will return immediately and will simplify async
  125900. * @param settings a collection of simplification settings
  125901. * @param parallelProcessing should all levels calculate parallel or one after the other
  125902. * @param simplificationType the type of simplification to run
  125903. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125904. * @returns the current mesh
  125905. */
  125906. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125907. }
  125908. /**
  125909. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125910. * created in a scene
  125911. */
  125912. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125913. /**
  125914. * The component name helpfull to identify the component in the list of scene components.
  125915. */
  125916. readonly name: string;
  125917. /**
  125918. * The scene the component belongs to.
  125919. */
  125920. scene: Scene;
  125921. /**
  125922. * Creates a new instance of the component for the given scene
  125923. * @param scene Defines the scene to register the component in
  125924. */
  125925. constructor(scene: Scene);
  125926. /**
  125927. * Registers the component in a given scene
  125928. */
  125929. register(): void;
  125930. /**
  125931. * Rebuilds the elements related to this component in case of
  125932. * context lost for instance.
  125933. */
  125934. rebuild(): void;
  125935. /**
  125936. * Disposes the component and the associated ressources
  125937. */
  125938. dispose(): void;
  125939. private _beforeCameraUpdate;
  125940. }
  125941. }
  125942. declare module BABYLON {
  125943. /**
  125944. * Navigation plugin interface to add navigation constrained by a navigation mesh
  125945. */
  125946. export interface INavigationEnginePlugin {
  125947. /**
  125948. * plugin name
  125949. */
  125950. name: string;
  125951. /**
  125952. * Creates a navigation mesh
  125953. * @param meshes array of all the geometry used to compute the navigatio mesh
  125954. * @param parameters bunch of parameters used to filter geometry
  125955. */
  125956. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125957. /**
  125958. * Create a navigation mesh debug mesh
  125959. * @param scene is where the mesh will be added
  125960. * @returns debug display mesh
  125961. */
  125962. createDebugNavMesh(scene: Scene): Mesh;
  125963. /**
  125964. * Get a navigation mesh constrained position, closest to the parameter position
  125965. * @param position world position
  125966. * @returns the closest point to position constrained by the navigation mesh
  125967. */
  125968. getClosestPoint(position: Vector3): Vector3;
  125969. /**
  125970. * Get a navigation mesh constrained position, within a particular radius
  125971. * @param position world position
  125972. * @param maxRadius the maximum distance to the constrained world position
  125973. * @returns the closest point to position constrained by the navigation mesh
  125974. */
  125975. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125976. /**
  125977. * Compute the final position from a segment made of destination-position
  125978. * @param position world position
  125979. * @param destination world position
  125980. * @returns the resulting point along the navmesh
  125981. */
  125982. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125983. /**
  125984. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125985. * @param start world position
  125986. * @param end world position
  125987. * @returns array containing world position composing the path
  125988. */
  125989. computePath(start: Vector3, end: Vector3): Vector3[];
  125990. /**
  125991. * If this plugin is supported
  125992. * @returns true if plugin is supported
  125993. */
  125994. isSupported(): boolean;
  125995. /**
  125996. * Create a new Crowd so you can add agents
  125997. * @param maxAgents the maximum agent count in the crowd
  125998. * @param maxAgentRadius the maximum radius an agent can have
  125999. * @param scene to attach the crowd to
  126000. * @returns the crowd you can add agents to
  126001. */
  126002. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126003. /**
  126004. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126005. * The queries will try to find a solution within those bounds
  126006. * default is (1,1,1)
  126007. * @param extent x,y,z value that define the extent around the queries point of reference
  126008. */
  126009. setDefaultQueryExtent(extent: Vector3): void;
  126010. /**
  126011. * Get the Bounding box extent specified by setDefaultQueryExtent
  126012. * @returns the box extent values
  126013. */
  126014. getDefaultQueryExtent(): Vector3;
  126015. /**
  126016. * Release all resources
  126017. */
  126018. dispose(): void;
  126019. }
  126020. /**
  126021. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126022. */
  126023. export interface ICrowd {
  126024. /**
  126025. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126026. * You can attach anything to that node. The node position is updated in the scene update tick.
  126027. * @param pos world position that will be constrained by the navigation mesh
  126028. * @param parameters agent parameters
  126029. * @param transform hooked to the agent that will be update by the scene
  126030. * @returns agent index
  126031. */
  126032. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126033. /**
  126034. * Returns the agent position in world space
  126035. * @param index agent index returned by addAgent
  126036. * @returns world space position
  126037. */
  126038. getAgentPosition(index: number): Vector3;
  126039. /**
  126040. * Gets the agent velocity in world space
  126041. * @param index agent index returned by addAgent
  126042. * @returns world space velocity
  126043. */
  126044. getAgentVelocity(index: number): Vector3;
  126045. /**
  126046. * remove a particular agent previously created
  126047. * @param index agent index returned by addAgent
  126048. */
  126049. removeAgent(index: number): void;
  126050. /**
  126051. * get the list of all agents attached to this crowd
  126052. * @returns list of agent indices
  126053. */
  126054. getAgents(): number[];
  126055. /**
  126056. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126057. * @param deltaTime in seconds
  126058. */
  126059. update(deltaTime: number): void;
  126060. /**
  126061. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126062. * @param index agent index returned by addAgent
  126063. * @param destination targeted world position
  126064. */
  126065. agentGoto(index: number, destination: Vector3): void;
  126066. /**
  126067. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126068. * The queries will try to find a solution within those bounds
  126069. * default is (1,1,1)
  126070. * @param extent x,y,z value that define the extent around the queries point of reference
  126071. */
  126072. setDefaultQueryExtent(extent: Vector3): void;
  126073. /**
  126074. * Get the Bounding box extent specified by setDefaultQueryExtent
  126075. * @returns the box extent values
  126076. */
  126077. getDefaultQueryExtent(): Vector3;
  126078. /**
  126079. * Release all resources
  126080. */
  126081. dispose(): void;
  126082. }
  126083. /**
  126084. * Configures an agent
  126085. */
  126086. export interface IAgentParameters {
  126087. /**
  126088. * Agent radius. [Limit: >= 0]
  126089. */
  126090. radius: number;
  126091. /**
  126092. * Agent height. [Limit: > 0]
  126093. */
  126094. height: number;
  126095. /**
  126096. * Maximum allowed acceleration. [Limit: >= 0]
  126097. */
  126098. maxAcceleration: number;
  126099. /**
  126100. * Maximum allowed speed. [Limit: >= 0]
  126101. */
  126102. maxSpeed: number;
  126103. /**
  126104. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126105. */
  126106. collisionQueryRange: number;
  126107. /**
  126108. * The path visibility optimization range. [Limit: > 0]
  126109. */
  126110. pathOptimizationRange: number;
  126111. /**
  126112. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126113. */
  126114. separationWeight: number;
  126115. }
  126116. /**
  126117. * Configures the navigation mesh creation
  126118. */
  126119. export interface INavMeshParameters {
  126120. /**
  126121. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126122. */
  126123. cs: number;
  126124. /**
  126125. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126126. */
  126127. ch: number;
  126128. /**
  126129. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126130. */
  126131. walkableSlopeAngle: number;
  126132. /**
  126133. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126134. * be considered walkable. [Limit: >= 3] [Units: vx]
  126135. */
  126136. walkableHeight: number;
  126137. /**
  126138. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126139. */
  126140. walkableClimb: number;
  126141. /**
  126142. * The distance to erode/shrink the walkable area of the heightfield away from
  126143. * obstructions. [Limit: >=0] [Units: vx]
  126144. */
  126145. walkableRadius: number;
  126146. /**
  126147. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126148. */
  126149. maxEdgeLen: number;
  126150. /**
  126151. * The maximum distance a simplfied contour's border edges should deviate
  126152. * the original raw contour. [Limit: >=0] [Units: vx]
  126153. */
  126154. maxSimplificationError: number;
  126155. /**
  126156. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126157. */
  126158. minRegionArea: number;
  126159. /**
  126160. * Any regions with a span count smaller than this value will, if possible,
  126161. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126162. */
  126163. mergeRegionArea: number;
  126164. /**
  126165. * The maximum number of vertices allowed for polygons generated during the
  126166. * contour to polygon conversion process. [Limit: >= 3]
  126167. */
  126168. maxVertsPerPoly: number;
  126169. /**
  126170. * Sets the sampling distance to use when generating the detail mesh.
  126171. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126172. */
  126173. detailSampleDist: number;
  126174. /**
  126175. * The maximum distance the detail mesh surface should deviate from heightfield
  126176. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126177. */
  126178. detailSampleMaxError: number;
  126179. }
  126180. }
  126181. declare module BABYLON {
  126182. /**
  126183. * RecastJS navigation plugin
  126184. */
  126185. export class RecastJSPlugin implements INavigationEnginePlugin {
  126186. /**
  126187. * Reference to the Recast library
  126188. */
  126189. bjsRECAST: any;
  126190. /**
  126191. * plugin name
  126192. */
  126193. name: string;
  126194. /**
  126195. * the first navmesh created. We might extend this to support multiple navmeshes
  126196. */
  126197. navMesh: any;
  126198. /**
  126199. * Initializes the recastJS plugin
  126200. * @param recastInjection can be used to inject your own recast reference
  126201. */
  126202. constructor(recastInjection?: any);
  126203. /**
  126204. * Creates a navigation mesh
  126205. * @param meshes array of all the geometry used to compute the navigatio mesh
  126206. * @param parameters bunch of parameters used to filter geometry
  126207. */
  126208. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126209. /**
  126210. * Create a navigation mesh debug mesh
  126211. * @param scene is where the mesh will be added
  126212. * @returns debug display mesh
  126213. */
  126214. createDebugNavMesh(scene: Scene): Mesh;
  126215. /**
  126216. * Get a navigation mesh constrained position, closest to the parameter position
  126217. * @param position world position
  126218. * @returns the closest point to position constrained by the navigation mesh
  126219. */
  126220. getClosestPoint(position: Vector3): Vector3;
  126221. /**
  126222. * Get a navigation mesh constrained position, within a particular radius
  126223. * @param position world position
  126224. * @param maxRadius the maximum distance to the constrained world position
  126225. * @returns the closest point to position constrained by the navigation mesh
  126226. */
  126227. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126228. /**
  126229. * Compute the final position from a segment made of destination-position
  126230. * @param position world position
  126231. * @param destination world position
  126232. * @returns the resulting point along the navmesh
  126233. */
  126234. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126235. /**
  126236. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126237. * @param start world position
  126238. * @param end world position
  126239. * @returns array containing world position composing the path
  126240. */
  126241. computePath(start: Vector3, end: Vector3): Vector3[];
  126242. /**
  126243. * Create a new Crowd so you can add agents
  126244. * @param maxAgents the maximum agent count in the crowd
  126245. * @param maxAgentRadius the maximum radius an agent can have
  126246. * @param scene to attach the crowd to
  126247. * @returns the crowd you can add agents to
  126248. */
  126249. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126250. /**
  126251. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126252. * The queries will try to find a solution within those bounds
  126253. * default is (1,1,1)
  126254. * @param extent x,y,z value that define the extent around the queries point of reference
  126255. */
  126256. setDefaultQueryExtent(extent: Vector3): void;
  126257. /**
  126258. * Get the Bounding box extent specified by setDefaultQueryExtent
  126259. * @returns the box extent values
  126260. */
  126261. getDefaultQueryExtent(): Vector3;
  126262. /**
  126263. * Disposes
  126264. */
  126265. dispose(): void;
  126266. /**
  126267. * If this plugin is supported
  126268. * @returns true if plugin is supported
  126269. */
  126270. isSupported(): boolean;
  126271. }
  126272. /**
  126273. * Recast detour crowd implementation
  126274. */
  126275. export class RecastJSCrowd implements ICrowd {
  126276. /**
  126277. * Recast/detour plugin
  126278. */
  126279. bjsRECASTPlugin: RecastJSPlugin;
  126280. /**
  126281. * Link to the detour crowd
  126282. */
  126283. recastCrowd: any;
  126284. /**
  126285. * One transform per agent
  126286. */
  126287. transforms: TransformNode[];
  126288. /**
  126289. * All agents created
  126290. */
  126291. agents: number[];
  126292. /**
  126293. * Link to the scene is kept to unregister the crowd from the scene
  126294. */
  126295. private _scene;
  126296. /**
  126297. * Observer for crowd updates
  126298. */
  126299. private _onBeforeAnimationsObserver;
  126300. /**
  126301. * Constructor
  126302. * @param plugin recastJS plugin
  126303. * @param maxAgents the maximum agent count in the crowd
  126304. * @param maxAgentRadius the maximum radius an agent can have
  126305. * @param scene to attach the crowd to
  126306. * @returns the crowd you can add agents to
  126307. */
  126308. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126309. /**
  126310. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126311. * You can attach anything to that node. The node position is updated in the scene update tick.
  126312. * @param pos world position that will be constrained by the navigation mesh
  126313. * @param parameters agent parameters
  126314. * @param transform hooked to the agent that will be update by the scene
  126315. * @returns agent index
  126316. */
  126317. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126318. /**
  126319. * Returns the agent position in world space
  126320. * @param index agent index returned by addAgent
  126321. * @returns world space position
  126322. */
  126323. getAgentPosition(index: number): Vector3;
  126324. /**
  126325. * Returns the agent velocity in world space
  126326. * @param index agent index returned by addAgent
  126327. * @returns world space velocity
  126328. */
  126329. getAgentVelocity(index: number): Vector3;
  126330. /**
  126331. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126332. * @param index agent index returned by addAgent
  126333. * @param destination targeted world position
  126334. */
  126335. agentGoto(index: number, destination: Vector3): void;
  126336. /**
  126337. * remove a particular agent previously created
  126338. * @param index agent index returned by addAgent
  126339. */
  126340. removeAgent(index: number): void;
  126341. /**
  126342. * get the list of all agents attached to this crowd
  126343. * @returns list of agent indices
  126344. */
  126345. getAgents(): number[];
  126346. /**
  126347. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126348. * @param deltaTime in seconds
  126349. */
  126350. update(deltaTime: number): void;
  126351. /**
  126352. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126353. * The queries will try to find a solution within those bounds
  126354. * default is (1,1,1)
  126355. * @param extent x,y,z value that define the extent around the queries point of reference
  126356. */
  126357. setDefaultQueryExtent(extent: Vector3): void;
  126358. /**
  126359. * Get the Bounding box extent specified by setDefaultQueryExtent
  126360. * @returns the box extent values
  126361. */
  126362. getDefaultQueryExtent(): Vector3;
  126363. /**
  126364. * Release all resources
  126365. */
  126366. dispose(): void;
  126367. }
  126368. }
  126369. declare module BABYLON {
  126370. /**
  126371. * Class used to enable access to IndexedDB
  126372. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126373. */
  126374. export class Database implements IOfflineProvider {
  126375. private _callbackManifestChecked;
  126376. private _currentSceneUrl;
  126377. private _db;
  126378. private _enableSceneOffline;
  126379. private _enableTexturesOffline;
  126380. private _manifestVersionFound;
  126381. private _mustUpdateRessources;
  126382. private _hasReachedQuota;
  126383. private _isSupported;
  126384. private _idbFactory;
  126385. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126386. private static IsUASupportingBlobStorage;
  126387. /**
  126388. * Gets a boolean indicating if Database storate is enabled (off by default)
  126389. */
  126390. static IDBStorageEnabled: boolean;
  126391. /**
  126392. * Gets a boolean indicating if scene must be saved in the database
  126393. */
  126394. readonly enableSceneOffline: boolean;
  126395. /**
  126396. * Gets a boolean indicating if textures must be saved in the database
  126397. */
  126398. readonly enableTexturesOffline: boolean;
  126399. /**
  126400. * Creates a new Database
  126401. * @param urlToScene defines the url to load the scene
  126402. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126403. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126404. */
  126405. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126406. private static _ParseURL;
  126407. private static _ReturnFullUrlLocation;
  126408. private _checkManifestFile;
  126409. /**
  126410. * Open the database and make it available
  126411. * @param successCallback defines the callback to call on success
  126412. * @param errorCallback defines the callback to call on error
  126413. */
  126414. open(successCallback: () => void, errorCallback: () => void): void;
  126415. /**
  126416. * Loads an image from the database
  126417. * @param url defines the url to load from
  126418. * @param image defines the target DOM image
  126419. */
  126420. loadImage(url: string, image: HTMLImageElement): void;
  126421. private _loadImageFromDBAsync;
  126422. private _saveImageIntoDBAsync;
  126423. private _checkVersionFromDB;
  126424. private _loadVersionFromDBAsync;
  126425. private _saveVersionIntoDBAsync;
  126426. /**
  126427. * Loads a file from database
  126428. * @param url defines the URL to load from
  126429. * @param sceneLoaded defines a callback to call on success
  126430. * @param progressCallBack defines a callback to call when progress changed
  126431. * @param errorCallback defines a callback to call on error
  126432. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126433. */
  126434. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126435. private _loadFileAsync;
  126436. private _saveFileAsync;
  126437. /**
  126438. * Validates if xhr data is correct
  126439. * @param xhr defines the request to validate
  126440. * @param dataType defines the expected data type
  126441. * @returns true if data is correct
  126442. */
  126443. private static _ValidateXHRData;
  126444. }
  126445. }
  126446. declare module BABYLON {
  126447. /** @hidden */
  126448. export var gpuUpdateParticlesPixelShader: {
  126449. name: string;
  126450. shader: string;
  126451. };
  126452. }
  126453. declare module BABYLON {
  126454. /** @hidden */
  126455. export var gpuUpdateParticlesVertexShader: {
  126456. name: string;
  126457. shader: string;
  126458. };
  126459. }
  126460. declare module BABYLON {
  126461. /** @hidden */
  126462. export var clipPlaneFragmentDeclaration2: {
  126463. name: string;
  126464. shader: string;
  126465. };
  126466. }
  126467. declare module BABYLON {
  126468. /** @hidden */
  126469. export var gpuRenderParticlesPixelShader: {
  126470. name: string;
  126471. shader: string;
  126472. };
  126473. }
  126474. declare module BABYLON {
  126475. /** @hidden */
  126476. export var clipPlaneVertexDeclaration2: {
  126477. name: string;
  126478. shader: string;
  126479. };
  126480. }
  126481. declare module BABYLON {
  126482. /** @hidden */
  126483. export var gpuRenderParticlesVertexShader: {
  126484. name: string;
  126485. shader: string;
  126486. };
  126487. }
  126488. declare module BABYLON {
  126489. /**
  126490. * This represents a GPU particle system in Babylon
  126491. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126492. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126493. */
  126494. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126495. /**
  126496. * The layer mask we are rendering the particles through.
  126497. */
  126498. layerMask: number;
  126499. private _capacity;
  126500. private _activeCount;
  126501. private _currentActiveCount;
  126502. private _accumulatedCount;
  126503. private _renderEffect;
  126504. private _updateEffect;
  126505. private _buffer0;
  126506. private _buffer1;
  126507. private _spriteBuffer;
  126508. private _updateVAO;
  126509. private _renderVAO;
  126510. private _targetIndex;
  126511. private _sourceBuffer;
  126512. private _targetBuffer;
  126513. private _engine;
  126514. private _currentRenderId;
  126515. private _started;
  126516. private _stopped;
  126517. private _timeDelta;
  126518. private _randomTexture;
  126519. private _randomTexture2;
  126520. private _attributesStrideSize;
  126521. private _updateEffectOptions;
  126522. private _randomTextureSize;
  126523. private _actualFrame;
  126524. private readonly _rawTextureWidth;
  126525. /**
  126526. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126527. */
  126528. static readonly IsSupported: boolean;
  126529. /**
  126530. * An event triggered when the system is disposed.
  126531. */
  126532. onDisposeObservable: Observable<GPUParticleSystem>;
  126533. /**
  126534. * Gets the maximum number of particles active at the same time.
  126535. * @returns The max number of active particles.
  126536. */
  126537. getCapacity(): number;
  126538. /**
  126539. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126540. * to override the particles.
  126541. */
  126542. forceDepthWrite: boolean;
  126543. /**
  126544. * Gets or set the number of active particles
  126545. */
  126546. activeParticleCount: number;
  126547. private _preWarmDone;
  126548. /**
  126549. * Is this system ready to be used/rendered
  126550. * @return true if the system is ready
  126551. */
  126552. isReady(): boolean;
  126553. /**
  126554. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126555. * @returns True if it has been started, otherwise false.
  126556. */
  126557. isStarted(): boolean;
  126558. /**
  126559. * Starts the particle system and begins to emit
  126560. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126561. */
  126562. start(delay?: number): void;
  126563. /**
  126564. * Stops the particle system.
  126565. */
  126566. stop(): void;
  126567. /**
  126568. * Remove all active particles
  126569. */
  126570. reset(): void;
  126571. /**
  126572. * Returns the string "GPUParticleSystem"
  126573. * @returns a string containing the class name
  126574. */
  126575. getClassName(): string;
  126576. private _colorGradientsTexture;
  126577. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126578. /**
  126579. * Adds a new color gradient
  126580. * @param gradient defines the gradient to use (between 0 and 1)
  126581. * @param color1 defines the color to affect to the specified gradient
  126582. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126583. * @returns the current particle system
  126584. */
  126585. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126586. /**
  126587. * Remove a specific color gradient
  126588. * @param gradient defines the gradient to remove
  126589. * @returns the current particle system
  126590. */
  126591. removeColorGradient(gradient: number): GPUParticleSystem;
  126592. private _angularSpeedGradientsTexture;
  126593. private _sizeGradientsTexture;
  126594. private _velocityGradientsTexture;
  126595. private _limitVelocityGradientsTexture;
  126596. private _dragGradientsTexture;
  126597. private _addFactorGradient;
  126598. /**
  126599. * Adds a new size gradient
  126600. * @param gradient defines the gradient to use (between 0 and 1)
  126601. * @param factor defines the size factor to affect to the specified gradient
  126602. * @returns the current particle system
  126603. */
  126604. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126605. /**
  126606. * Remove a specific size gradient
  126607. * @param gradient defines the gradient to remove
  126608. * @returns the current particle system
  126609. */
  126610. removeSizeGradient(gradient: number): GPUParticleSystem;
  126611. /**
  126612. * Adds a new angular speed gradient
  126613. * @param gradient defines the gradient to use (between 0 and 1)
  126614. * @param factor defines the angular speed to affect to the specified gradient
  126615. * @returns the current particle system
  126616. */
  126617. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126618. /**
  126619. * Remove a specific angular speed gradient
  126620. * @param gradient defines the gradient to remove
  126621. * @returns the current particle system
  126622. */
  126623. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126624. /**
  126625. * Adds a new velocity gradient
  126626. * @param gradient defines the gradient to use (between 0 and 1)
  126627. * @param factor defines the velocity to affect to the specified gradient
  126628. * @returns the current particle system
  126629. */
  126630. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126631. /**
  126632. * Remove a specific velocity gradient
  126633. * @param gradient defines the gradient to remove
  126634. * @returns the current particle system
  126635. */
  126636. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126637. /**
  126638. * Adds a new limit velocity gradient
  126639. * @param gradient defines the gradient to use (between 0 and 1)
  126640. * @param factor defines the limit velocity value to affect to the specified gradient
  126641. * @returns the current particle system
  126642. */
  126643. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126644. /**
  126645. * Remove a specific limit velocity gradient
  126646. * @param gradient defines the gradient to remove
  126647. * @returns the current particle system
  126648. */
  126649. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126650. /**
  126651. * Adds a new drag gradient
  126652. * @param gradient defines the gradient to use (between 0 and 1)
  126653. * @param factor defines the drag value to affect to the specified gradient
  126654. * @returns the current particle system
  126655. */
  126656. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126657. /**
  126658. * Remove a specific drag gradient
  126659. * @param gradient defines the gradient to remove
  126660. * @returns the current particle system
  126661. */
  126662. removeDragGradient(gradient: number): GPUParticleSystem;
  126663. /**
  126664. * Not supported by GPUParticleSystem
  126665. * @param gradient defines the gradient to use (between 0 and 1)
  126666. * @param factor defines the emit rate value to affect to the specified gradient
  126667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126668. * @returns the current particle system
  126669. */
  126670. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126671. /**
  126672. * Not supported by GPUParticleSystem
  126673. * @param gradient defines the gradient to remove
  126674. * @returns the current particle system
  126675. */
  126676. removeEmitRateGradient(gradient: number): IParticleSystem;
  126677. /**
  126678. * Not supported by GPUParticleSystem
  126679. * @param gradient defines the gradient to use (between 0 and 1)
  126680. * @param factor defines the start size value to affect to the specified gradient
  126681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126682. * @returns the current particle system
  126683. */
  126684. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126685. /**
  126686. * Not supported by GPUParticleSystem
  126687. * @param gradient defines the gradient to remove
  126688. * @returns the current particle system
  126689. */
  126690. removeStartSizeGradient(gradient: number): IParticleSystem;
  126691. /**
  126692. * Not supported by GPUParticleSystem
  126693. * @param gradient defines the gradient to use (between 0 and 1)
  126694. * @param min defines the color remap minimal range
  126695. * @param max defines the color remap maximal range
  126696. * @returns the current particle system
  126697. */
  126698. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126699. /**
  126700. * Not supported by GPUParticleSystem
  126701. * @param gradient defines the gradient to remove
  126702. * @returns the current particle system
  126703. */
  126704. removeColorRemapGradient(): IParticleSystem;
  126705. /**
  126706. * Not supported by GPUParticleSystem
  126707. * @param gradient defines the gradient to use (between 0 and 1)
  126708. * @param min defines the alpha remap minimal range
  126709. * @param max defines the alpha remap maximal range
  126710. * @returns the current particle system
  126711. */
  126712. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126713. /**
  126714. * Not supported by GPUParticleSystem
  126715. * @param gradient defines the gradient to remove
  126716. * @returns the current particle system
  126717. */
  126718. removeAlphaRemapGradient(): IParticleSystem;
  126719. /**
  126720. * Not supported by GPUParticleSystem
  126721. * @param gradient defines the gradient to use (between 0 and 1)
  126722. * @param color defines the color to affect to the specified gradient
  126723. * @returns the current particle system
  126724. */
  126725. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126726. /**
  126727. * Not supported by GPUParticleSystem
  126728. * @param gradient defines the gradient to remove
  126729. * @returns the current particle system
  126730. */
  126731. removeRampGradient(): IParticleSystem;
  126732. /**
  126733. * Not supported by GPUParticleSystem
  126734. * @returns the list of ramp gradients
  126735. */
  126736. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126737. /**
  126738. * Not supported by GPUParticleSystem
  126739. * Gets or sets a boolean indicating that ramp gradients must be used
  126740. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126741. */
  126742. useRampGradients: boolean;
  126743. /**
  126744. * Not supported by GPUParticleSystem
  126745. * @param gradient defines the gradient to use (between 0 and 1)
  126746. * @param factor defines the life time factor to affect to the specified gradient
  126747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126748. * @returns the current particle system
  126749. */
  126750. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126751. /**
  126752. * Not supported by GPUParticleSystem
  126753. * @param gradient defines the gradient to remove
  126754. * @returns the current particle system
  126755. */
  126756. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126757. /**
  126758. * Instantiates a GPU particle system.
  126759. * 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.
  126760. * @param name The name of the particle system
  126761. * @param options The options used to create the system
  126762. * @param scene The scene the particle system belongs to
  126763. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126764. */
  126765. constructor(name: string, options: Partial<{
  126766. capacity: number;
  126767. randomTextureSize: number;
  126768. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126769. protected _reset(): void;
  126770. private _createUpdateVAO;
  126771. private _createRenderVAO;
  126772. private _initialize;
  126773. /** @hidden */
  126774. _recreateUpdateEffect(): void;
  126775. /** @hidden */
  126776. _recreateRenderEffect(): void;
  126777. /**
  126778. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126779. * @param preWarm defines if we are in the pre-warmimg phase
  126780. */
  126781. animate(preWarm?: boolean): void;
  126782. private _createFactorGradientTexture;
  126783. private _createSizeGradientTexture;
  126784. private _createAngularSpeedGradientTexture;
  126785. private _createVelocityGradientTexture;
  126786. private _createLimitVelocityGradientTexture;
  126787. private _createDragGradientTexture;
  126788. private _createColorGradientTexture;
  126789. /**
  126790. * Renders the particle system in its current state
  126791. * @param preWarm defines if the system should only update the particles but not render them
  126792. * @returns the current number of particles
  126793. */
  126794. render(preWarm?: boolean): number;
  126795. /**
  126796. * Rebuilds the particle system
  126797. */
  126798. rebuild(): void;
  126799. private _releaseBuffers;
  126800. private _releaseVAOs;
  126801. /**
  126802. * Disposes the particle system and free the associated resources
  126803. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126804. */
  126805. dispose(disposeTexture?: boolean): void;
  126806. /**
  126807. * Clones the particle system.
  126808. * @param name The name of the cloned object
  126809. * @param newEmitter The new emitter to use
  126810. * @returns the cloned particle system
  126811. */
  126812. clone(name: string, newEmitter: any): GPUParticleSystem;
  126813. /**
  126814. * Serializes the particle system to a JSON object.
  126815. * @returns the JSON object
  126816. */
  126817. serialize(): any;
  126818. /**
  126819. * Parses a JSON object to create a GPU particle system.
  126820. * @param parsedParticleSystem The JSON object to parse
  126821. * @param scene The scene to create the particle system in
  126822. * @param rootUrl The root url to use to load external dependencies like texture
  126823. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126824. * @returns the parsed GPU particle system
  126825. */
  126826. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126827. }
  126828. }
  126829. declare module BABYLON {
  126830. /**
  126831. * Represents a set of particle systems working together to create a specific effect
  126832. */
  126833. export class ParticleSystemSet implements IDisposable {
  126834. /**
  126835. * Gets or sets base Assets URL
  126836. */
  126837. static BaseAssetsUrl: string;
  126838. private _emitterCreationOptions;
  126839. private _emitterNode;
  126840. /**
  126841. * Gets the particle system list
  126842. */
  126843. systems: IParticleSystem[];
  126844. /**
  126845. * Gets the emitter node used with this set
  126846. */
  126847. readonly emitterNode: Nullable<TransformNode>;
  126848. /**
  126849. * Creates a new emitter mesh as a sphere
  126850. * @param options defines the options used to create the sphere
  126851. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126852. * @param scene defines the hosting scene
  126853. */
  126854. setEmitterAsSphere(options: {
  126855. diameter: number;
  126856. segments: number;
  126857. color: Color3;
  126858. }, renderingGroupId: number, scene: Scene): void;
  126859. /**
  126860. * Starts all particle systems of the set
  126861. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126862. */
  126863. start(emitter?: AbstractMesh): void;
  126864. /**
  126865. * Release all associated resources
  126866. */
  126867. dispose(): void;
  126868. /**
  126869. * Serialize the set into a JSON compatible object
  126870. * @returns a JSON compatible representation of the set
  126871. */
  126872. serialize(): any;
  126873. /**
  126874. * Parse a new ParticleSystemSet from a serialized source
  126875. * @param data defines a JSON compatible representation of the set
  126876. * @param scene defines the hosting scene
  126877. * @param gpu defines if we want GPU particles or CPU particles
  126878. * @returns a new ParticleSystemSet
  126879. */
  126880. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126881. }
  126882. }
  126883. declare module BABYLON {
  126884. /**
  126885. * This class is made for on one-liner static method to help creating particle system set.
  126886. */
  126887. export class ParticleHelper {
  126888. /**
  126889. * Gets or sets base Assets URL
  126890. */
  126891. static BaseAssetsUrl: string;
  126892. /**
  126893. * Create a default particle system that you can tweak
  126894. * @param emitter defines the emitter to use
  126895. * @param capacity defines the system capacity (default is 500 particles)
  126896. * @param scene defines the hosting scene
  126897. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126898. * @returns the new Particle system
  126899. */
  126900. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126901. /**
  126902. * This is the main static method (one-liner) of this helper to create different particle systems
  126903. * @param type This string represents the type to the particle system to create
  126904. * @param scene The scene where the particle system should live
  126905. * @param gpu If the system will use gpu
  126906. * @returns the ParticleSystemSet created
  126907. */
  126908. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126909. /**
  126910. * Static function used to export a particle system to a ParticleSystemSet variable.
  126911. * Please note that the emitter shape is not exported
  126912. * @param systems defines the particle systems to export
  126913. * @returns the created particle system set
  126914. */
  126915. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126916. }
  126917. }
  126918. declare module BABYLON {
  126919. interface Engine {
  126920. /**
  126921. * Create an effect to use with particle systems.
  126922. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126923. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126924. * @param uniformsNames defines a list of attribute names
  126925. * @param samplers defines an array of string used to represent textures
  126926. * @param defines defines the string containing the defines to use to compile the shaders
  126927. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126928. * @param onCompiled defines a function to call when the effect creation is successful
  126929. * @param onError defines a function to call when the effect creation has failed
  126930. * @returns the new Effect
  126931. */
  126932. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126933. }
  126934. interface Mesh {
  126935. /**
  126936. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126937. * @returns an array of IParticleSystem
  126938. */
  126939. getEmittedParticleSystems(): IParticleSystem[];
  126940. /**
  126941. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  126942. * @returns an array of IParticleSystem
  126943. */
  126944. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  126945. }
  126946. /**
  126947. * @hidden
  126948. */
  126949. export var _IDoNeedToBeInTheBuild: number;
  126950. }
  126951. declare module BABYLON {
  126952. /** Defines the 4 color options */
  126953. export enum PointColor {
  126954. /** color value */
  126955. Color = 2,
  126956. /** uv value */
  126957. UV = 1,
  126958. /** random value */
  126959. Random = 0,
  126960. /** stated value */
  126961. Stated = 3
  126962. }
  126963. /**
  126964. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  126965. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  126966. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  126967. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  126968. *
  126969. * Full documentation here : TO BE ENTERED
  126970. */
  126971. export class PointsCloudSystem implements IDisposable {
  126972. /**
  126973. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  126974. * Example : var p = SPS.particles[i];
  126975. */
  126976. particles: CloudPoint[];
  126977. /**
  126978. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  126979. */
  126980. nbParticles: number;
  126981. /**
  126982. * This a counter for your own usage. It's not set by any SPS functions.
  126983. */
  126984. counter: number;
  126985. /**
  126986. * The PCS name. This name is also given to the underlying mesh.
  126987. */
  126988. name: string;
  126989. /**
  126990. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  126991. */
  126992. mesh: Mesh;
  126993. /**
  126994. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  126995. * Please read :
  126996. */
  126997. vars: any;
  126998. /**
  126999. * @hidden
  127000. */
  127001. _size: number;
  127002. private _scene;
  127003. private _promises;
  127004. private _positions;
  127005. private _indices;
  127006. private _normals;
  127007. private _colors;
  127008. private _uvs;
  127009. private _indices32;
  127010. private _positions32;
  127011. private _colors32;
  127012. private _uvs32;
  127013. private _updatable;
  127014. private _isVisibilityBoxLocked;
  127015. private _alwaysVisible;
  127016. private _groups;
  127017. private _groupCounter;
  127018. private _computeParticleColor;
  127019. private _computeParticleTexture;
  127020. private _computeParticleRotation;
  127021. private _computeBoundingBox;
  127022. private _isReady;
  127023. /**
  127024. * Creates a PCS (Points Cloud System) object
  127025. * @param name (String) is the PCS name, this will be the underlying mesh name
  127026. * @param pointSize (number) is the size for each point
  127027. * @param scene (Scene) is the scene in which the PCS is added
  127028. * @param options defines the options of the PCS e.g.
  127029. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127030. */
  127031. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127032. updatable?: boolean;
  127033. });
  127034. /**
  127035. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127036. * If no points were added to the PCS, the returned mesh is just a single point.
  127037. * @returns a promise for the created mesh
  127038. */
  127039. buildMeshAsync(): Promise<Mesh>;
  127040. /**
  127041. * @hidden
  127042. */
  127043. private _buildMesh;
  127044. private _addParticle;
  127045. private _randomUnitVector;
  127046. private _getColorIndicesForCoord;
  127047. private _setPointsColorOrUV;
  127048. private _colorFromTexture;
  127049. private _calculateDensity;
  127050. /**
  127051. * Adds points to the PCS in random positions within a unit sphere
  127052. * @param nb (positive integer) the number of particles to be created from this model
  127053. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127054. * @returns the number of groups in the system
  127055. */
  127056. addPoints(nb: number, pointFunction?: any): number;
  127057. /**
  127058. * Adds points to the PCS from the surface of the model shape
  127059. * @param mesh is any Mesh object that will be used as a surface model for the points
  127060. * @param nb (positive integer) the number of particles to be created from this model
  127061. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127062. * @param color (color3) to be used when colorWith is stated
  127063. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127064. * @returns the number of groups in the system
  127065. */
  127066. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  127067. /**
  127068. * Adds points to the PCS inside the model shape
  127069. * @param mesh is any Mesh object that will be used as a surface model for the points
  127070. * @param nb (positive integer) the number of particles to be created from this model
  127071. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  127072. * @param color (color4) to be used when colorWith is stated
  127073. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127074. * @returns the number of groups in the system
  127075. */
  127076. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  127077. /**
  127078. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127079. * This method calls `updateParticle()` for each particle of the SPS.
  127080. * For an animated SPS, it is usually called within the render loop.
  127081. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127082. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127083. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127084. * @returns the PCS.
  127085. */
  127086. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127087. /**
  127088. * Disposes the PCS.
  127089. */
  127090. dispose(): void;
  127091. /**
  127092. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127093. * doc :
  127094. * @returns the PCS.
  127095. */
  127096. refreshVisibleSize(): PointsCloudSystem;
  127097. /**
  127098. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127099. * @param size the size (float) of the visibility box
  127100. * note : this doesn't lock the PCS mesh bounding box.
  127101. * doc :
  127102. */
  127103. setVisibilityBox(size: number): void;
  127104. /**
  127105. * Gets whether the PCS is always visible or not
  127106. * doc :
  127107. */
  127108. /**
  127109. * Sets the PCS as always visible or not
  127110. * doc :
  127111. */
  127112. isAlwaysVisible: boolean;
  127113. /**
  127114. * Tells to `setParticles()` to compute the particle rotations or not
  127115. * Default value : false. The PCS is faster when it's set to false
  127116. * Note : particle rotations are only applied to parent particles
  127117. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127118. */
  127119. computeParticleRotation: boolean;
  127120. /**
  127121. * Tells to `setParticles()` to compute the particle colors or not.
  127122. * Default value : true. The PCS is faster when it's set to false.
  127123. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127124. */
  127125. /**
  127126. * Gets if `setParticles()` computes the particle colors or not.
  127127. * Default value : false. The PCS is faster when it's set to false.
  127128. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127129. */
  127130. computeParticleColor: boolean;
  127131. /**
  127132. * Gets if `setParticles()` computes the particle textures or not.
  127133. * Default value : false. The PCS is faster when it's set to false.
  127134. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127135. */
  127136. computeParticleTexture: boolean;
  127137. /**
  127138. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127139. */
  127140. /**
  127141. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127142. */
  127143. computeBoundingBox: boolean;
  127144. /**
  127145. * This function does nothing. It may be overwritten to set all the particle first values.
  127146. * The PCS doesn't call this function, you may have to call it by your own.
  127147. * doc :
  127148. */
  127149. initParticles(): void;
  127150. /**
  127151. * This function does nothing. It may be overwritten to recycle a particle
  127152. * The PCS doesn't call this function, you can to call it
  127153. * doc :
  127154. * @param particle The particle to recycle
  127155. * @returns the recycled particle
  127156. */
  127157. recycleParticle(particle: CloudPoint): CloudPoint;
  127158. /**
  127159. * Updates a particle : this function should be overwritten by the user.
  127160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127161. * doc :
  127162. * @example : just set a particle position or velocity and recycle conditions
  127163. * @param particle The particle to update
  127164. * @returns the updated particle
  127165. */
  127166. updateParticle(particle: CloudPoint): CloudPoint;
  127167. /**
  127168. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127169. * This does nothing and may be overwritten by the user.
  127170. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127171. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127172. * @param update the boolean update value actually passed to setParticles()
  127173. */
  127174. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127175. /**
  127176. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127177. * This will be passed three parameters.
  127178. * This does nothing and may be overwritten by the user.
  127179. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127181. * @param update the boolean update value actually passed to setParticles()
  127182. */
  127183. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127184. }
  127185. }
  127186. declare module BABYLON {
  127187. /**
  127188. * Represents one particle of a points cloud system.
  127189. */
  127190. export class CloudPoint {
  127191. /**
  127192. * particle global index
  127193. */
  127194. idx: number;
  127195. /**
  127196. * The color of the particle
  127197. */
  127198. color: Nullable<Color4>;
  127199. /**
  127200. * The world space position of the particle.
  127201. */
  127202. position: Vector3;
  127203. /**
  127204. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127205. */
  127206. rotation: Vector3;
  127207. /**
  127208. * The world space rotation quaternion of the particle.
  127209. */
  127210. rotationQuaternion: Nullable<Quaternion>;
  127211. /**
  127212. * The uv of the particle.
  127213. */
  127214. uv: Nullable<Vector2>;
  127215. /**
  127216. * The current speed of the particle.
  127217. */
  127218. velocity: Vector3;
  127219. /**
  127220. * The pivot point in the particle local space.
  127221. */
  127222. pivot: Vector3;
  127223. /**
  127224. * Must the particle be translated from its pivot point in its local space ?
  127225. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127226. * Default : false
  127227. */
  127228. translateFromPivot: boolean;
  127229. /**
  127230. * Index of this particle in the global "positions" array (Internal use)
  127231. * @hidden
  127232. */
  127233. _pos: number;
  127234. /**
  127235. * @hidden Index of this particle in the global "indices" array (Internal use)
  127236. */
  127237. _ind: number;
  127238. /**
  127239. * Group this particle belongs to
  127240. */
  127241. _group: PointsGroup;
  127242. /**
  127243. * Group id of this particle
  127244. */
  127245. groupId: number;
  127246. /**
  127247. * Index of the particle in its group id (Internal use)
  127248. */
  127249. idxInGroup: number;
  127250. /**
  127251. * @hidden Particle BoundingInfo object (Internal use)
  127252. */
  127253. _boundingInfo: BoundingInfo;
  127254. /**
  127255. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127256. */
  127257. _pcs: PointsCloudSystem;
  127258. /**
  127259. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127260. */
  127261. _stillInvisible: boolean;
  127262. /**
  127263. * @hidden Last computed particle rotation matrix
  127264. */
  127265. _rotationMatrix: number[];
  127266. /**
  127267. * Parent particle Id, if any.
  127268. * Default null.
  127269. */
  127270. parentId: Nullable<number>;
  127271. /**
  127272. * @hidden Internal global position in the PCS.
  127273. */
  127274. _globalPosition: Vector3;
  127275. /**
  127276. * Creates a Point Cloud object.
  127277. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127278. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127279. * @param group (PointsGroup) is the group the particle belongs to
  127280. * @param groupId (integer) is the group identifier in the PCS.
  127281. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127282. * @param pcs defines the PCS it is associated to
  127283. */
  127284. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127285. /**
  127286. * get point size
  127287. */
  127288. /**
  127289. * Set point size
  127290. */
  127291. size: Vector3;
  127292. /**
  127293. * Legacy support, changed quaternion to rotationQuaternion
  127294. */
  127295. /**
  127296. * Legacy support, changed quaternion to rotationQuaternion
  127297. */
  127298. quaternion: Nullable<Quaternion>;
  127299. /**
  127300. * Returns a boolean. True if the particle intersects a mesh, else false
  127301. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127302. * @param target is the object (point or mesh) what the intersection is computed against
  127303. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127304. * @returns true if it intersects
  127305. */
  127306. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127307. /**
  127308. * get the rotation matrix of the particle
  127309. * @hidden
  127310. */
  127311. getRotationMatrix(m: Matrix): void;
  127312. }
  127313. /**
  127314. * Represents a group of points in a points cloud system
  127315. * * PCS internal tool, don't use it manually.
  127316. */
  127317. export class PointsGroup {
  127318. /**
  127319. * The group id
  127320. * @hidden
  127321. */
  127322. groupID: number;
  127323. /**
  127324. * image data for group (internal use)
  127325. * @hidden
  127326. */
  127327. _groupImageData: Nullable<ArrayBufferView>;
  127328. /**
  127329. * Image Width (internal use)
  127330. * @hidden
  127331. */
  127332. _groupImgWidth: number;
  127333. /**
  127334. * Image Height (internal use)
  127335. * @hidden
  127336. */
  127337. _groupImgHeight: number;
  127338. /**
  127339. * Custom position function (internal use)
  127340. * @hidden
  127341. */
  127342. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127343. /**
  127344. * density per facet for surface points
  127345. * @hidden
  127346. */
  127347. _groupDensity: number[];
  127348. /**
  127349. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127350. * PCS internal tool, don't use it manually.
  127351. * @hidden
  127352. */
  127353. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127354. }
  127355. }
  127356. declare module BABYLON {
  127357. interface Scene {
  127358. /** @hidden (Backing field) */
  127359. _physicsEngine: Nullable<IPhysicsEngine>;
  127360. /**
  127361. * Gets the current physics engine
  127362. * @returns a IPhysicsEngine or null if none attached
  127363. */
  127364. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127365. /**
  127366. * Enables physics to the current scene
  127367. * @param gravity defines the scene's gravity for the physics engine
  127368. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127369. * @return a boolean indicating if the physics engine was initialized
  127370. */
  127371. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127372. /**
  127373. * Disables and disposes the physics engine associated with the scene
  127374. */
  127375. disablePhysicsEngine(): void;
  127376. /**
  127377. * Gets a boolean indicating if there is an active physics engine
  127378. * @returns a boolean indicating if there is an active physics engine
  127379. */
  127380. isPhysicsEnabled(): boolean;
  127381. /**
  127382. * Deletes a physics compound impostor
  127383. * @param compound defines the compound to delete
  127384. */
  127385. deleteCompoundImpostor(compound: any): void;
  127386. /**
  127387. * An event triggered when physic simulation is about to be run
  127388. */
  127389. onBeforePhysicsObservable: Observable<Scene>;
  127390. /**
  127391. * An event triggered when physic simulation has been done
  127392. */
  127393. onAfterPhysicsObservable: Observable<Scene>;
  127394. }
  127395. interface AbstractMesh {
  127396. /** @hidden */
  127397. _physicsImpostor: Nullable<PhysicsImpostor>;
  127398. /**
  127399. * Gets or sets impostor used for physic simulation
  127400. * @see http://doc.babylonjs.com/features/physics_engine
  127401. */
  127402. physicsImpostor: Nullable<PhysicsImpostor>;
  127403. /**
  127404. * Gets the current physics impostor
  127405. * @see http://doc.babylonjs.com/features/physics_engine
  127406. * @returns a physics impostor or null
  127407. */
  127408. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127409. /** Apply a physic impulse to the mesh
  127410. * @param force defines the force to apply
  127411. * @param contactPoint defines where to apply the force
  127412. * @returns the current mesh
  127413. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127414. */
  127415. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127416. /**
  127417. * Creates a physic joint between two meshes
  127418. * @param otherMesh defines the other mesh to use
  127419. * @param pivot1 defines the pivot to use on this mesh
  127420. * @param pivot2 defines the pivot to use on the other mesh
  127421. * @param options defines additional options (can be plugin dependent)
  127422. * @returns the current mesh
  127423. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127424. */
  127425. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127426. /** @hidden */
  127427. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127428. }
  127429. /**
  127430. * Defines the physics engine scene component responsible to manage a physics engine
  127431. */
  127432. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127433. /**
  127434. * The component name helpful to identify the component in the list of scene components.
  127435. */
  127436. readonly name: string;
  127437. /**
  127438. * The scene the component belongs to.
  127439. */
  127440. scene: Scene;
  127441. /**
  127442. * Creates a new instance of the component for the given scene
  127443. * @param scene Defines the scene to register the component in
  127444. */
  127445. constructor(scene: Scene);
  127446. /**
  127447. * Registers the component in a given scene
  127448. */
  127449. register(): void;
  127450. /**
  127451. * Rebuilds the elements related to this component in case of
  127452. * context lost for instance.
  127453. */
  127454. rebuild(): void;
  127455. /**
  127456. * Disposes the component and the associated ressources
  127457. */
  127458. dispose(): void;
  127459. }
  127460. }
  127461. declare module BABYLON {
  127462. /**
  127463. * A helper for physics simulations
  127464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127465. */
  127466. export class PhysicsHelper {
  127467. private _scene;
  127468. private _physicsEngine;
  127469. /**
  127470. * Initializes the Physics helper
  127471. * @param scene Babylon.js scene
  127472. */
  127473. constructor(scene: Scene);
  127474. /**
  127475. * Applies a radial explosion impulse
  127476. * @param origin the origin of the explosion
  127477. * @param radiusOrEventOptions the radius or the options of radial explosion
  127478. * @param strength the explosion strength
  127479. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127480. * @returns A physics radial explosion event, or null
  127481. */
  127482. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127483. /**
  127484. * Applies a radial explosion force
  127485. * @param origin the origin of the explosion
  127486. * @param radiusOrEventOptions the radius or the options of radial explosion
  127487. * @param strength the explosion strength
  127488. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127489. * @returns A physics radial explosion event, or null
  127490. */
  127491. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127492. /**
  127493. * Creates a gravitational field
  127494. * @param origin the origin of the explosion
  127495. * @param radiusOrEventOptions the radius or the options of radial explosion
  127496. * @param strength the explosion strength
  127497. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127498. * @returns A physics gravitational field event, or null
  127499. */
  127500. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127501. /**
  127502. * Creates a physics updraft event
  127503. * @param origin the origin of the updraft
  127504. * @param radiusOrEventOptions the radius or the options of the updraft
  127505. * @param strength the strength of the updraft
  127506. * @param height the height of the updraft
  127507. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127508. * @returns A physics updraft event, or null
  127509. */
  127510. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127511. /**
  127512. * Creates a physics vortex event
  127513. * @param origin the of the vortex
  127514. * @param radiusOrEventOptions the radius or the options of the vortex
  127515. * @param strength the strength of the vortex
  127516. * @param height the height of the vortex
  127517. * @returns a Physics vortex event, or null
  127518. * A physics vortex event or null
  127519. */
  127520. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127521. }
  127522. /**
  127523. * Represents a physics radial explosion event
  127524. */
  127525. class PhysicsRadialExplosionEvent {
  127526. private _scene;
  127527. private _options;
  127528. private _sphere;
  127529. private _dataFetched;
  127530. /**
  127531. * Initializes a radial explosioin event
  127532. * @param _scene BabylonJS scene
  127533. * @param _options The options for the vortex event
  127534. */
  127535. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127536. /**
  127537. * Returns the data related to the radial explosion event (sphere).
  127538. * @returns The radial explosion event data
  127539. */
  127540. getData(): PhysicsRadialExplosionEventData;
  127541. /**
  127542. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127543. * @param impostor A physics imposter
  127544. * @param origin the origin of the explosion
  127545. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127546. */
  127547. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127548. /**
  127549. * Triggers affecterd impostors callbacks
  127550. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127551. */
  127552. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127553. /**
  127554. * Disposes the sphere.
  127555. * @param force Specifies if the sphere should be disposed by force
  127556. */
  127557. dispose(force?: boolean): void;
  127558. /*** Helpers ***/
  127559. private _prepareSphere;
  127560. private _intersectsWithSphere;
  127561. }
  127562. /**
  127563. * Represents a gravitational field event
  127564. */
  127565. class PhysicsGravitationalFieldEvent {
  127566. private _physicsHelper;
  127567. private _scene;
  127568. private _origin;
  127569. private _options;
  127570. private _tickCallback;
  127571. private _sphere;
  127572. private _dataFetched;
  127573. /**
  127574. * Initializes the physics gravitational field event
  127575. * @param _physicsHelper A physics helper
  127576. * @param _scene BabylonJS scene
  127577. * @param _origin The origin position of the gravitational field event
  127578. * @param _options The options for the vortex event
  127579. */
  127580. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127581. /**
  127582. * Returns the data related to the gravitational field event (sphere).
  127583. * @returns A gravitational field event
  127584. */
  127585. getData(): PhysicsGravitationalFieldEventData;
  127586. /**
  127587. * Enables the gravitational field.
  127588. */
  127589. enable(): void;
  127590. /**
  127591. * Disables the gravitational field.
  127592. */
  127593. disable(): void;
  127594. /**
  127595. * Disposes the sphere.
  127596. * @param force The force to dispose from the gravitational field event
  127597. */
  127598. dispose(force?: boolean): void;
  127599. private _tick;
  127600. }
  127601. /**
  127602. * Represents a physics updraft event
  127603. */
  127604. class PhysicsUpdraftEvent {
  127605. private _scene;
  127606. private _origin;
  127607. private _options;
  127608. private _physicsEngine;
  127609. private _originTop;
  127610. private _originDirection;
  127611. private _tickCallback;
  127612. private _cylinder;
  127613. private _cylinderPosition;
  127614. private _dataFetched;
  127615. /**
  127616. * Initializes the physics updraft event
  127617. * @param _scene BabylonJS scene
  127618. * @param _origin The origin position of the updraft
  127619. * @param _options The options for the updraft event
  127620. */
  127621. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127622. /**
  127623. * Returns the data related to the updraft event (cylinder).
  127624. * @returns A physics updraft event
  127625. */
  127626. getData(): PhysicsUpdraftEventData;
  127627. /**
  127628. * Enables the updraft.
  127629. */
  127630. enable(): void;
  127631. /**
  127632. * Disables the updraft.
  127633. */
  127634. disable(): void;
  127635. /**
  127636. * Disposes the cylinder.
  127637. * @param force Specifies if the updraft should be disposed by force
  127638. */
  127639. dispose(force?: boolean): void;
  127640. private getImpostorHitData;
  127641. private _tick;
  127642. /*** Helpers ***/
  127643. private _prepareCylinder;
  127644. private _intersectsWithCylinder;
  127645. }
  127646. /**
  127647. * Represents a physics vortex event
  127648. */
  127649. class PhysicsVortexEvent {
  127650. private _scene;
  127651. private _origin;
  127652. private _options;
  127653. private _physicsEngine;
  127654. private _originTop;
  127655. private _tickCallback;
  127656. private _cylinder;
  127657. private _cylinderPosition;
  127658. private _dataFetched;
  127659. /**
  127660. * Initializes the physics vortex event
  127661. * @param _scene The BabylonJS scene
  127662. * @param _origin The origin position of the vortex
  127663. * @param _options The options for the vortex event
  127664. */
  127665. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127666. /**
  127667. * Returns the data related to the vortex event (cylinder).
  127668. * @returns The physics vortex event data
  127669. */
  127670. getData(): PhysicsVortexEventData;
  127671. /**
  127672. * Enables the vortex.
  127673. */
  127674. enable(): void;
  127675. /**
  127676. * Disables the cortex.
  127677. */
  127678. disable(): void;
  127679. /**
  127680. * Disposes the sphere.
  127681. * @param force
  127682. */
  127683. dispose(force?: boolean): void;
  127684. private getImpostorHitData;
  127685. private _tick;
  127686. /*** Helpers ***/
  127687. private _prepareCylinder;
  127688. private _intersectsWithCylinder;
  127689. }
  127690. /**
  127691. * Options fot the radial explosion event
  127692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127693. */
  127694. export class PhysicsRadialExplosionEventOptions {
  127695. /**
  127696. * The radius of the sphere for the radial explosion.
  127697. */
  127698. radius: number;
  127699. /**
  127700. * The strenth of the explosion.
  127701. */
  127702. strength: number;
  127703. /**
  127704. * The strenght of the force in correspondence to the distance of the affected object
  127705. */
  127706. falloff: PhysicsRadialImpulseFalloff;
  127707. /**
  127708. * Sphere options for the radial explosion.
  127709. */
  127710. sphere: {
  127711. segments: number;
  127712. diameter: number;
  127713. };
  127714. /**
  127715. * Sphere options for the radial explosion.
  127716. */
  127717. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127718. }
  127719. /**
  127720. * Options fot the updraft event
  127721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127722. */
  127723. export class PhysicsUpdraftEventOptions {
  127724. /**
  127725. * The radius of the cylinder for the vortex
  127726. */
  127727. radius: number;
  127728. /**
  127729. * The strenth of the updraft.
  127730. */
  127731. strength: number;
  127732. /**
  127733. * The height of the cylinder for the updraft.
  127734. */
  127735. height: number;
  127736. /**
  127737. * The mode for the the updraft.
  127738. */
  127739. updraftMode: PhysicsUpdraftMode;
  127740. }
  127741. /**
  127742. * Options fot the vortex event
  127743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127744. */
  127745. export class PhysicsVortexEventOptions {
  127746. /**
  127747. * The radius of the cylinder for the vortex
  127748. */
  127749. radius: number;
  127750. /**
  127751. * The strenth of the vortex.
  127752. */
  127753. strength: number;
  127754. /**
  127755. * The height of the cylinder for the vortex.
  127756. */
  127757. height: number;
  127758. /**
  127759. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127760. */
  127761. centripetalForceThreshold: number;
  127762. /**
  127763. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127764. */
  127765. centripetalForceMultiplier: number;
  127766. /**
  127767. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127768. */
  127769. centrifugalForceMultiplier: number;
  127770. /**
  127771. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127772. */
  127773. updraftForceMultiplier: number;
  127774. }
  127775. /**
  127776. * The strenght of the force in correspondence to the distance of the affected object
  127777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127778. */
  127779. export enum PhysicsRadialImpulseFalloff {
  127780. /** Defines that impulse is constant in strength across it's whole radius */
  127781. Constant = 0,
  127782. /** Defines that impulse gets weaker if it's further from the origin */
  127783. Linear = 1
  127784. }
  127785. /**
  127786. * The strength of the force in correspondence to the distance of the affected object
  127787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127788. */
  127789. export enum PhysicsUpdraftMode {
  127790. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127791. Center = 0,
  127792. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127793. Perpendicular = 1
  127794. }
  127795. /**
  127796. * Interface for a physics hit data
  127797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127798. */
  127799. export interface PhysicsHitData {
  127800. /**
  127801. * The force applied at the contact point
  127802. */
  127803. force: Vector3;
  127804. /**
  127805. * The contact point
  127806. */
  127807. contactPoint: Vector3;
  127808. /**
  127809. * The distance from the origin to the contact point
  127810. */
  127811. distanceFromOrigin: number;
  127812. }
  127813. /**
  127814. * Interface for radial explosion event data
  127815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127816. */
  127817. export interface PhysicsRadialExplosionEventData {
  127818. /**
  127819. * A sphere used for the radial explosion event
  127820. */
  127821. sphere: Mesh;
  127822. }
  127823. /**
  127824. * Interface for gravitational field event data
  127825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127826. */
  127827. export interface PhysicsGravitationalFieldEventData {
  127828. /**
  127829. * A sphere mesh used for the gravitational field event
  127830. */
  127831. sphere: Mesh;
  127832. }
  127833. /**
  127834. * Interface for updraft event data
  127835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127836. */
  127837. export interface PhysicsUpdraftEventData {
  127838. /**
  127839. * A cylinder used for the updraft event
  127840. */
  127841. cylinder: Mesh;
  127842. }
  127843. /**
  127844. * Interface for vortex event data
  127845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127846. */
  127847. export interface PhysicsVortexEventData {
  127848. /**
  127849. * A cylinder used for the vortex event
  127850. */
  127851. cylinder: Mesh;
  127852. }
  127853. /**
  127854. * Interface for an affected physics impostor
  127855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127856. */
  127857. export interface PhysicsAffectedImpostorWithData {
  127858. /**
  127859. * The impostor affected by the effect
  127860. */
  127861. impostor: PhysicsImpostor;
  127862. /**
  127863. * The data about the hit/horce from the explosion
  127864. */
  127865. hitData: PhysicsHitData;
  127866. }
  127867. }
  127868. declare module BABYLON {
  127869. /** @hidden */
  127870. export var blackAndWhitePixelShader: {
  127871. name: string;
  127872. shader: string;
  127873. };
  127874. }
  127875. declare module BABYLON {
  127876. /**
  127877. * Post process used to render in black and white
  127878. */
  127879. export class BlackAndWhitePostProcess extends PostProcess {
  127880. /**
  127881. * Linear about to convert he result to black and white (default: 1)
  127882. */
  127883. degree: number;
  127884. /**
  127885. * Creates a black and white post process
  127886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127887. * @param name The name of the effect.
  127888. * @param options The required width/height ratio to downsize to before computing the render pass.
  127889. * @param camera The camera to apply the render pass to.
  127890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127891. * @param engine The engine which the post process will be applied. (default: current engine)
  127892. * @param reusable If the post process can be reused on the same frame. (default: false)
  127893. */
  127894. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127895. }
  127896. }
  127897. declare module BABYLON {
  127898. /**
  127899. * This represents a set of one or more post processes in Babylon.
  127900. * A post process can be used to apply a shader to a texture after it is rendered.
  127901. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127902. */
  127903. export class PostProcessRenderEffect {
  127904. private _postProcesses;
  127905. private _getPostProcesses;
  127906. private _singleInstance;
  127907. private _cameras;
  127908. private _indicesForCamera;
  127909. /**
  127910. * Name of the effect
  127911. * @hidden
  127912. */
  127913. _name: string;
  127914. /**
  127915. * Instantiates a post process render effect.
  127916. * A post process can be used to apply a shader to a texture after it is rendered.
  127917. * @param engine The engine the effect is tied to
  127918. * @param name The name of the effect
  127919. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127920. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127921. */
  127922. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127923. /**
  127924. * Checks if all the post processes in the effect are supported.
  127925. */
  127926. readonly isSupported: boolean;
  127927. /**
  127928. * Updates the current state of the effect
  127929. * @hidden
  127930. */
  127931. _update(): void;
  127932. /**
  127933. * Attaches the effect on cameras
  127934. * @param cameras The camera to attach to.
  127935. * @hidden
  127936. */
  127937. _attachCameras(cameras: Camera): void;
  127938. /**
  127939. * Attaches the effect on cameras
  127940. * @param cameras The camera to attach to.
  127941. * @hidden
  127942. */
  127943. _attachCameras(cameras: Camera[]): void;
  127944. /**
  127945. * Detaches the effect on cameras
  127946. * @param cameras The camera to detatch from.
  127947. * @hidden
  127948. */
  127949. _detachCameras(cameras: Camera): void;
  127950. /**
  127951. * Detatches the effect on cameras
  127952. * @param cameras The camera to detatch from.
  127953. * @hidden
  127954. */
  127955. _detachCameras(cameras: Camera[]): void;
  127956. /**
  127957. * Enables the effect on given cameras
  127958. * @param cameras The camera to enable.
  127959. * @hidden
  127960. */
  127961. _enable(cameras: Camera): void;
  127962. /**
  127963. * Enables the effect on given cameras
  127964. * @param cameras The camera to enable.
  127965. * @hidden
  127966. */
  127967. _enable(cameras: Nullable<Camera[]>): void;
  127968. /**
  127969. * Disables the effect on the given cameras
  127970. * @param cameras The camera to disable.
  127971. * @hidden
  127972. */
  127973. _disable(cameras: Camera): void;
  127974. /**
  127975. * Disables the effect on the given cameras
  127976. * @param cameras The camera to disable.
  127977. * @hidden
  127978. */
  127979. _disable(cameras: Nullable<Camera[]>): void;
  127980. /**
  127981. * Gets a list of the post processes contained in the effect.
  127982. * @param camera The camera to get the post processes on.
  127983. * @returns The list of the post processes in the effect.
  127984. */
  127985. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  127986. }
  127987. }
  127988. declare module BABYLON {
  127989. /** @hidden */
  127990. export var extractHighlightsPixelShader: {
  127991. name: string;
  127992. shader: string;
  127993. };
  127994. }
  127995. declare module BABYLON {
  127996. /**
  127997. * 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.
  127998. */
  127999. export class ExtractHighlightsPostProcess extends PostProcess {
  128000. /**
  128001. * The luminance threshold, pixels below this value will be set to black.
  128002. */
  128003. threshold: number;
  128004. /** @hidden */
  128005. _exposure: number;
  128006. /**
  128007. * Post process which has the input texture to be used when performing highlight extraction
  128008. * @hidden
  128009. */
  128010. _inputPostProcess: Nullable<PostProcess>;
  128011. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128012. }
  128013. }
  128014. declare module BABYLON {
  128015. /** @hidden */
  128016. export var bloomMergePixelShader: {
  128017. name: string;
  128018. shader: string;
  128019. };
  128020. }
  128021. declare module BABYLON {
  128022. /**
  128023. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128024. */
  128025. export class BloomMergePostProcess extends PostProcess {
  128026. /** Weight of the bloom to be added to the original input. */
  128027. weight: number;
  128028. /**
  128029. * Creates a new instance of @see BloomMergePostProcess
  128030. * @param name The name of the effect.
  128031. * @param originalFromInput Post process which's input will be used for the merge.
  128032. * @param blurred Blurred highlights post process which's output will be used.
  128033. * @param weight Weight of the bloom to be added to the original input.
  128034. * @param options The required width/height ratio to downsize to before computing the render pass.
  128035. * @param camera The camera to apply the render pass to.
  128036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128037. * @param engine The engine which the post process will be applied. (default: current engine)
  128038. * @param reusable If the post process can be reused on the same frame. (default: false)
  128039. * @param textureType Type of textures used when performing the post process. (default: 0)
  128040. * @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)
  128041. */
  128042. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128043. /** Weight of the bloom to be added to the original input. */
  128044. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128045. }
  128046. }
  128047. declare module BABYLON {
  128048. /**
  128049. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128050. */
  128051. export class BloomEffect extends PostProcessRenderEffect {
  128052. private bloomScale;
  128053. /**
  128054. * @hidden Internal
  128055. */
  128056. _effects: Array<PostProcess>;
  128057. /**
  128058. * @hidden Internal
  128059. */
  128060. _downscale: ExtractHighlightsPostProcess;
  128061. private _blurX;
  128062. private _blurY;
  128063. private _merge;
  128064. /**
  128065. * The luminance threshold to find bright areas of the image to bloom.
  128066. */
  128067. threshold: number;
  128068. /**
  128069. * The strength of the bloom.
  128070. */
  128071. weight: number;
  128072. /**
  128073. * Specifies the size of the bloom blur kernel, relative to the final output size
  128074. */
  128075. kernel: number;
  128076. /**
  128077. * Creates a new instance of @see BloomEffect
  128078. * @param scene The scene the effect belongs to.
  128079. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128080. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128081. * @param bloomWeight The the strength of bloom.
  128082. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128083. * @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)
  128084. */
  128085. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128086. /**
  128087. * Disposes each of the internal effects for a given camera.
  128088. * @param camera The camera to dispose the effect on.
  128089. */
  128090. disposeEffects(camera: Camera): void;
  128091. /**
  128092. * @hidden Internal
  128093. */
  128094. _updateEffects(): void;
  128095. /**
  128096. * Internal
  128097. * @returns if all the contained post processes are ready.
  128098. * @hidden
  128099. */
  128100. _isReady(): boolean;
  128101. }
  128102. }
  128103. declare module BABYLON {
  128104. /** @hidden */
  128105. export var chromaticAberrationPixelShader: {
  128106. name: string;
  128107. shader: string;
  128108. };
  128109. }
  128110. declare module BABYLON {
  128111. /**
  128112. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128113. */
  128114. export class ChromaticAberrationPostProcess extends PostProcess {
  128115. /**
  128116. * The amount of seperation of rgb channels (default: 30)
  128117. */
  128118. aberrationAmount: number;
  128119. /**
  128120. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128121. */
  128122. radialIntensity: number;
  128123. /**
  128124. * 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))
  128125. */
  128126. direction: Vector2;
  128127. /**
  128128. * 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))
  128129. */
  128130. centerPosition: Vector2;
  128131. /**
  128132. * Creates a new instance ChromaticAberrationPostProcess
  128133. * @param name The name of the effect.
  128134. * @param screenWidth The width of the screen to apply the effect on.
  128135. * @param screenHeight The height of the screen to apply the effect on.
  128136. * @param options The required width/height ratio to downsize to before computing the render pass.
  128137. * @param camera The camera to apply the render pass to.
  128138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128139. * @param engine The engine which the post process will be applied. (default: current engine)
  128140. * @param reusable If the post process can be reused on the same frame. (default: false)
  128141. * @param textureType Type of textures used when performing the post process. (default: 0)
  128142. * @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)
  128143. */
  128144. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128145. }
  128146. }
  128147. declare module BABYLON {
  128148. /** @hidden */
  128149. export var circleOfConfusionPixelShader: {
  128150. name: string;
  128151. shader: string;
  128152. };
  128153. }
  128154. declare module BABYLON {
  128155. /**
  128156. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128157. */
  128158. export class CircleOfConfusionPostProcess extends PostProcess {
  128159. /**
  128160. * 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.
  128161. */
  128162. lensSize: number;
  128163. /**
  128164. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128165. */
  128166. fStop: number;
  128167. /**
  128168. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128169. */
  128170. focusDistance: number;
  128171. /**
  128172. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128173. */
  128174. focalLength: number;
  128175. private _depthTexture;
  128176. /**
  128177. * Creates a new instance CircleOfConfusionPostProcess
  128178. * @param name The name of the effect.
  128179. * @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.
  128180. * @param options The required width/height ratio to downsize to before computing the render pass.
  128181. * @param camera The camera to apply the render pass to.
  128182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128183. * @param engine The engine which the post process will be applied. (default: current engine)
  128184. * @param reusable If the post process can be reused on the same frame. (default: false)
  128185. * @param textureType Type of textures used when performing the post process. (default: 0)
  128186. * @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)
  128187. */
  128188. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128189. /**
  128190. * 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.
  128191. */
  128192. depthTexture: RenderTargetTexture;
  128193. }
  128194. }
  128195. declare module BABYLON {
  128196. /** @hidden */
  128197. export var colorCorrectionPixelShader: {
  128198. name: string;
  128199. shader: string;
  128200. };
  128201. }
  128202. declare module BABYLON {
  128203. /**
  128204. *
  128205. * This post-process allows the modification of rendered colors by using
  128206. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128207. *
  128208. * The object needs to be provided an url to a texture containing the color
  128209. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128210. * Use an image editing software to tweak the LUT to match your needs.
  128211. *
  128212. * For an example of a color LUT, see here:
  128213. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128214. * For explanations on color grading, see here:
  128215. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128216. *
  128217. */
  128218. export class ColorCorrectionPostProcess extends PostProcess {
  128219. private _colorTableTexture;
  128220. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128221. }
  128222. }
  128223. declare module BABYLON {
  128224. /** @hidden */
  128225. export var convolutionPixelShader: {
  128226. name: string;
  128227. shader: string;
  128228. };
  128229. }
  128230. declare module BABYLON {
  128231. /**
  128232. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128233. * input texture to perform effects such as edge detection or sharpening
  128234. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128235. */
  128236. export class ConvolutionPostProcess extends PostProcess {
  128237. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128238. kernel: number[];
  128239. /**
  128240. * Creates a new instance ConvolutionPostProcess
  128241. * @param name The name of the effect.
  128242. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128243. * @param options The required width/height ratio to downsize to before computing the render pass.
  128244. * @param camera The camera to apply the render pass to.
  128245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128246. * @param engine The engine which the post process will be applied. (default: current engine)
  128247. * @param reusable If the post process can be reused on the same frame. (default: false)
  128248. * @param textureType Type of textures used when performing the post process. (default: 0)
  128249. */
  128250. constructor(name: string,
  128251. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128252. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128253. /**
  128254. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128255. */
  128256. static EdgeDetect0Kernel: number[];
  128257. /**
  128258. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128259. */
  128260. static EdgeDetect1Kernel: number[];
  128261. /**
  128262. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128263. */
  128264. static EdgeDetect2Kernel: number[];
  128265. /**
  128266. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128267. */
  128268. static SharpenKernel: number[];
  128269. /**
  128270. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128271. */
  128272. static EmbossKernel: number[];
  128273. /**
  128274. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128275. */
  128276. static GaussianKernel: number[];
  128277. }
  128278. }
  128279. declare module BABYLON {
  128280. /**
  128281. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128282. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128283. * based on samples that have a large difference in distance than the center pixel.
  128284. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128285. */
  128286. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128287. direction: Vector2;
  128288. /**
  128289. * Creates a new instance CircleOfConfusionPostProcess
  128290. * @param name The name of the effect.
  128291. * @param scene The scene the effect belongs to.
  128292. * @param direction The direction the blur should be applied.
  128293. * @param kernel The size of the kernel used to blur.
  128294. * @param options The required width/height ratio to downsize to before computing the render pass.
  128295. * @param camera The camera to apply the render pass to.
  128296. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128297. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128299. * @param engine The engine which the post process will be applied. (default: current engine)
  128300. * @param reusable If the post process can be reused on the same frame. (default: false)
  128301. * @param textureType Type of textures used when performing the post process. (default: 0)
  128302. * @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)
  128303. */
  128304. 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);
  128305. }
  128306. }
  128307. declare module BABYLON {
  128308. /** @hidden */
  128309. export var depthOfFieldMergePixelShader: {
  128310. name: string;
  128311. shader: string;
  128312. };
  128313. }
  128314. declare module BABYLON {
  128315. /**
  128316. * Options to be set when merging outputs from the default pipeline.
  128317. */
  128318. export class DepthOfFieldMergePostProcessOptions {
  128319. /**
  128320. * The original image to merge on top of
  128321. */
  128322. originalFromInput: PostProcess;
  128323. /**
  128324. * Parameters to perform the merge of the depth of field effect
  128325. */
  128326. depthOfField?: {
  128327. circleOfConfusion: PostProcess;
  128328. blurSteps: Array<PostProcess>;
  128329. };
  128330. /**
  128331. * Parameters to perform the merge of bloom effect
  128332. */
  128333. bloom?: {
  128334. blurred: PostProcess;
  128335. weight: number;
  128336. };
  128337. }
  128338. /**
  128339. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128340. */
  128341. export class DepthOfFieldMergePostProcess extends PostProcess {
  128342. private blurSteps;
  128343. /**
  128344. * Creates a new instance of DepthOfFieldMergePostProcess
  128345. * @param name The name of the effect.
  128346. * @param originalFromInput Post process which's input will be used for the merge.
  128347. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128348. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128349. * @param options The required width/height ratio to downsize to before computing the render pass.
  128350. * @param camera The camera to apply the render pass to.
  128351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128352. * @param engine The engine which the post process will be applied. (default: current engine)
  128353. * @param reusable If the post process can be reused on the same frame. (default: false)
  128354. * @param textureType Type of textures used when performing the post process. (default: 0)
  128355. * @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)
  128356. */
  128357. 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);
  128358. /**
  128359. * Updates the effect with the current post process compile time values and recompiles the shader.
  128360. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128361. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128362. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128363. * @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
  128364. * @param onCompiled Called when the shader has been compiled.
  128365. * @param onError Called if there is an error when compiling a shader.
  128366. */
  128367. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128368. }
  128369. }
  128370. declare module BABYLON {
  128371. /**
  128372. * Specifies the level of max blur that should be applied when using the depth of field effect
  128373. */
  128374. export enum DepthOfFieldEffectBlurLevel {
  128375. /**
  128376. * Subtle blur
  128377. */
  128378. Low = 0,
  128379. /**
  128380. * Medium blur
  128381. */
  128382. Medium = 1,
  128383. /**
  128384. * Large blur
  128385. */
  128386. High = 2
  128387. }
  128388. /**
  128389. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128390. */
  128391. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128392. private _circleOfConfusion;
  128393. /**
  128394. * @hidden Internal, blurs from high to low
  128395. */
  128396. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128397. private _depthOfFieldBlurY;
  128398. private _dofMerge;
  128399. /**
  128400. * @hidden Internal post processes in depth of field effect
  128401. */
  128402. _effects: Array<PostProcess>;
  128403. /**
  128404. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128405. */
  128406. focalLength: number;
  128407. /**
  128408. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128409. */
  128410. fStop: number;
  128411. /**
  128412. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128413. */
  128414. focusDistance: number;
  128415. /**
  128416. * 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.
  128417. */
  128418. lensSize: number;
  128419. /**
  128420. * Creates a new instance DepthOfFieldEffect
  128421. * @param scene The scene the effect belongs to.
  128422. * @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.
  128423. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128424. * @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)
  128425. */
  128426. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128427. /**
  128428. * Get the current class name of the current effet
  128429. * @returns "DepthOfFieldEffect"
  128430. */
  128431. getClassName(): string;
  128432. /**
  128433. * 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.
  128434. */
  128435. depthTexture: RenderTargetTexture;
  128436. /**
  128437. * Disposes each of the internal effects for a given camera.
  128438. * @param camera The camera to dispose the effect on.
  128439. */
  128440. disposeEffects(camera: Camera): void;
  128441. /**
  128442. * @hidden Internal
  128443. */
  128444. _updateEffects(): void;
  128445. /**
  128446. * Internal
  128447. * @returns if all the contained post processes are ready.
  128448. * @hidden
  128449. */
  128450. _isReady(): boolean;
  128451. }
  128452. }
  128453. declare module BABYLON {
  128454. /** @hidden */
  128455. export var displayPassPixelShader: {
  128456. name: string;
  128457. shader: string;
  128458. };
  128459. }
  128460. declare module BABYLON {
  128461. /**
  128462. * DisplayPassPostProcess which produces an output the same as it's input
  128463. */
  128464. export class DisplayPassPostProcess extends PostProcess {
  128465. /**
  128466. * Creates the DisplayPassPostProcess
  128467. * @param name The name of the effect.
  128468. * @param options The required width/height ratio to downsize to before computing the render pass.
  128469. * @param camera The camera to apply the render pass to.
  128470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128471. * @param engine The engine which the post process will be applied. (default: current engine)
  128472. * @param reusable If the post process can be reused on the same frame. (default: false)
  128473. */
  128474. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128475. }
  128476. }
  128477. declare module BABYLON {
  128478. /** @hidden */
  128479. export var filterPixelShader: {
  128480. name: string;
  128481. shader: string;
  128482. };
  128483. }
  128484. declare module BABYLON {
  128485. /**
  128486. * Applies a kernel filter to the image
  128487. */
  128488. export class FilterPostProcess extends PostProcess {
  128489. /** The matrix to be applied to the image */
  128490. kernelMatrix: Matrix;
  128491. /**
  128492. *
  128493. * @param name The name of the effect.
  128494. * @param kernelMatrix The matrix to be applied to the image
  128495. * @param options The required width/height ratio to downsize to before computing the render pass.
  128496. * @param camera The camera to apply the render pass to.
  128497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128498. * @param engine The engine which the post process will be applied. (default: current engine)
  128499. * @param reusable If the post process can be reused on the same frame. (default: false)
  128500. */
  128501. constructor(name: string,
  128502. /** The matrix to be applied to the image */
  128503. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128504. }
  128505. }
  128506. declare module BABYLON {
  128507. /** @hidden */
  128508. export var fxaaPixelShader: {
  128509. name: string;
  128510. shader: string;
  128511. };
  128512. }
  128513. declare module BABYLON {
  128514. /** @hidden */
  128515. export var fxaaVertexShader: {
  128516. name: string;
  128517. shader: string;
  128518. };
  128519. }
  128520. declare module BABYLON {
  128521. /**
  128522. * Fxaa post process
  128523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128524. */
  128525. export class FxaaPostProcess extends PostProcess {
  128526. /** @hidden */
  128527. texelWidth: number;
  128528. /** @hidden */
  128529. texelHeight: number;
  128530. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128531. private _getDefines;
  128532. }
  128533. }
  128534. declare module BABYLON {
  128535. /** @hidden */
  128536. export var grainPixelShader: {
  128537. name: string;
  128538. shader: string;
  128539. };
  128540. }
  128541. declare module BABYLON {
  128542. /**
  128543. * The GrainPostProcess adds noise to the image at mid luminance levels
  128544. */
  128545. export class GrainPostProcess extends PostProcess {
  128546. /**
  128547. * The intensity of the grain added (default: 30)
  128548. */
  128549. intensity: number;
  128550. /**
  128551. * If the grain should be randomized on every frame
  128552. */
  128553. animated: boolean;
  128554. /**
  128555. * Creates a new instance of @see GrainPostProcess
  128556. * @param name The name of the effect.
  128557. * @param options The required width/height ratio to downsize to before computing the render pass.
  128558. * @param camera The camera to apply the render pass to.
  128559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128560. * @param engine The engine which the post process will be applied. (default: current engine)
  128561. * @param reusable If the post process can be reused on the same frame. (default: false)
  128562. * @param textureType Type of textures used when performing the post process. (default: 0)
  128563. * @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)
  128564. */
  128565. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128566. }
  128567. }
  128568. declare module BABYLON {
  128569. /** @hidden */
  128570. export var highlightsPixelShader: {
  128571. name: string;
  128572. shader: string;
  128573. };
  128574. }
  128575. declare module BABYLON {
  128576. /**
  128577. * Extracts highlights from the image
  128578. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128579. */
  128580. export class HighlightsPostProcess extends PostProcess {
  128581. /**
  128582. * Extracts highlights from the image
  128583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128584. * @param name The name of the effect.
  128585. * @param options The required width/height ratio to downsize to before computing the render pass.
  128586. * @param camera The camera to apply the render pass to.
  128587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128588. * @param engine The engine which the post process will be applied. (default: current engine)
  128589. * @param reusable If the post process can be reused on the same frame. (default: false)
  128590. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128591. */
  128592. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128593. }
  128594. }
  128595. declare module BABYLON {
  128596. /** @hidden */
  128597. export var mrtFragmentDeclaration: {
  128598. name: string;
  128599. shader: string;
  128600. };
  128601. }
  128602. declare module BABYLON {
  128603. /** @hidden */
  128604. export var geometryPixelShader: {
  128605. name: string;
  128606. shader: string;
  128607. };
  128608. }
  128609. declare module BABYLON {
  128610. /** @hidden */
  128611. export var geometryVertexShader: {
  128612. name: string;
  128613. shader: string;
  128614. };
  128615. }
  128616. declare module BABYLON {
  128617. /** @hidden */
  128618. interface ISavedTransformationMatrix {
  128619. world: Matrix;
  128620. viewProjection: Matrix;
  128621. }
  128622. /**
  128623. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128624. */
  128625. export class GeometryBufferRenderer {
  128626. /**
  128627. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128628. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128629. */
  128630. static readonly POSITION_TEXTURE_TYPE: number;
  128631. /**
  128632. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128633. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128634. */
  128635. static readonly VELOCITY_TEXTURE_TYPE: number;
  128636. /**
  128637. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128638. * in order to compute objects velocities when enableVelocity is set to "true"
  128639. * @hidden
  128640. */
  128641. _previousTransformationMatrices: {
  128642. [index: number]: ISavedTransformationMatrix;
  128643. };
  128644. /**
  128645. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128646. * in order to compute objects velocities when enableVelocity is set to "true"
  128647. * @hidden
  128648. */
  128649. _previousBonesTransformationMatrices: {
  128650. [index: number]: Float32Array;
  128651. };
  128652. /**
  128653. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128654. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128655. */
  128656. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128657. private _scene;
  128658. private _multiRenderTarget;
  128659. private _ratio;
  128660. private _enablePosition;
  128661. private _enableVelocity;
  128662. private _positionIndex;
  128663. private _velocityIndex;
  128664. protected _effect: Effect;
  128665. protected _cachedDefines: string;
  128666. /**
  128667. * Set the render list (meshes to be rendered) used in the G buffer.
  128668. */
  128669. renderList: Mesh[];
  128670. /**
  128671. * Gets wether or not G buffer are supported by the running hardware.
  128672. * This requires draw buffer supports
  128673. */
  128674. readonly isSupported: boolean;
  128675. /**
  128676. * Returns the index of the given texture type in the G-Buffer textures array
  128677. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128678. * @returns the index of the given texture type in the G-Buffer textures array
  128679. */
  128680. getTextureIndex(textureType: number): number;
  128681. /**
  128682. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128683. */
  128684. /**
  128685. * Sets whether or not objects positions are enabled for the G buffer.
  128686. */
  128687. enablePosition: boolean;
  128688. /**
  128689. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128690. */
  128691. /**
  128692. * Sets wether or not objects velocities are enabled for the G buffer.
  128693. */
  128694. enableVelocity: boolean;
  128695. /**
  128696. * Gets the scene associated with the buffer.
  128697. */
  128698. readonly scene: Scene;
  128699. /**
  128700. * Gets the ratio used by the buffer during its creation.
  128701. * How big is the buffer related to the main canvas.
  128702. */
  128703. readonly ratio: number;
  128704. /** @hidden */
  128705. static _SceneComponentInitialization: (scene: Scene) => void;
  128706. /**
  128707. * Creates a new G Buffer for the scene
  128708. * @param scene The scene the buffer belongs to
  128709. * @param ratio How big is the buffer related to the main canvas.
  128710. */
  128711. constructor(scene: Scene, ratio?: number);
  128712. /**
  128713. * Checks wether everything is ready to render a submesh to the G buffer.
  128714. * @param subMesh the submesh to check readiness for
  128715. * @param useInstances is the mesh drawn using instance or not
  128716. * @returns true if ready otherwise false
  128717. */
  128718. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128719. /**
  128720. * Gets the current underlying G Buffer.
  128721. * @returns the buffer
  128722. */
  128723. getGBuffer(): MultiRenderTarget;
  128724. /**
  128725. * Gets the number of samples used to render the buffer (anti aliasing).
  128726. */
  128727. /**
  128728. * Sets the number of samples used to render the buffer (anti aliasing).
  128729. */
  128730. samples: number;
  128731. /**
  128732. * Disposes the renderer and frees up associated resources.
  128733. */
  128734. dispose(): void;
  128735. protected _createRenderTargets(): void;
  128736. private _copyBonesTransformationMatrices;
  128737. }
  128738. }
  128739. declare module BABYLON {
  128740. interface Scene {
  128741. /** @hidden (Backing field) */
  128742. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128743. /**
  128744. * Gets or Sets the current geometry buffer associated to the scene.
  128745. */
  128746. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128747. /**
  128748. * Enables a GeometryBufferRender and associates it with the scene
  128749. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128750. * @returns the GeometryBufferRenderer
  128751. */
  128752. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128753. /**
  128754. * Disables the GeometryBufferRender associated with the scene
  128755. */
  128756. disableGeometryBufferRenderer(): void;
  128757. }
  128758. /**
  128759. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128760. * in several rendering techniques.
  128761. */
  128762. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128763. /**
  128764. * The component name helpful to identify the component in the list of scene components.
  128765. */
  128766. readonly name: string;
  128767. /**
  128768. * The scene the component belongs to.
  128769. */
  128770. scene: Scene;
  128771. /**
  128772. * Creates a new instance of the component for the given scene
  128773. * @param scene Defines the scene to register the component in
  128774. */
  128775. constructor(scene: Scene);
  128776. /**
  128777. * Registers the component in a given scene
  128778. */
  128779. register(): void;
  128780. /**
  128781. * Rebuilds the elements related to this component in case of
  128782. * context lost for instance.
  128783. */
  128784. rebuild(): void;
  128785. /**
  128786. * Disposes the component and the associated ressources
  128787. */
  128788. dispose(): void;
  128789. private _gatherRenderTargets;
  128790. }
  128791. }
  128792. declare module BABYLON {
  128793. /** @hidden */
  128794. export var motionBlurPixelShader: {
  128795. name: string;
  128796. shader: string;
  128797. };
  128798. }
  128799. declare module BABYLON {
  128800. /**
  128801. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128802. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128803. * As an example, all you have to do is to create the post-process:
  128804. * var mb = new BABYLON.MotionBlurPostProcess(
  128805. * 'mb', // The name of the effect.
  128806. * scene, // The scene containing the objects to blur according to their velocity.
  128807. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128808. * camera // The camera to apply the render pass to.
  128809. * );
  128810. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128811. */
  128812. export class MotionBlurPostProcess extends PostProcess {
  128813. /**
  128814. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128815. */
  128816. motionStrength: number;
  128817. /**
  128818. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128819. */
  128820. /**
  128821. * Sets the number of iterations to be used for motion blur quality
  128822. */
  128823. motionBlurSamples: number;
  128824. private _motionBlurSamples;
  128825. private _geometryBufferRenderer;
  128826. /**
  128827. * Creates a new instance MotionBlurPostProcess
  128828. * @param name The name of the effect.
  128829. * @param scene The scene containing the objects to blur according to their velocity.
  128830. * @param options The required width/height ratio to downsize to before computing the render pass.
  128831. * @param camera The camera to apply the render pass to.
  128832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128833. * @param engine The engine which the post process will be applied. (default: current engine)
  128834. * @param reusable If the post process can be reused on the same frame. (default: false)
  128835. * @param textureType Type of textures used when performing the post process. (default: 0)
  128836. * @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)
  128837. */
  128838. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128839. /**
  128840. * Excludes the given skinned mesh from computing bones velocities.
  128841. * 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.
  128842. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128843. */
  128844. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128845. /**
  128846. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128847. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128848. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128849. */
  128850. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128851. /**
  128852. * Disposes the post process.
  128853. * @param camera The camera to dispose the post process on.
  128854. */
  128855. dispose(camera?: Camera): void;
  128856. }
  128857. }
  128858. declare module BABYLON {
  128859. /** @hidden */
  128860. export var refractionPixelShader: {
  128861. name: string;
  128862. shader: string;
  128863. };
  128864. }
  128865. declare module BABYLON {
  128866. /**
  128867. * Post process which applies a refractin texture
  128868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128869. */
  128870. export class RefractionPostProcess extends PostProcess {
  128871. /** the base color of the refraction (used to taint the rendering) */
  128872. color: Color3;
  128873. /** simulated refraction depth */
  128874. depth: number;
  128875. /** the coefficient of the base color (0 to remove base color tainting) */
  128876. colorLevel: number;
  128877. private _refTexture;
  128878. private _ownRefractionTexture;
  128879. /**
  128880. * Gets or sets the refraction texture
  128881. * Please note that you are responsible for disposing the texture if you set it manually
  128882. */
  128883. refractionTexture: Texture;
  128884. /**
  128885. * Initializes the RefractionPostProcess
  128886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128887. * @param name The name of the effect.
  128888. * @param refractionTextureUrl Url of the refraction texture to use
  128889. * @param color the base color of the refraction (used to taint the rendering)
  128890. * @param depth simulated refraction depth
  128891. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128892. * @param camera The camera to apply the render pass to.
  128893. * @param options The required width/height ratio to downsize to before computing the render pass.
  128894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128895. * @param engine The engine which the post process will be applied. (default: current engine)
  128896. * @param reusable If the post process can be reused on the same frame. (default: false)
  128897. */
  128898. constructor(name: string, refractionTextureUrl: string,
  128899. /** the base color of the refraction (used to taint the rendering) */
  128900. color: Color3,
  128901. /** simulated refraction depth */
  128902. depth: number,
  128903. /** the coefficient of the base color (0 to remove base color tainting) */
  128904. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128905. /**
  128906. * Disposes of the post process
  128907. * @param camera Camera to dispose post process on
  128908. */
  128909. dispose(camera: Camera): void;
  128910. }
  128911. }
  128912. declare module BABYLON {
  128913. /** @hidden */
  128914. export var sharpenPixelShader: {
  128915. name: string;
  128916. shader: string;
  128917. };
  128918. }
  128919. declare module BABYLON {
  128920. /**
  128921. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128922. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128923. */
  128924. export class SharpenPostProcess extends PostProcess {
  128925. /**
  128926. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128927. */
  128928. colorAmount: number;
  128929. /**
  128930. * How much sharpness should be applied (default: 0.3)
  128931. */
  128932. edgeAmount: number;
  128933. /**
  128934. * Creates a new instance ConvolutionPostProcess
  128935. * @param name The name of the effect.
  128936. * @param options The required width/height ratio to downsize to before computing the render pass.
  128937. * @param camera The camera to apply the render pass to.
  128938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128939. * @param engine The engine which the post process will be applied. (default: current engine)
  128940. * @param reusable If the post process can be reused on the same frame. (default: false)
  128941. * @param textureType Type of textures used when performing the post process. (default: 0)
  128942. * @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)
  128943. */
  128944. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128945. }
  128946. }
  128947. declare module BABYLON {
  128948. /**
  128949. * PostProcessRenderPipeline
  128950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128951. */
  128952. export class PostProcessRenderPipeline {
  128953. private engine;
  128954. private _renderEffects;
  128955. private _renderEffectsForIsolatedPass;
  128956. /**
  128957. * List of inspectable custom properties (used by the Inspector)
  128958. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  128959. */
  128960. inspectableCustomProperties: IInspectable[];
  128961. /**
  128962. * @hidden
  128963. */
  128964. protected _cameras: Camera[];
  128965. /** @hidden */
  128966. _name: string;
  128967. /**
  128968. * Gets pipeline name
  128969. */
  128970. readonly name: string;
  128971. /** Gets the list of attached cameras */
  128972. readonly cameras: Camera[];
  128973. /**
  128974. * Initializes a PostProcessRenderPipeline
  128975. * @param engine engine to add the pipeline to
  128976. * @param name name of the pipeline
  128977. */
  128978. constructor(engine: Engine, name: string);
  128979. /**
  128980. * Gets the class name
  128981. * @returns "PostProcessRenderPipeline"
  128982. */
  128983. getClassName(): string;
  128984. /**
  128985. * If all the render effects in the pipeline are supported
  128986. */
  128987. readonly isSupported: boolean;
  128988. /**
  128989. * Adds an effect to the pipeline
  128990. * @param renderEffect the effect to add
  128991. */
  128992. addEffect(renderEffect: PostProcessRenderEffect): void;
  128993. /** @hidden */
  128994. _rebuild(): void;
  128995. /** @hidden */
  128996. _enableEffect(renderEffectName: string, cameras: Camera): void;
  128997. /** @hidden */
  128998. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  128999. /** @hidden */
  129000. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129001. /** @hidden */
  129002. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129003. /** @hidden */
  129004. _attachCameras(cameras: Camera, unique: boolean): void;
  129005. /** @hidden */
  129006. _attachCameras(cameras: Camera[], unique: boolean): void;
  129007. /** @hidden */
  129008. _detachCameras(cameras: Camera): void;
  129009. /** @hidden */
  129010. _detachCameras(cameras: Nullable<Camera[]>): void;
  129011. /** @hidden */
  129012. _update(): void;
  129013. /** @hidden */
  129014. _reset(): void;
  129015. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129016. /**
  129017. * Disposes of the pipeline
  129018. */
  129019. dispose(): void;
  129020. }
  129021. }
  129022. declare module BABYLON {
  129023. /**
  129024. * PostProcessRenderPipelineManager class
  129025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129026. */
  129027. export class PostProcessRenderPipelineManager {
  129028. private _renderPipelines;
  129029. /**
  129030. * Initializes a PostProcessRenderPipelineManager
  129031. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129032. */
  129033. constructor();
  129034. /**
  129035. * Gets the list of supported render pipelines
  129036. */
  129037. readonly supportedPipelines: PostProcessRenderPipeline[];
  129038. /**
  129039. * Adds a pipeline to the manager
  129040. * @param renderPipeline The pipeline to add
  129041. */
  129042. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129043. /**
  129044. * Attaches a camera to the pipeline
  129045. * @param renderPipelineName The name of the pipeline to attach to
  129046. * @param cameras the camera to attach
  129047. * @param unique if the camera can be attached multiple times to the pipeline
  129048. */
  129049. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129050. /**
  129051. * Detaches a camera from the pipeline
  129052. * @param renderPipelineName The name of the pipeline to detach from
  129053. * @param cameras the camera to detach
  129054. */
  129055. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129056. /**
  129057. * Enables an effect by name on a pipeline
  129058. * @param renderPipelineName the name of the pipeline to enable the effect in
  129059. * @param renderEffectName the name of the effect to enable
  129060. * @param cameras the cameras that the effect should be enabled on
  129061. */
  129062. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129063. /**
  129064. * Disables an effect by name on a pipeline
  129065. * @param renderPipelineName the name of the pipeline to disable the effect in
  129066. * @param renderEffectName the name of the effect to disable
  129067. * @param cameras the cameras that the effect should be disabled on
  129068. */
  129069. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129070. /**
  129071. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129072. */
  129073. update(): void;
  129074. /** @hidden */
  129075. _rebuild(): void;
  129076. /**
  129077. * Disposes of the manager and pipelines
  129078. */
  129079. dispose(): void;
  129080. }
  129081. }
  129082. declare module BABYLON {
  129083. interface Scene {
  129084. /** @hidden (Backing field) */
  129085. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129086. /**
  129087. * Gets the postprocess render pipeline manager
  129088. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129089. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129090. */
  129091. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129092. }
  129093. /**
  129094. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129095. */
  129096. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129097. /**
  129098. * The component name helpfull to identify the component in the list of scene components.
  129099. */
  129100. readonly name: string;
  129101. /**
  129102. * The scene the component belongs to.
  129103. */
  129104. scene: Scene;
  129105. /**
  129106. * Creates a new instance of the component for the given scene
  129107. * @param scene Defines the scene to register the component in
  129108. */
  129109. constructor(scene: Scene);
  129110. /**
  129111. * Registers the component in a given scene
  129112. */
  129113. register(): void;
  129114. /**
  129115. * Rebuilds the elements related to this component in case of
  129116. * context lost for instance.
  129117. */
  129118. rebuild(): void;
  129119. /**
  129120. * Disposes the component and the associated ressources
  129121. */
  129122. dispose(): void;
  129123. private _gatherRenderTargets;
  129124. }
  129125. }
  129126. declare module BABYLON {
  129127. /**
  129128. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129129. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129130. */
  129131. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129132. private _scene;
  129133. private _camerasToBeAttached;
  129134. /**
  129135. * ID of the sharpen post process,
  129136. */
  129137. private readonly SharpenPostProcessId;
  129138. /**
  129139. * @ignore
  129140. * ID of the image processing post process;
  129141. */
  129142. readonly ImageProcessingPostProcessId: string;
  129143. /**
  129144. * @ignore
  129145. * ID of the Fast Approximate Anti-Aliasing post process;
  129146. */
  129147. readonly FxaaPostProcessId: string;
  129148. /**
  129149. * ID of the chromatic aberration post process,
  129150. */
  129151. private readonly ChromaticAberrationPostProcessId;
  129152. /**
  129153. * ID of the grain post process
  129154. */
  129155. private readonly GrainPostProcessId;
  129156. /**
  129157. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129158. */
  129159. sharpen: SharpenPostProcess;
  129160. private _sharpenEffect;
  129161. private bloom;
  129162. /**
  129163. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129164. */
  129165. depthOfField: DepthOfFieldEffect;
  129166. /**
  129167. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129168. */
  129169. fxaa: FxaaPostProcess;
  129170. /**
  129171. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129172. */
  129173. imageProcessing: ImageProcessingPostProcess;
  129174. /**
  129175. * Chromatic aberration post process which will shift rgb colors in the image
  129176. */
  129177. chromaticAberration: ChromaticAberrationPostProcess;
  129178. private _chromaticAberrationEffect;
  129179. /**
  129180. * Grain post process which add noise to the image
  129181. */
  129182. grain: GrainPostProcess;
  129183. private _grainEffect;
  129184. /**
  129185. * Glow post process which adds a glow to emissive areas of the image
  129186. */
  129187. private _glowLayer;
  129188. /**
  129189. * Animations which can be used to tweak settings over a period of time
  129190. */
  129191. animations: Animation[];
  129192. private _imageProcessingConfigurationObserver;
  129193. private _sharpenEnabled;
  129194. private _bloomEnabled;
  129195. private _depthOfFieldEnabled;
  129196. private _depthOfFieldBlurLevel;
  129197. private _fxaaEnabled;
  129198. private _imageProcessingEnabled;
  129199. private _defaultPipelineTextureType;
  129200. private _bloomScale;
  129201. private _chromaticAberrationEnabled;
  129202. private _grainEnabled;
  129203. private _buildAllowed;
  129204. /**
  129205. * Gets active scene
  129206. */
  129207. readonly scene: Scene;
  129208. /**
  129209. * Enable or disable the sharpen process from the pipeline
  129210. */
  129211. sharpenEnabled: boolean;
  129212. private _resizeObserver;
  129213. private _hardwareScaleLevel;
  129214. private _bloomKernel;
  129215. /**
  129216. * Specifies the size of the bloom blur kernel, relative to the final output size
  129217. */
  129218. bloomKernel: number;
  129219. /**
  129220. * Specifies the weight of the bloom in the final rendering
  129221. */
  129222. private _bloomWeight;
  129223. /**
  129224. * Specifies the luma threshold for the area that will be blurred by the bloom
  129225. */
  129226. private _bloomThreshold;
  129227. private _hdr;
  129228. /**
  129229. * The strength of the bloom.
  129230. */
  129231. bloomWeight: number;
  129232. /**
  129233. * The strength of the bloom.
  129234. */
  129235. bloomThreshold: number;
  129236. /**
  129237. * The scale of the bloom, lower value will provide better performance.
  129238. */
  129239. bloomScale: number;
  129240. /**
  129241. * Enable or disable the bloom from the pipeline
  129242. */
  129243. bloomEnabled: boolean;
  129244. private _rebuildBloom;
  129245. /**
  129246. * If the depth of field is enabled.
  129247. */
  129248. depthOfFieldEnabled: boolean;
  129249. /**
  129250. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129251. */
  129252. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129253. /**
  129254. * If the anti aliasing is enabled.
  129255. */
  129256. fxaaEnabled: boolean;
  129257. private _samples;
  129258. /**
  129259. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129260. */
  129261. samples: number;
  129262. /**
  129263. * If image processing is enabled.
  129264. */
  129265. imageProcessingEnabled: boolean;
  129266. /**
  129267. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129268. */
  129269. glowLayerEnabled: boolean;
  129270. /**
  129271. * Gets the glow layer (or null if not defined)
  129272. */
  129273. readonly glowLayer: Nullable<GlowLayer>;
  129274. /**
  129275. * Enable or disable the chromaticAberration process from the pipeline
  129276. */
  129277. chromaticAberrationEnabled: boolean;
  129278. /**
  129279. * Enable or disable the grain process from the pipeline
  129280. */
  129281. grainEnabled: boolean;
  129282. /**
  129283. * @constructor
  129284. * @param name - The rendering pipeline name (default: "")
  129285. * @param hdr - If high dynamic range textures should be used (default: true)
  129286. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129287. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129288. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129289. */
  129290. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129291. /**
  129292. * Get the class name
  129293. * @returns "DefaultRenderingPipeline"
  129294. */
  129295. getClassName(): string;
  129296. /**
  129297. * Force the compilation of the entire pipeline.
  129298. */
  129299. prepare(): void;
  129300. private _hasCleared;
  129301. private _prevPostProcess;
  129302. private _prevPrevPostProcess;
  129303. private _setAutoClearAndTextureSharing;
  129304. private _depthOfFieldSceneObserver;
  129305. private _buildPipeline;
  129306. private _disposePostProcesses;
  129307. /**
  129308. * Adds a camera to the pipeline
  129309. * @param camera the camera to be added
  129310. */
  129311. addCamera(camera: Camera): void;
  129312. /**
  129313. * Removes a camera from the pipeline
  129314. * @param camera the camera to remove
  129315. */
  129316. removeCamera(camera: Camera): void;
  129317. /**
  129318. * Dispose of the pipeline and stop all post processes
  129319. */
  129320. dispose(): void;
  129321. /**
  129322. * Serialize the rendering pipeline (Used when exporting)
  129323. * @returns the serialized object
  129324. */
  129325. serialize(): any;
  129326. /**
  129327. * Parse the serialized pipeline
  129328. * @param source Source pipeline.
  129329. * @param scene The scene to load the pipeline to.
  129330. * @param rootUrl The URL of the serialized pipeline.
  129331. * @returns An instantiated pipeline from the serialized object.
  129332. */
  129333. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129334. }
  129335. }
  129336. declare module BABYLON {
  129337. /** @hidden */
  129338. export var lensHighlightsPixelShader: {
  129339. name: string;
  129340. shader: string;
  129341. };
  129342. }
  129343. declare module BABYLON {
  129344. /** @hidden */
  129345. export var depthOfFieldPixelShader: {
  129346. name: string;
  129347. shader: string;
  129348. };
  129349. }
  129350. declare module BABYLON {
  129351. /**
  129352. * BABYLON.JS Chromatic Aberration GLSL Shader
  129353. * Author: Olivier Guyot
  129354. * Separates very slightly R, G and B colors on the edges of the screen
  129355. * Inspired by Francois Tarlier & Martins Upitis
  129356. */
  129357. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129358. /**
  129359. * @ignore
  129360. * The chromatic aberration PostProcess id in the pipeline
  129361. */
  129362. LensChromaticAberrationEffect: string;
  129363. /**
  129364. * @ignore
  129365. * The highlights enhancing PostProcess id in the pipeline
  129366. */
  129367. HighlightsEnhancingEffect: string;
  129368. /**
  129369. * @ignore
  129370. * The depth-of-field PostProcess id in the pipeline
  129371. */
  129372. LensDepthOfFieldEffect: string;
  129373. private _scene;
  129374. private _depthTexture;
  129375. private _grainTexture;
  129376. private _chromaticAberrationPostProcess;
  129377. private _highlightsPostProcess;
  129378. private _depthOfFieldPostProcess;
  129379. private _edgeBlur;
  129380. private _grainAmount;
  129381. private _chromaticAberration;
  129382. private _distortion;
  129383. private _highlightsGain;
  129384. private _highlightsThreshold;
  129385. private _dofDistance;
  129386. private _dofAperture;
  129387. private _dofDarken;
  129388. private _dofPentagon;
  129389. private _blurNoise;
  129390. /**
  129391. * @constructor
  129392. *
  129393. * Effect parameters are as follow:
  129394. * {
  129395. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129396. * edge_blur: number; // from 0 to x (1 for realism)
  129397. * distortion: number; // from 0 to x (1 for realism)
  129398. * grain_amount: number; // from 0 to 1
  129399. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129400. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129401. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129402. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129403. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129404. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129405. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129406. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129407. * }
  129408. * Note: if an effect parameter is unset, effect is disabled
  129409. *
  129410. * @param name The rendering pipeline name
  129411. * @param parameters - An object containing all parameters (see above)
  129412. * @param scene The scene linked to this pipeline
  129413. * @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)
  129414. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129415. */
  129416. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129417. /**
  129418. * Get the class name
  129419. * @returns "LensRenderingPipeline"
  129420. */
  129421. getClassName(): string;
  129422. /**
  129423. * Gets associated scene
  129424. */
  129425. readonly scene: Scene;
  129426. /**
  129427. * Gets or sets the edge blur
  129428. */
  129429. edgeBlur: number;
  129430. /**
  129431. * Gets or sets the grain amount
  129432. */
  129433. grainAmount: number;
  129434. /**
  129435. * Gets or sets the chromatic aberration amount
  129436. */
  129437. chromaticAberration: number;
  129438. /**
  129439. * Gets or sets the depth of field aperture
  129440. */
  129441. dofAperture: number;
  129442. /**
  129443. * Gets or sets the edge distortion
  129444. */
  129445. edgeDistortion: number;
  129446. /**
  129447. * Gets or sets the depth of field distortion
  129448. */
  129449. dofDistortion: number;
  129450. /**
  129451. * Gets or sets the darken out of focus amount
  129452. */
  129453. darkenOutOfFocus: number;
  129454. /**
  129455. * Gets or sets a boolean indicating if blur noise is enabled
  129456. */
  129457. blurNoise: boolean;
  129458. /**
  129459. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129460. */
  129461. pentagonBokeh: boolean;
  129462. /**
  129463. * Gets or sets the highlight grain amount
  129464. */
  129465. highlightsGain: number;
  129466. /**
  129467. * Gets or sets the highlight threshold
  129468. */
  129469. highlightsThreshold: number;
  129470. /**
  129471. * Sets the amount of blur at the edges
  129472. * @param amount blur amount
  129473. */
  129474. setEdgeBlur(amount: number): void;
  129475. /**
  129476. * Sets edge blur to 0
  129477. */
  129478. disableEdgeBlur(): void;
  129479. /**
  129480. * Sets the amout of grain
  129481. * @param amount Amount of grain
  129482. */
  129483. setGrainAmount(amount: number): void;
  129484. /**
  129485. * Set grain amount to 0
  129486. */
  129487. disableGrain(): void;
  129488. /**
  129489. * Sets the chromatic aberration amount
  129490. * @param amount amount of chromatic aberration
  129491. */
  129492. setChromaticAberration(amount: number): void;
  129493. /**
  129494. * Sets chromatic aberration amount to 0
  129495. */
  129496. disableChromaticAberration(): void;
  129497. /**
  129498. * Sets the EdgeDistortion amount
  129499. * @param amount amount of EdgeDistortion
  129500. */
  129501. setEdgeDistortion(amount: number): void;
  129502. /**
  129503. * Sets edge distortion to 0
  129504. */
  129505. disableEdgeDistortion(): void;
  129506. /**
  129507. * Sets the FocusDistance amount
  129508. * @param amount amount of FocusDistance
  129509. */
  129510. setFocusDistance(amount: number): void;
  129511. /**
  129512. * Disables depth of field
  129513. */
  129514. disableDepthOfField(): void;
  129515. /**
  129516. * Sets the Aperture amount
  129517. * @param amount amount of Aperture
  129518. */
  129519. setAperture(amount: number): void;
  129520. /**
  129521. * Sets the DarkenOutOfFocus amount
  129522. * @param amount amount of DarkenOutOfFocus
  129523. */
  129524. setDarkenOutOfFocus(amount: number): void;
  129525. private _pentagonBokehIsEnabled;
  129526. /**
  129527. * Creates a pentagon bokeh effect
  129528. */
  129529. enablePentagonBokeh(): void;
  129530. /**
  129531. * Disables the pentagon bokeh effect
  129532. */
  129533. disablePentagonBokeh(): void;
  129534. /**
  129535. * Enables noise blur
  129536. */
  129537. enableNoiseBlur(): void;
  129538. /**
  129539. * Disables noise blur
  129540. */
  129541. disableNoiseBlur(): void;
  129542. /**
  129543. * Sets the HighlightsGain amount
  129544. * @param amount amount of HighlightsGain
  129545. */
  129546. setHighlightsGain(amount: number): void;
  129547. /**
  129548. * Sets the HighlightsThreshold amount
  129549. * @param amount amount of HighlightsThreshold
  129550. */
  129551. setHighlightsThreshold(amount: number): void;
  129552. /**
  129553. * Disables highlights
  129554. */
  129555. disableHighlights(): void;
  129556. /**
  129557. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129558. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129559. */
  129560. dispose(disableDepthRender?: boolean): void;
  129561. private _createChromaticAberrationPostProcess;
  129562. private _createHighlightsPostProcess;
  129563. private _createDepthOfFieldPostProcess;
  129564. private _createGrainTexture;
  129565. }
  129566. }
  129567. declare module BABYLON {
  129568. /** @hidden */
  129569. export var ssao2PixelShader: {
  129570. name: string;
  129571. shader: string;
  129572. };
  129573. }
  129574. declare module BABYLON {
  129575. /** @hidden */
  129576. export var ssaoCombinePixelShader: {
  129577. name: string;
  129578. shader: string;
  129579. };
  129580. }
  129581. declare module BABYLON {
  129582. /**
  129583. * Render pipeline to produce ssao effect
  129584. */
  129585. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129586. /**
  129587. * @ignore
  129588. * The PassPostProcess id in the pipeline that contains the original scene color
  129589. */
  129590. SSAOOriginalSceneColorEffect: string;
  129591. /**
  129592. * @ignore
  129593. * The SSAO PostProcess id in the pipeline
  129594. */
  129595. SSAORenderEffect: string;
  129596. /**
  129597. * @ignore
  129598. * The horizontal blur PostProcess id in the pipeline
  129599. */
  129600. SSAOBlurHRenderEffect: string;
  129601. /**
  129602. * @ignore
  129603. * The vertical blur PostProcess id in the pipeline
  129604. */
  129605. SSAOBlurVRenderEffect: string;
  129606. /**
  129607. * @ignore
  129608. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129609. */
  129610. SSAOCombineRenderEffect: string;
  129611. /**
  129612. * The output strength of the SSAO post-process. Default value is 1.0.
  129613. */
  129614. totalStrength: number;
  129615. /**
  129616. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129617. */
  129618. maxZ: number;
  129619. /**
  129620. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129621. */
  129622. minZAspect: number;
  129623. private _samples;
  129624. /**
  129625. * Number of samples used for the SSAO calculations. Default value is 8
  129626. */
  129627. samples: number;
  129628. private _textureSamples;
  129629. /**
  129630. * Number of samples to use for antialiasing
  129631. */
  129632. textureSamples: number;
  129633. /**
  129634. * Ratio object used for SSAO ratio and blur ratio
  129635. */
  129636. private _ratio;
  129637. /**
  129638. * Dynamically generated sphere sampler.
  129639. */
  129640. private _sampleSphere;
  129641. /**
  129642. * Blur filter offsets
  129643. */
  129644. private _samplerOffsets;
  129645. private _expensiveBlur;
  129646. /**
  129647. * If bilateral blur should be used
  129648. */
  129649. expensiveBlur: boolean;
  129650. /**
  129651. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129652. */
  129653. radius: number;
  129654. /**
  129655. * The base color of the SSAO post-process
  129656. * The final result is "base + ssao" between [0, 1]
  129657. */
  129658. base: number;
  129659. /**
  129660. * Support test.
  129661. */
  129662. static readonly IsSupported: boolean;
  129663. private _scene;
  129664. private _depthTexture;
  129665. private _normalTexture;
  129666. private _randomTexture;
  129667. private _originalColorPostProcess;
  129668. private _ssaoPostProcess;
  129669. private _blurHPostProcess;
  129670. private _blurVPostProcess;
  129671. private _ssaoCombinePostProcess;
  129672. private _firstUpdate;
  129673. /**
  129674. * Gets active scene
  129675. */
  129676. readonly scene: Scene;
  129677. /**
  129678. * @constructor
  129679. * @param name The rendering pipeline name
  129680. * @param scene The scene linked to this pipeline
  129681. * @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 }
  129682. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129683. */
  129684. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129685. /**
  129686. * Get the class name
  129687. * @returns "SSAO2RenderingPipeline"
  129688. */
  129689. getClassName(): string;
  129690. /**
  129691. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129692. */
  129693. dispose(disableGeometryBufferRenderer?: boolean): void;
  129694. private _createBlurPostProcess;
  129695. /** @hidden */
  129696. _rebuild(): void;
  129697. private _bits;
  129698. private _radicalInverse_VdC;
  129699. private _hammersley;
  129700. private _hemisphereSample_uniform;
  129701. private _generateHemisphere;
  129702. private _createSSAOPostProcess;
  129703. private _createSSAOCombinePostProcess;
  129704. private _createRandomTexture;
  129705. /**
  129706. * Serialize the rendering pipeline (Used when exporting)
  129707. * @returns the serialized object
  129708. */
  129709. serialize(): any;
  129710. /**
  129711. * Parse the serialized pipeline
  129712. * @param source Source pipeline.
  129713. * @param scene The scene to load the pipeline to.
  129714. * @param rootUrl The URL of the serialized pipeline.
  129715. * @returns An instantiated pipeline from the serialized object.
  129716. */
  129717. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129718. }
  129719. }
  129720. declare module BABYLON {
  129721. /** @hidden */
  129722. export var ssaoPixelShader: {
  129723. name: string;
  129724. shader: string;
  129725. };
  129726. }
  129727. declare module BABYLON {
  129728. /**
  129729. * Render pipeline to produce ssao effect
  129730. */
  129731. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129732. /**
  129733. * @ignore
  129734. * The PassPostProcess id in the pipeline that contains the original scene color
  129735. */
  129736. SSAOOriginalSceneColorEffect: string;
  129737. /**
  129738. * @ignore
  129739. * The SSAO PostProcess id in the pipeline
  129740. */
  129741. SSAORenderEffect: string;
  129742. /**
  129743. * @ignore
  129744. * The horizontal blur PostProcess id in the pipeline
  129745. */
  129746. SSAOBlurHRenderEffect: string;
  129747. /**
  129748. * @ignore
  129749. * The vertical blur PostProcess id in the pipeline
  129750. */
  129751. SSAOBlurVRenderEffect: string;
  129752. /**
  129753. * @ignore
  129754. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129755. */
  129756. SSAOCombineRenderEffect: string;
  129757. /**
  129758. * The output strength of the SSAO post-process. Default value is 1.0.
  129759. */
  129760. totalStrength: number;
  129761. /**
  129762. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129763. */
  129764. radius: number;
  129765. /**
  129766. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129767. * Must not be equal to fallOff and superior to fallOff.
  129768. * Default value is 0.0075
  129769. */
  129770. area: number;
  129771. /**
  129772. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129773. * Must not be equal to area and inferior to area.
  129774. * Default value is 0.000001
  129775. */
  129776. fallOff: number;
  129777. /**
  129778. * The base color of the SSAO post-process
  129779. * The final result is "base + ssao" between [0, 1]
  129780. */
  129781. base: number;
  129782. private _scene;
  129783. private _depthTexture;
  129784. private _randomTexture;
  129785. private _originalColorPostProcess;
  129786. private _ssaoPostProcess;
  129787. private _blurHPostProcess;
  129788. private _blurVPostProcess;
  129789. private _ssaoCombinePostProcess;
  129790. private _firstUpdate;
  129791. /**
  129792. * Gets active scene
  129793. */
  129794. readonly scene: Scene;
  129795. /**
  129796. * @constructor
  129797. * @param name - The rendering pipeline name
  129798. * @param scene - The scene linked to this pipeline
  129799. * @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 }
  129800. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129801. */
  129802. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129803. /**
  129804. * Get the class name
  129805. * @returns "SSAORenderingPipeline"
  129806. */
  129807. getClassName(): string;
  129808. /**
  129809. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129810. */
  129811. dispose(disableDepthRender?: boolean): void;
  129812. private _createBlurPostProcess;
  129813. /** @hidden */
  129814. _rebuild(): void;
  129815. private _createSSAOPostProcess;
  129816. private _createSSAOCombinePostProcess;
  129817. private _createRandomTexture;
  129818. }
  129819. }
  129820. declare module BABYLON {
  129821. /** @hidden */
  129822. export var standardPixelShader: {
  129823. name: string;
  129824. shader: string;
  129825. };
  129826. }
  129827. declare module BABYLON {
  129828. /**
  129829. * Standard rendering pipeline
  129830. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129831. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129832. */
  129833. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129834. /**
  129835. * Public members
  129836. */
  129837. /**
  129838. * Post-process which contains the original scene color before the pipeline applies all the effects
  129839. */
  129840. originalPostProcess: Nullable<PostProcess>;
  129841. /**
  129842. * Post-process used to down scale an image x4
  129843. */
  129844. downSampleX4PostProcess: Nullable<PostProcess>;
  129845. /**
  129846. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129847. */
  129848. brightPassPostProcess: Nullable<PostProcess>;
  129849. /**
  129850. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129851. */
  129852. blurHPostProcesses: PostProcess[];
  129853. /**
  129854. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129855. */
  129856. blurVPostProcesses: PostProcess[];
  129857. /**
  129858. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129859. */
  129860. textureAdderPostProcess: Nullable<PostProcess>;
  129861. /**
  129862. * Post-process used to create volumetric lighting effect
  129863. */
  129864. volumetricLightPostProcess: Nullable<PostProcess>;
  129865. /**
  129866. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129867. */
  129868. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129869. /**
  129870. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129871. */
  129872. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129873. /**
  129874. * Post-process used to merge the volumetric light effect and the real scene color
  129875. */
  129876. volumetricLightMergePostProces: Nullable<PostProcess>;
  129877. /**
  129878. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129879. */
  129880. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129881. /**
  129882. * Base post-process used to calculate the average luminance of the final image for HDR
  129883. */
  129884. luminancePostProcess: Nullable<PostProcess>;
  129885. /**
  129886. * Post-processes used to create down sample post-processes in order to get
  129887. * the average luminance of the final image for HDR
  129888. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129889. */
  129890. luminanceDownSamplePostProcesses: PostProcess[];
  129891. /**
  129892. * Post-process used to create a HDR effect (light adaptation)
  129893. */
  129894. hdrPostProcess: Nullable<PostProcess>;
  129895. /**
  129896. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129897. */
  129898. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129899. /**
  129900. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129901. */
  129902. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129903. /**
  129904. * Post-process used to merge the final HDR post-process and the real scene color
  129905. */
  129906. hdrFinalPostProcess: Nullable<PostProcess>;
  129907. /**
  129908. * Post-process used to create a lens flare effect
  129909. */
  129910. lensFlarePostProcess: Nullable<PostProcess>;
  129911. /**
  129912. * Post-process that merges the result of the lens flare post-process and the real scene color
  129913. */
  129914. lensFlareComposePostProcess: Nullable<PostProcess>;
  129915. /**
  129916. * Post-process used to create a motion blur effect
  129917. */
  129918. motionBlurPostProcess: Nullable<PostProcess>;
  129919. /**
  129920. * Post-process used to create a depth of field effect
  129921. */
  129922. depthOfFieldPostProcess: Nullable<PostProcess>;
  129923. /**
  129924. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129925. */
  129926. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129927. /**
  129928. * Represents the brightness threshold in order to configure the illuminated surfaces
  129929. */
  129930. brightThreshold: number;
  129931. /**
  129932. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129933. */
  129934. blurWidth: number;
  129935. /**
  129936. * Sets if the blur for highlighted surfaces must be only horizontal
  129937. */
  129938. horizontalBlur: boolean;
  129939. /**
  129940. * Gets the overall exposure used by the pipeline
  129941. */
  129942. /**
  129943. * Sets the overall exposure used by the pipeline
  129944. */
  129945. exposure: number;
  129946. /**
  129947. * Texture used typically to simulate "dirty" on camera lens
  129948. */
  129949. lensTexture: Nullable<Texture>;
  129950. /**
  129951. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  129952. */
  129953. volumetricLightCoefficient: number;
  129954. /**
  129955. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  129956. */
  129957. volumetricLightPower: number;
  129958. /**
  129959. * Used the set the blur intensity to smooth the volumetric lights
  129960. */
  129961. volumetricLightBlurScale: number;
  129962. /**
  129963. * Light (spot or directional) used to generate the volumetric lights rays
  129964. * The source light must have a shadow generate so the pipeline can get its
  129965. * depth map
  129966. */
  129967. sourceLight: Nullable<SpotLight | DirectionalLight>;
  129968. /**
  129969. * For eye adaptation, represents the minimum luminance the eye can see
  129970. */
  129971. hdrMinimumLuminance: number;
  129972. /**
  129973. * For eye adaptation, represents the decrease luminance speed
  129974. */
  129975. hdrDecreaseRate: number;
  129976. /**
  129977. * For eye adaptation, represents the increase luminance speed
  129978. */
  129979. hdrIncreaseRate: number;
  129980. /**
  129981. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129982. */
  129983. /**
  129984. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129985. */
  129986. hdrAutoExposure: boolean;
  129987. /**
  129988. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  129989. */
  129990. lensColorTexture: Nullable<Texture>;
  129991. /**
  129992. * The overall strengh for the lens flare effect
  129993. */
  129994. lensFlareStrength: number;
  129995. /**
  129996. * Dispersion coefficient for lens flare ghosts
  129997. */
  129998. lensFlareGhostDispersal: number;
  129999. /**
  130000. * Main lens flare halo width
  130001. */
  130002. lensFlareHaloWidth: number;
  130003. /**
  130004. * Based on the lens distortion effect, defines how much the lens flare result
  130005. * is distorted
  130006. */
  130007. lensFlareDistortionStrength: number;
  130008. /**
  130009. * Configures the blur intensity used for for lens flare (halo)
  130010. */
  130011. lensFlareBlurWidth: number;
  130012. /**
  130013. * Lens star texture must be used to simulate rays on the flares and is available
  130014. * in the documentation
  130015. */
  130016. lensStarTexture: Nullable<Texture>;
  130017. /**
  130018. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130019. * flare effect by taking account of the dirt texture
  130020. */
  130021. lensFlareDirtTexture: Nullable<Texture>;
  130022. /**
  130023. * Represents the focal length for the depth of field effect
  130024. */
  130025. depthOfFieldDistance: number;
  130026. /**
  130027. * Represents the blur intensity for the blurred part of the depth of field effect
  130028. */
  130029. depthOfFieldBlurWidth: number;
  130030. /**
  130031. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130032. */
  130033. /**
  130034. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130035. */
  130036. motionStrength: number;
  130037. /**
  130038. * Gets wether or not the motion blur post-process is object based or screen based.
  130039. */
  130040. /**
  130041. * Sets wether or not the motion blur post-process should be object based or screen based
  130042. */
  130043. objectBasedMotionBlur: boolean;
  130044. /**
  130045. * List of animations for the pipeline (IAnimatable implementation)
  130046. */
  130047. animations: Animation[];
  130048. /**
  130049. * Private members
  130050. */
  130051. private _scene;
  130052. private _currentDepthOfFieldSource;
  130053. private _basePostProcess;
  130054. private _fixedExposure;
  130055. private _currentExposure;
  130056. private _hdrAutoExposure;
  130057. private _hdrCurrentLuminance;
  130058. private _motionStrength;
  130059. private _isObjectBasedMotionBlur;
  130060. private _floatTextureType;
  130061. private _camerasToBeAttached;
  130062. private _ratio;
  130063. private _bloomEnabled;
  130064. private _depthOfFieldEnabled;
  130065. private _vlsEnabled;
  130066. private _lensFlareEnabled;
  130067. private _hdrEnabled;
  130068. private _motionBlurEnabled;
  130069. private _fxaaEnabled;
  130070. private _motionBlurSamples;
  130071. private _volumetricLightStepsCount;
  130072. private _samples;
  130073. /**
  130074. * @ignore
  130075. * Specifies if the bloom pipeline is enabled
  130076. */
  130077. BloomEnabled: boolean;
  130078. /**
  130079. * @ignore
  130080. * Specifies if the depth of field pipeline is enabed
  130081. */
  130082. DepthOfFieldEnabled: boolean;
  130083. /**
  130084. * @ignore
  130085. * Specifies if the lens flare pipeline is enabed
  130086. */
  130087. LensFlareEnabled: boolean;
  130088. /**
  130089. * @ignore
  130090. * Specifies if the HDR pipeline is enabled
  130091. */
  130092. HDREnabled: boolean;
  130093. /**
  130094. * @ignore
  130095. * Specifies if the volumetric lights scattering effect is enabled
  130096. */
  130097. VLSEnabled: boolean;
  130098. /**
  130099. * @ignore
  130100. * Specifies if the motion blur effect is enabled
  130101. */
  130102. MotionBlurEnabled: boolean;
  130103. /**
  130104. * Specifies if anti-aliasing is enabled
  130105. */
  130106. fxaaEnabled: boolean;
  130107. /**
  130108. * Specifies the number of steps used to calculate the volumetric lights
  130109. * Typically in interval [50, 200]
  130110. */
  130111. volumetricLightStepsCount: number;
  130112. /**
  130113. * Specifies the number of samples used for the motion blur effect
  130114. * Typically in interval [16, 64]
  130115. */
  130116. motionBlurSamples: number;
  130117. /**
  130118. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130119. */
  130120. samples: number;
  130121. /**
  130122. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130123. * @constructor
  130124. * @param name The rendering pipeline name
  130125. * @param scene The scene linked to this pipeline
  130126. * @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)
  130127. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130128. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130129. */
  130130. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130131. private _buildPipeline;
  130132. private _createDownSampleX4PostProcess;
  130133. private _createBrightPassPostProcess;
  130134. private _createBlurPostProcesses;
  130135. private _createTextureAdderPostProcess;
  130136. private _createVolumetricLightPostProcess;
  130137. private _createLuminancePostProcesses;
  130138. private _createHdrPostProcess;
  130139. private _createLensFlarePostProcess;
  130140. private _createDepthOfFieldPostProcess;
  130141. private _createMotionBlurPostProcess;
  130142. private _getDepthTexture;
  130143. private _disposePostProcesses;
  130144. /**
  130145. * Dispose of the pipeline and stop all post processes
  130146. */
  130147. dispose(): void;
  130148. /**
  130149. * Serialize the rendering pipeline (Used when exporting)
  130150. * @returns the serialized object
  130151. */
  130152. serialize(): any;
  130153. /**
  130154. * Parse the serialized pipeline
  130155. * @param source Source pipeline.
  130156. * @param scene The scene to load the pipeline to.
  130157. * @param rootUrl The URL of the serialized pipeline.
  130158. * @returns An instantiated pipeline from the serialized object.
  130159. */
  130160. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130161. /**
  130162. * Luminance steps
  130163. */
  130164. static LuminanceSteps: number;
  130165. }
  130166. }
  130167. declare module BABYLON {
  130168. /** @hidden */
  130169. export var tonemapPixelShader: {
  130170. name: string;
  130171. shader: string;
  130172. };
  130173. }
  130174. declare module BABYLON {
  130175. /** Defines operator used for tonemapping */
  130176. export enum TonemappingOperator {
  130177. /** Hable */
  130178. Hable = 0,
  130179. /** Reinhard */
  130180. Reinhard = 1,
  130181. /** HejiDawson */
  130182. HejiDawson = 2,
  130183. /** Photographic */
  130184. Photographic = 3
  130185. }
  130186. /**
  130187. * Defines a post process to apply tone mapping
  130188. */
  130189. export class TonemapPostProcess extends PostProcess {
  130190. private _operator;
  130191. /** Defines the required exposure adjustement */
  130192. exposureAdjustment: number;
  130193. /**
  130194. * Creates a new TonemapPostProcess
  130195. * @param name defines the name of the postprocess
  130196. * @param _operator defines the operator to use
  130197. * @param exposureAdjustment defines the required exposure adjustement
  130198. * @param camera defines the camera to use (can be null)
  130199. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130200. * @param engine defines the hosting engine (can be ignore if camera is set)
  130201. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130202. */
  130203. constructor(name: string, _operator: TonemappingOperator,
  130204. /** Defines the required exposure adjustement */
  130205. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130206. }
  130207. }
  130208. declare module BABYLON {
  130209. /** @hidden */
  130210. export var depthVertexShader: {
  130211. name: string;
  130212. shader: string;
  130213. };
  130214. }
  130215. declare module BABYLON {
  130216. /** @hidden */
  130217. export var volumetricLightScatteringPixelShader: {
  130218. name: string;
  130219. shader: string;
  130220. };
  130221. }
  130222. declare module BABYLON {
  130223. /** @hidden */
  130224. export var volumetricLightScatteringPassVertexShader: {
  130225. name: string;
  130226. shader: string;
  130227. };
  130228. }
  130229. declare module BABYLON {
  130230. /** @hidden */
  130231. export var volumetricLightScatteringPassPixelShader: {
  130232. name: string;
  130233. shader: string;
  130234. };
  130235. }
  130236. declare module BABYLON {
  130237. /**
  130238. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130239. */
  130240. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130241. private _volumetricLightScatteringPass;
  130242. private _volumetricLightScatteringRTT;
  130243. private _viewPort;
  130244. private _screenCoordinates;
  130245. private _cachedDefines;
  130246. /**
  130247. * If not undefined, the mesh position is computed from the attached node position
  130248. */
  130249. attachedNode: {
  130250. position: Vector3;
  130251. };
  130252. /**
  130253. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130254. */
  130255. customMeshPosition: Vector3;
  130256. /**
  130257. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130258. */
  130259. useCustomMeshPosition: boolean;
  130260. /**
  130261. * If the post-process should inverse the light scattering direction
  130262. */
  130263. invert: boolean;
  130264. /**
  130265. * The internal mesh used by the post-process
  130266. */
  130267. mesh: Mesh;
  130268. /**
  130269. * @hidden
  130270. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130271. */
  130272. useDiffuseColor: boolean;
  130273. /**
  130274. * Array containing the excluded meshes not rendered in the internal pass
  130275. */
  130276. excludedMeshes: AbstractMesh[];
  130277. /**
  130278. * Controls the overall intensity of the post-process
  130279. */
  130280. exposure: number;
  130281. /**
  130282. * Dissipates each sample's contribution in range [0, 1]
  130283. */
  130284. decay: number;
  130285. /**
  130286. * Controls the overall intensity of each sample
  130287. */
  130288. weight: number;
  130289. /**
  130290. * Controls the density of each sample
  130291. */
  130292. density: number;
  130293. /**
  130294. * @constructor
  130295. * @param name The post-process name
  130296. * @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)
  130297. * @param camera The camera that the post-process will be attached to
  130298. * @param mesh The mesh used to create the light scattering
  130299. * @param samples The post-process quality, default 100
  130300. * @param samplingModeThe post-process filtering mode
  130301. * @param engine The babylon engine
  130302. * @param reusable If the post-process is reusable
  130303. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130304. */
  130305. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130306. /**
  130307. * Returns the string "VolumetricLightScatteringPostProcess"
  130308. * @returns "VolumetricLightScatteringPostProcess"
  130309. */
  130310. getClassName(): string;
  130311. private _isReady;
  130312. /**
  130313. * Sets the new light position for light scattering effect
  130314. * @param position The new custom light position
  130315. */
  130316. setCustomMeshPosition(position: Vector3): void;
  130317. /**
  130318. * Returns the light position for light scattering effect
  130319. * @return Vector3 The custom light position
  130320. */
  130321. getCustomMeshPosition(): Vector3;
  130322. /**
  130323. * Disposes the internal assets and detaches the post-process from the camera
  130324. */
  130325. dispose(camera: Camera): void;
  130326. /**
  130327. * Returns the render target texture used by the post-process
  130328. * @return the render target texture used by the post-process
  130329. */
  130330. getPass(): RenderTargetTexture;
  130331. private _meshExcluded;
  130332. private _createPass;
  130333. private _updateMeshScreenCoordinates;
  130334. /**
  130335. * Creates a default mesh for the Volumeric Light Scattering post-process
  130336. * @param name The mesh name
  130337. * @param scene The scene where to create the mesh
  130338. * @return the default mesh
  130339. */
  130340. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130341. }
  130342. }
  130343. declare module BABYLON {
  130344. interface Scene {
  130345. /** @hidden (Backing field) */
  130346. _boundingBoxRenderer: BoundingBoxRenderer;
  130347. /** @hidden (Backing field) */
  130348. _forceShowBoundingBoxes: boolean;
  130349. /**
  130350. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130351. */
  130352. forceShowBoundingBoxes: boolean;
  130353. /**
  130354. * Gets the bounding box renderer associated with the scene
  130355. * @returns a BoundingBoxRenderer
  130356. */
  130357. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130358. }
  130359. interface AbstractMesh {
  130360. /** @hidden (Backing field) */
  130361. _showBoundingBox: boolean;
  130362. /**
  130363. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130364. */
  130365. showBoundingBox: boolean;
  130366. }
  130367. /**
  130368. * Component responsible of rendering the bounding box of the meshes in a scene.
  130369. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130370. */
  130371. export class BoundingBoxRenderer implements ISceneComponent {
  130372. /**
  130373. * The component name helpfull to identify the component in the list of scene components.
  130374. */
  130375. readonly name: string;
  130376. /**
  130377. * The scene the component belongs to.
  130378. */
  130379. scene: Scene;
  130380. /**
  130381. * Color of the bounding box lines placed in front of an object
  130382. */
  130383. frontColor: Color3;
  130384. /**
  130385. * Color of the bounding box lines placed behind an object
  130386. */
  130387. backColor: Color3;
  130388. /**
  130389. * Defines if the renderer should show the back lines or not
  130390. */
  130391. showBackLines: boolean;
  130392. /**
  130393. * @hidden
  130394. */
  130395. renderList: SmartArray<BoundingBox>;
  130396. private _colorShader;
  130397. private _vertexBuffers;
  130398. private _indexBuffer;
  130399. private _fillIndexBuffer;
  130400. private _fillIndexData;
  130401. /**
  130402. * Instantiates a new bounding box renderer in a scene.
  130403. * @param scene the scene the renderer renders in
  130404. */
  130405. constructor(scene: Scene);
  130406. /**
  130407. * Registers the component in a given scene
  130408. */
  130409. register(): void;
  130410. private _evaluateSubMesh;
  130411. private _activeMesh;
  130412. private _prepareRessources;
  130413. private _createIndexBuffer;
  130414. /**
  130415. * Rebuilds the elements related to this component in case of
  130416. * context lost for instance.
  130417. */
  130418. rebuild(): void;
  130419. /**
  130420. * @hidden
  130421. */
  130422. reset(): void;
  130423. /**
  130424. * Render the bounding boxes of a specific rendering group
  130425. * @param renderingGroupId defines the rendering group to render
  130426. */
  130427. render(renderingGroupId: number): void;
  130428. /**
  130429. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130430. * @param mesh Define the mesh to render the occlusion bounding box for
  130431. */
  130432. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130433. /**
  130434. * Dispose and release the resources attached to this renderer.
  130435. */
  130436. dispose(): void;
  130437. }
  130438. }
  130439. declare module BABYLON {
  130440. /** @hidden */
  130441. export var depthPixelShader: {
  130442. name: string;
  130443. shader: string;
  130444. };
  130445. }
  130446. declare module BABYLON {
  130447. /**
  130448. * This represents a depth renderer in Babylon.
  130449. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130450. */
  130451. export class DepthRenderer {
  130452. private _scene;
  130453. private _depthMap;
  130454. private _effect;
  130455. private readonly _storeNonLinearDepth;
  130456. private readonly _clearColor;
  130457. /** Get if the depth renderer is using packed depth or not */
  130458. readonly isPacked: boolean;
  130459. private _cachedDefines;
  130460. private _camera;
  130461. /**
  130462. * Specifiess that the depth renderer will only be used within
  130463. * the camera it is created for.
  130464. * This can help forcing its rendering during the camera processing.
  130465. */
  130466. useOnlyInActiveCamera: boolean;
  130467. /** @hidden */
  130468. static _SceneComponentInitialization: (scene: Scene) => void;
  130469. /**
  130470. * Instantiates a depth renderer
  130471. * @param scene The scene the renderer belongs to
  130472. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130473. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130474. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130475. */
  130476. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130477. /**
  130478. * Creates the depth rendering effect and checks if the effect is ready.
  130479. * @param subMesh The submesh to be used to render the depth map of
  130480. * @param useInstances If multiple world instances should be used
  130481. * @returns if the depth renderer is ready to render the depth map
  130482. */
  130483. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130484. /**
  130485. * Gets the texture which the depth map will be written to.
  130486. * @returns The depth map texture
  130487. */
  130488. getDepthMap(): RenderTargetTexture;
  130489. /**
  130490. * Disposes of the depth renderer.
  130491. */
  130492. dispose(): void;
  130493. }
  130494. }
  130495. declare module BABYLON {
  130496. interface Scene {
  130497. /** @hidden (Backing field) */
  130498. _depthRenderer: {
  130499. [id: string]: DepthRenderer;
  130500. };
  130501. /**
  130502. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130503. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130504. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130505. * @returns the created depth renderer
  130506. */
  130507. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130508. /**
  130509. * Disables a depth renderer for a given camera
  130510. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130511. */
  130512. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130513. }
  130514. /**
  130515. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130516. * in several rendering techniques.
  130517. */
  130518. export class DepthRendererSceneComponent implements ISceneComponent {
  130519. /**
  130520. * The component name helpfull to identify the component in the list of scene components.
  130521. */
  130522. readonly name: string;
  130523. /**
  130524. * The scene the component belongs to.
  130525. */
  130526. scene: Scene;
  130527. /**
  130528. * Creates a new instance of the component for the given scene
  130529. * @param scene Defines the scene to register the component in
  130530. */
  130531. constructor(scene: Scene);
  130532. /**
  130533. * Registers the component in a given scene
  130534. */
  130535. register(): void;
  130536. /**
  130537. * Rebuilds the elements related to this component in case of
  130538. * context lost for instance.
  130539. */
  130540. rebuild(): void;
  130541. /**
  130542. * Disposes the component and the associated ressources
  130543. */
  130544. dispose(): void;
  130545. private _gatherRenderTargets;
  130546. private _gatherActiveCameraRenderTargets;
  130547. }
  130548. }
  130549. declare module BABYLON {
  130550. /** @hidden */
  130551. export var outlinePixelShader: {
  130552. name: string;
  130553. shader: string;
  130554. };
  130555. }
  130556. declare module BABYLON {
  130557. /** @hidden */
  130558. export var outlineVertexShader: {
  130559. name: string;
  130560. shader: string;
  130561. };
  130562. }
  130563. declare module BABYLON {
  130564. interface Scene {
  130565. /** @hidden */
  130566. _outlineRenderer: OutlineRenderer;
  130567. /**
  130568. * Gets the outline renderer associated with the scene
  130569. * @returns a OutlineRenderer
  130570. */
  130571. getOutlineRenderer(): OutlineRenderer;
  130572. }
  130573. interface AbstractMesh {
  130574. /** @hidden (Backing field) */
  130575. _renderOutline: boolean;
  130576. /**
  130577. * Gets or sets a boolean indicating if the outline must be rendered as well
  130578. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130579. */
  130580. renderOutline: boolean;
  130581. /** @hidden (Backing field) */
  130582. _renderOverlay: boolean;
  130583. /**
  130584. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130585. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130586. */
  130587. renderOverlay: boolean;
  130588. }
  130589. /**
  130590. * This class is responsible to draw bothe outline/overlay of meshes.
  130591. * It should not be used directly but through the available method on mesh.
  130592. */
  130593. export class OutlineRenderer implements ISceneComponent {
  130594. /**
  130595. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130596. */
  130597. private static _StencilReference;
  130598. /**
  130599. * The name of the component. Each component must have a unique name.
  130600. */
  130601. name: string;
  130602. /**
  130603. * The scene the component belongs to.
  130604. */
  130605. scene: Scene;
  130606. /**
  130607. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130608. */
  130609. zOffset: number;
  130610. private _engine;
  130611. private _effect;
  130612. private _cachedDefines;
  130613. private _savedDepthWrite;
  130614. /**
  130615. * Instantiates a new outline renderer. (There could be only one per scene).
  130616. * @param scene Defines the scene it belongs to
  130617. */
  130618. constructor(scene: Scene);
  130619. /**
  130620. * Register the component to one instance of a scene.
  130621. */
  130622. register(): void;
  130623. /**
  130624. * Rebuilds the elements related to this component in case of
  130625. * context lost for instance.
  130626. */
  130627. rebuild(): void;
  130628. /**
  130629. * Disposes the component and the associated ressources.
  130630. */
  130631. dispose(): void;
  130632. /**
  130633. * Renders the outline in the canvas.
  130634. * @param subMesh Defines the sumesh to render
  130635. * @param batch Defines the batch of meshes in case of instances
  130636. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130637. */
  130638. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130639. /**
  130640. * Returns whether or not the outline renderer is ready for a given submesh.
  130641. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130642. * @param subMesh Defines the submesh to check readyness for
  130643. * @param useInstances Defines wheter wee are trying to render instances or not
  130644. * @returns true if ready otherwise false
  130645. */
  130646. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130647. private _beforeRenderingMesh;
  130648. private _afterRenderingMesh;
  130649. }
  130650. }
  130651. declare module BABYLON {
  130652. /**
  130653. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130654. * @see http://doc.babylonjs.com/babylon101/sprites
  130655. */
  130656. export class SpritePackedManager extends SpriteManager {
  130657. /** defines the packed manager's name */
  130658. name: string;
  130659. /**
  130660. * Creates a new sprite manager from a packed sprite sheet
  130661. * @param name defines the manager's name
  130662. * @param imgUrl defines the sprite sheet url
  130663. * @param capacity defines the maximum allowed number of sprites
  130664. * @param scene defines the hosting scene
  130665. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130666. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130667. * @param samplingMode defines the smapling mode to use with spritesheet
  130668. * @param fromPacked set to true; do not alter
  130669. */
  130670. constructor(
  130671. /** defines the packed manager's name */
  130672. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130673. }
  130674. }
  130675. declare module BABYLON {
  130676. /**
  130677. * Defines the list of states available for a task inside a AssetsManager
  130678. */
  130679. export enum AssetTaskState {
  130680. /**
  130681. * Initialization
  130682. */
  130683. INIT = 0,
  130684. /**
  130685. * Running
  130686. */
  130687. RUNNING = 1,
  130688. /**
  130689. * Done
  130690. */
  130691. DONE = 2,
  130692. /**
  130693. * Error
  130694. */
  130695. ERROR = 3
  130696. }
  130697. /**
  130698. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130699. */
  130700. export abstract class AbstractAssetTask {
  130701. /**
  130702. * Task name
  130703. */ name: string;
  130704. /**
  130705. * Callback called when the task is successful
  130706. */
  130707. onSuccess: (task: any) => void;
  130708. /**
  130709. * Callback called when the task is not successful
  130710. */
  130711. onError: (task: any, message?: string, exception?: any) => void;
  130712. /**
  130713. * Creates a new AssetsManager
  130714. * @param name defines the name of the task
  130715. */
  130716. constructor(
  130717. /**
  130718. * Task name
  130719. */ name: string);
  130720. private _isCompleted;
  130721. private _taskState;
  130722. private _errorObject;
  130723. /**
  130724. * Get if the task is completed
  130725. */
  130726. readonly isCompleted: boolean;
  130727. /**
  130728. * Gets the current state of the task
  130729. */
  130730. readonly taskState: AssetTaskState;
  130731. /**
  130732. * Gets the current error object (if task is in error)
  130733. */
  130734. readonly errorObject: {
  130735. message?: string;
  130736. exception?: any;
  130737. };
  130738. /**
  130739. * Internal only
  130740. * @hidden
  130741. */
  130742. _setErrorObject(message?: string, exception?: any): void;
  130743. /**
  130744. * Execute the current task
  130745. * @param scene defines the scene where you want your assets to be loaded
  130746. * @param onSuccess is a callback called when the task is successfully executed
  130747. * @param onError is a callback called if an error occurs
  130748. */
  130749. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130750. /**
  130751. * Execute the current task
  130752. * @param scene defines the scene where you want your assets to be loaded
  130753. * @param onSuccess is a callback called when the task is successfully executed
  130754. * @param onError is a callback called if an error occurs
  130755. */
  130756. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130757. /**
  130758. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130759. * This can be used with failed tasks that have the reason for failure fixed.
  130760. */
  130761. reset(): void;
  130762. private onErrorCallback;
  130763. private onDoneCallback;
  130764. }
  130765. /**
  130766. * Define the interface used by progress events raised during assets loading
  130767. */
  130768. export interface IAssetsProgressEvent {
  130769. /**
  130770. * Defines the number of remaining tasks to process
  130771. */
  130772. remainingCount: number;
  130773. /**
  130774. * Defines the total number of tasks
  130775. */
  130776. totalCount: number;
  130777. /**
  130778. * Defines the task that was just processed
  130779. */
  130780. task: AbstractAssetTask;
  130781. }
  130782. /**
  130783. * Class used to share progress information about assets loading
  130784. */
  130785. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130786. /**
  130787. * Defines the number of remaining tasks to process
  130788. */
  130789. remainingCount: number;
  130790. /**
  130791. * Defines the total number of tasks
  130792. */
  130793. totalCount: number;
  130794. /**
  130795. * Defines the task that was just processed
  130796. */
  130797. task: AbstractAssetTask;
  130798. /**
  130799. * Creates a AssetsProgressEvent
  130800. * @param remainingCount defines the number of remaining tasks to process
  130801. * @param totalCount defines the total number of tasks
  130802. * @param task defines the task that was just processed
  130803. */
  130804. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130805. }
  130806. /**
  130807. * Define a task used by AssetsManager to load meshes
  130808. */
  130809. export class MeshAssetTask extends AbstractAssetTask {
  130810. /**
  130811. * Defines the name of the task
  130812. */
  130813. name: string;
  130814. /**
  130815. * Defines the list of mesh's names you want to load
  130816. */
  130817. meshesNames: any;
  130818. /**
  130819. * Defines the root url to use as a base to load your meshes and associated resources
  130820. */
  130821. rootUrl: string;
  130822. /**
  130823. * Defines the filename of the scene to load from
  130824. */
  130825. sceneFilename: string;
  130826. /**
  130827. * Gets the list of loaded meshes
  130828. */
  130829. loadedMeshes: Array<AbstractMesh>;
  130830. /**
  130831. * Gets the list of loaded particle systems
  130832. */
  130833. loadedParticleSystems: Array<IParticleSystem>;
  130834. /**
  130835. * Gets the list of loaded skeletons
  130836. */
  130837. loadedSkeletons: Array<Skeleton>;
  130838. /**
  130839. * Gets the list of loaded animation groups
  130840. */
  130841. loadedAnimationGroups: Array<AnimationGroup>;
  130842. /**
  130843. * Callback called when the task is successful
  130844. */
  130845. onSuccess: (task: MeshAssetTask) => void;
  130846. /**
  130847. * Callback called when the task is successful
  130848. */
  130849. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130850. /**
  130851. * Creates a new MeshAssetTask
  130852. * @param name defines the name of the task
  130853. * @param meshesNames defines the list of mesh's names you want to load
  130854. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130855. * @param sceneFilename defines the filename of the scene to load from
  130856. */
  130857. constructor(
  130858. /**
  130859. * Defines the name of the task
  130860. */
  130861. name: string,
  130862. /**
  130863. * Defines the list of mesh's names you want to load
  130864. */
  130865. meshesNames: any,
  130866. /**
  130867. * Defines the root url to use as a base to load your meshes and associated resources
  130868. */
  130869. rootUrl: string,
  130870. /**
  130871. * Defines the filename of the scene to load from
  130872. */
  130873. sceneFilename: string);
  130874. /**
  130875. * Execute the current task
  130876. * @param scene defines the scene where you want your assets to be loaded
  130877. * @param onSuccess is a callback called when the task is successfully executed
  130878. * @param onError is a callback called if an error occurs
  130879. */
  130880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130881. }
  130882. /**
  130883. * Define a task used by AssetsManager to load text content
  130884. */
  130885. export class TextFileAssetTask extends AbstractAssetTask {
  130886. /**
  130887. * Defines the name of the task
  130888. */
  130889. name: string;
  130890. /**
  130891. * Defines the location of the file to load
  130892. */
  130893. url: string;
  130894. /**
  130895. * Gets the loaded text string
  130896. */
  130897. text: string;
  130898. /**
  130899. * Callback called when the task is successful
  130900. */
  130901. onSuccess: (task: TextFileAssetTask) => void;
  130902. /**
  130903. * Callback called when the task is successful
  130904. */
  130905. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130906. /**
  130907. * Creates a new TextFileAssetTask object
  130908. * @param name defines the name of the task
  130909. * @param url defines the location of the file to load
  130910. */
  130911. constructor(
  130912. /**
  130913. * Defines the name of the task
  130914. */
  130915. name: string,
  130916. /**
  130917. * Defines the location of the file to load
  130918. */
  130919. url: string);
  130920. /**
  130921. * Execute the current task
  130922. * @param scene defines the scene where you want your assets to be loaded
  130923. * @param onSuccess is a callback called when the task is successfully executed
  130924. * @param onError is a callback called if an error occurs
  130925. */
  130926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130927. }
  130928. /**
  130929. * Define a task used by AssetsManager to load binary data
  130930. */
  130931. export class BinaryFileAssetTask extends AbstractAssetTask {
  130932. /**
  130933. * Defines the name of the task
  130934. */
  130935. name: string;
  130936. /**
  130937. * Defines the location of the file to load
  130938. */
  130939. url: string;
  130940. /**
  130941. * Gets the lodaded data (as an array buffer)
  130942. */
  130943. data: ArrayBuffer;
  130944. /**
  130945. * Callback called when the task is successful
  130946. */
  130947. onSuccess: (task: BinaryFileAssetTask) => void;
  130948. /**
  130949. * Callback called when the task is successful
  130950. */
  130951. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  130952. /**
  130953. * Creates a new BinaryFileAssetTask object
  130954. * @param name defines the name of the new task
  130955. * @param url defines the location of the file to load
  130956. */
  130957. constructor(
  130958. /**
  130959. * Defines the name of the task
  130960. */
  130961. name: string,
  130962. /**
  130963. * Defines the location of the file to load
  130964. */
  130965. url: string);
  130966. /**
  130967. * Execute the current task
  130968. * @param scene defines the scene where you want your assets to be loaded
  130969. * @param onSuccess is a callback called when the task is successfully executed
  130970. * @param onError is a callback called if an error occurs
  130971. */
  130972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130973. }
  130974. /**
  130975. * Define a task used by AssetsManager to load images
  130976. */
  130977. export class ImageAssetTask extends AbstractAssetTask {
  130978. /**
  130979. * Defines the name of the task
  130980. */
  130981. name: string;
  130982. /**
  130983. * Defines the location of the image to load
  130984. */
  130985. url: string;
  130986. /**
  130987. * Gets the loaded images
  130988. */
  130989. image: HTMLImageElement;
  130990. /**
  130991. * Callback called when the task is successful
  130992. */
  130993. onSuccess: (task: ImageAssetTask) => void;
  130994. /**
  130995. * Callback called when the task is successful
  130996. */
  130997. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  130998. /**
  130999. * Creates a new ImageAssetTask
  131000. * @param name defines the name of the task
  131001. * @param url defines the location of the image to load
  131002. */
  131003. constructor(
  131004. /**
  131005. * Defines the name of the task
  131006. */
  131007. name: string,
  131008. /**
  131009. * Defines the location of the image to load
  131010. */
  131011. url: string);
  131012. /**
  131013. * Execute the current task
  131014. * @param scene defines the scene where you want your assets to be loaded
  131015. * @param onSuccess is a callback called when the task is successfully executed
  131016. * @param onError is a callback called if an error occurs
  131017. */
  131018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131019. }
  131020. /**
  131021. * Defines the interface used by texture loading tasks
  131022. */
  131023. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131024. /**
  131025. * Gets the loaded texture
  131026. */
  131027. texture: TEX;
  131028. }
  131029. /**
  131030. * Define a task used by AssetsManager to load 2D textures
  131031. */
  131032. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131033. /**
  131034. * Defines the name of the task
  131035. */
  131036. name: string;
  131037. /**
  131038. * Defines the location of the file to load
  131039. */
  131040. url: string;
  131041. /**
  131042. * Defines if mipmap should not be generated (default is false)
  131043. */
  131044. noMipmap?: boolean | undefined;
  131045. /**
  131046. * Defines if texture must be inverted on Y axis (default is false)
  131047. */
  131048. invertY?: boolean | undefined;
  131049. /**
  131050. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131051. */
  131052. samplingMode: number;
  131053. /**
  131054. * Gets the loaded texture
  131055. */
  131056. texture: Texture;
  131057. /**
  131058. * Callback called when the task is successful
  131059. */
  131060. onSuccess: (task: TextureAssetTask) => void;
  131061. /**
  131062. * Callback called when the task is successful
  131063. */
  131064. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131065. /**
  131066. * Creates a new TextureAssetTask object
  131067. * @param name defines the name of the task
  131068. * @param url defines the location of the file to load
  131069. * @param noMipmap defines if mipmap should not be generated (default is false)
  131070. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131071. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131072. */
  131073. constructor(
  131074. /**
  131075. * Defines the name of the task
  131076. */
  131077. name: string,
  131078. /**
  131079. * Defines the location of the file to load
  131080. */
  131081. url: string,
  131082. /**
  131083. * Defines if mipmap should not be generated (default is false)
  131084. */
  131085. noMipmap?: boolean | undefined,
  131086. /**
  131087. * Defines if texture must be inverted on Y axis (default is false)
  131088. */
  131089. invertY?: boolean | undefined,
  131090. /**
  131091. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131092. */
  131093. samplingMode?: number);
  131094. /**
  131095. * Execute the current task
  131096. * @param scene defines the scene where you want your assets to be loaded
  131097. * @param onSuccess is a callback called when the task is successfully executed
  131098. * @param onError is a callback called if an error occurs
  131099. */
  131100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131101. }
  131102. /**
  131103. * Define a task used by AssetsManager to load cube textures
  131104. */
  131105. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131106. /**
  131107. * Defines the name of the task
  131108. */
  131109. name: string;
  131110. /**
  131111. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131112. */
  131113. url: string;
  131114. /**
  131115. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131116. */
  131117. extensions?: string[] | undefined;
  131118. /**
  131119. * Defines if mipmaps should not be generated (default is false)
  131120. */
  131121. noMipmap?: boolean | undefined;
  131122. /**
  131123. * Defines the explicit list of files (undefined by default)
  131124. */
  131125. files?: string[] | undefined;
  131126. /**
  131127. * Gets the loaded texture
  131128. */
  131129. texture: CubeTexture;
  131130. /**
  131131. * Callback called when the task is successful
  131132. */
  131133. onSuccess: (task: CubeTextureAssetTask) => void;
  131134. /**
  131135. * Callback called when the task is successful
  131136. */
  131137. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131138. /**
  131139. * Creates a new CubeTextureAssetTask
  131140. * @param name defines the name of the task
  131141. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131142. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131143. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131144. * @param files defines the explicit list of files (undefined by default)
  131145. */
  131146. constructor(
  131147. /**
  131148. * Defines the name of the task
  131149. */
  131150. name: string,
  131151. /**
  131152. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131153. */
  131154. url: string,
  131155. /**
  131156. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131157. */
  131158. extensions?: string[] | undefined,
  131159. /**
  131160. * Defines if mipmaps should not be generated (default is false)
  131161. */
  131162. noMipmap?: boolean | undefined,
  131163. /**
  131164. * Defines the explicit list of files (undefined by default)
  131165. */
  131166. files?: string[] | undefined);
  131167. /**
  131168. * Execute the current task
  131169. * @param scene defines the scene where you want your assets to be loaded
  131170. * @param onSuccess is a callback called when the task is successfully executed
  131171. * @param onError is a callback called if an error occurs
  131172. */
  131173. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131174. }
  131175. /**
  131176. * Define a task used by AssetsManager to load HDR cube textures
  131177. */
  131178. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131179. /**
  131180. * Defines the name of the task
  131181. */
  131182. name: string;
  131183. /**
  131184. * Defines the location of the file to load
  131185. */
  131186. url: string;
  131187. /**
  131188. * Defines the desired size (the more it increases the longer the generation will be)
  131189. */
  131190. size: number;
  131191. /**
  131192. * Defines if mipmaps should not be generated (default is false)
  131193. */
  131194. noMipmap: boolean;
  131195. /**
  131196. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131197. */
  131198. generateHarmonics: boolean;
  131199. /**
  131200. * 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)
  131201. */
  131202. gammaSpace: boolean;
  131203. /**
  131204. * Internal Use Only
  131205. */
  131206. reserved: boolean;
  131207. /**
  131208. * Gets the loaded texture
  131209. */
  131210. texture: HDRCubeTexture;
  131211. /**
  131212. * Callback called when the task is successful
  131213. */
  131214. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131215. /**
  131216. * Callback called when the task is successful
  131217. */
  131218. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131219. /**
  131220. * Creates a new HDRCubeTextureAssetTask object
  131221. * @param name defines the name of the task
  131222. * @param url defines the location of the file to load
  131223. * @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.
  131224. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131225. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131226. * @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)
  131227. * @param reserved Internal use only
  131228. */
  131229. constructor(
  131230. /**
  131231. * Defines the name of the task
  131232. */
  131233. name: string,
  131234. /**
  131235. * Defines the location of the file to load
  131236. */
  131237. url: string,
  131238. /**
  131239. * Defines the desired size (the more it increases the longer the generation will be)
  131240. */
  131241. size: number,
  131242. /**
  131243. * Defines if mipmaps should not be generated (default is false)
  131244. */
  131245. noMipmap?: boolean,
  131246. /**
  131247. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131248. */
  131249. generateHarmonics?: boolean,
  131250. /**
  131251. * 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)
  131252. */
  131253. gammaSpace?: boolean,
  131254. /**
  131255. * Internal Use Only
  131256. */
  131257. reserved?: boolean);
  131258. /**
  131259. * Execute the current task
  131260. * @param scene defines the scene where you want your assets to be loaded
  131261. * @param onSuccess is a callback called when the task is successfully executed
  131262. * @param onError is a callback called if an error occurs
  131263. */
  131264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131265. }
  131266. /**
  131267. * Define a task used by AssetsManager to load Equirectangular cube textures
  131268. */
  131269. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131270. /**
  131271. * Defines the name of the task
  131272. */
  131273. name: string;
  131274. /**
  131275. * Defines the location of the file to load
  131276. */
  131277. url: string;
  131278. /**
  131279. * Defines the desired size (the more it increases the longer the generation will be)
  131280. */
  131281. size: number;
  131282. /**
  131283. * Defines if mipmaps should not be generated (default is false)
  131284. */
  131285. noMipmap: boolean;
  131286. /**
  131287. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131288. * but the standard material would require them in Gamma space) (default is true)
  131289. */
  131290. gammaSpace: boolean;
  131291. /**
  131292. * Gets the loaded texture
  131293. */
  131294. texture: EquiRectangularCubeTexture;
  131295. /**
  131296. * Callback called when the task is successful
  131297. */
  131298. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131299. /**
  131300. * Callback called when the task is successful
  131301. */
  131302. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131303. /**
  131304. * Creates a new EquiRectangularCubeTextureAssetTask object
  131305. * @param name defines the name of the task
  131306. * @param url defines the location of the file to load
  131307. * @param size defines the desired size (the more it increases the longer the generation will be)
  131308. * If the size is omitted this implies you are using a preprocessed cubemap.
  131309. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131310. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131311. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131312. * (default is true)
  131313. */
  131314. constructor(
  131315. /**
  131316. * Defines the name of the task
  131317. */
  131318. name: string,
  131319. /**
  131320. * Defines the location of the file to load
  131321. */
  131322. url: string,
  131323. /**
  131324. * Defines the desired size (the more it increases the longer the generation will be)
  131325. */
  131326. size: number,
  131327. /**
  131328. * Defines if mipmaps should not be generated (default is false)
  131329. */
  131330. noMipmap?: boolean,
  131331. /**
  131332. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131333. * but the standard material would require them in Gamma space) (default is true)
  131334. */
  131335. gammaSpace?: boolean);
  131336. /**
  131337. * Execute the current task
  131338. * @param scene defines the scene where you want your assets to be loaded
  131339. * @param onSuccess is a callback called when the task is successfully executed
  131340. * @param onError is a callback called if an error occurs
  131341. */
  131342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131343. }
  131344. /**
  131345. * This class can be used to easily import assets into a scene
  131346. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131347. */
  131348. export class AssetsManager {
  131349. private _scene;
  131350. private _isLoading;
  131351. protected _tasks: AbstractAssetTask[];
  131352. protected _waitingTasksCount: number;
  131353. protected _totalTasksCount: number;
  131354. /**
  131355. * Callback called when all tasks are processed
  131356. */
  131357. onFinish: (tasks: AbstractAssetTask[]) => void;
  131358. /**
  131359. * Callback called when a task is successful
  131360. */
  131361. onTaskSuccess: (task: AbstractAssetTask) => void;
  131362. /**
  131363. * Callback called when a task had an error
  131364. */
  131365. onTaskError: (task: AbstractAssetTask) => void;
  131366. /**
  131367. * Callback called when a task is done (whatever the result is)
  131368. */
  131369. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131370. /**
  131371. * Observable called when all tasks are processed
  131372. */
  131373. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131374. /**
  131375. * Observable called when a task had an error
  131376. */
  131377. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131378. /**
  131379. * Observable called when all tasks were executed
  131380. */
  131381. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131382. /**
  131383. * Observable called when a task is done (whatever the result is)
  131384. */
  131385. onProgressObservable: Observable<IAssetsProgressEvent>;
  131386. /**
  131387. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131388. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131389. */
  131390. useDefaultLoadingScreen: boolean;
  131391. /**
  131392. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131393. * when all assets have been downloaded.
  131394. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131395. */
  131396. autoHideLoadingUI: boolean;
  131397. /**
  131398. * Creates a new AssetsManager
  131399. * @param scene defines the scene to work on
  131400. */
  131401. constructor(scene: Scene);
  131402. /**
  131403. * Add a MeshAssetTask to the list of active tasks
  131404. * @param taskName defines the name of the new task
  131405. * @param meshesNames defines the name of meshes to load
  131406. * @param rootUrl defines the root url to use to locate files
  131407. * @param sceneFilename defines the filename of the scene file
  131408. * @returns a new MeshAssetTask object
  131409. */
  131410. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131411. /**
  131412. * Add a TextFileAssetTask to the list of active tasks
  131413. * @param taskName defines the name of the new task
  131414. * @param url defines the url of the file to load
  131415. * @returns a new TextFileAssetTask object
  131416. */
  131417. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131418. /**
  131419. * Add a BinaryFileAssetTask to the list of active tasks
  131420. * @param taskName defines the name of the new task
  131421. * @param url defines the url of the file to load
  131422. * @returns a new BinaryFileAssetTask object
  131423. */
  131424. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131425. /**
  131426. * Add a ImageAssetTask to the list of active tasks
  131427. * @param taskName defines the name of the new task
  131428. * @param url defines the url of the file to load
  131429. * @returns a new ImageAssetTask object
  131430. */
  131431. addImageTask(taskName: string, url: string): ImageAssetTask;
  131432. /**
  131433. * Add a TextureAssetTask to the list of active tasks
  131434. * @param taskName defines the name of the new task
  131435. * @param url defines the url of the file to load
  131436. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131437. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131438. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131439. * @returns a new TextureAssetTask object
  131440. */
  131441. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131442. /**
  131443. * Add a CubeTextureAssetTask to the list of active tasks
  131444. * @param taskName defines the name of the new task
  131445. * @param url defines the url of the file to load
  131446. * @param extensions defines the extension to use to load the cube map (can be null)
  131447. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131448. * @param files defines the list of files to load (can be null)
  131449. * @returns a new CubeTextureAssetTask object
  131450. */
  131451. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131452. /**
  131453. *
  131454. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131455. * @param taskName defines the name of the new task
  131456. * @param url defines the url of the file to load
  131457. * @param size defines the size you want for the cubemap (can be null)
  131458. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131459. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131460. * @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)
  131461. * @param reserved Internal use only
  131462. * @returns a new HDRCubeTextureAssetTask object
  131463. */
  131464. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131465. /**
  131466. *
  131467. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131468. * @param taskName defines the name of the new task
  131469. * @param url defines the url of the file to load
  131470. * @param size defines the size you want for the cubemap (can be null)
  131471. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131472. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131473. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131474. * @returns a new EquiRectangularCubeTextureAssetTask object
  131475. */
  131476. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131477. /**
  131478. * Remove a task from the assets manager.
  131479. * @param task the task to remove
  131480. */
  131481. removeTask(task: AbstractAssetTask): void;
  131482. private _decreaseWaitingTasksCount;
  131483. private _runTask;
  131484. /**
  131485. * Reset the AssetsManager and remove all tasks
  131486. * @return the current instance of the AssetsManager
  131487. */
  131488. reset(): AssetsManager;
  131489. /**
  131490. * Start the loading process
  131491. * @return the current instance of the AssetsManager
  131492. */
  131493. load(): AssetsManager;
  131494. /**
  131495. * Start the loading process as an async operation
  131496. * @return a promise returning the list of failed tasks
  131497. */
  131498. loadAsync(): Promise<void>;
  131499. }
  131500. }
  131501. declare module BABYLON {
  131502. /**
  131503. * Wrapper class for promise with external resolve and reject.
  131504. */
  131505. export class Deferred<T> {
  131506. /**
  131507. * The promise associated with this deferred object.
  131508. */
  131509. readonly promise: Promise<T>;
  131510. private _resolve;
  131511. private _reject;
  131512. /**
  131513. * The resolve method of the promise associated with this deferred object.
  131514. */
  131515. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131516. /**
  131517. * The reject method of the promise associated with this deferred object.
  131518. */
  131519. readonly reject: (reason?: any) => void;
  131520. /**
  131521. * Constructor for this deferred object.
  131522. */
  131523. constructor();
  131524. }
  131525. }
  131526. declare module BABYLON {
  131527. /**
  131528. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131529. */
  131530. export class MeshExploder {
  131531. private _centerMesh;
  131532. private _meshes;
  131533. private _meshesOrigins;
  131534. private _toCenterVectors;
  131535. private _scaledDirection;
  131536. private _newPosition;
  131537. private _centerPosition;
  131538. /**
  131539. * Explodes meshes from a center mesh.
  131540. * @param meshes The meshes to explode.
  131541. * @param centerMesh The mesh to be center of explosion.
  131542. */
  131543. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131544. private _setCenterMesh;
  131545. /**
  131546. * Get class name
  131547. * @returns "MeshExploder"
  131548. */
  131549. getClassName(): string;
  131550. /**
  131551. * "Exploded meshes"
  131552. * @returns Array of meshes with the centerMesh at index 0.
  131553. */
  131554. getMeshes(): Array<Mesh>;
  131555. /**
  131556. * Explodes meshes giving a specific direction
  131557. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131558. */
  131559. explode(direction?: number): void;
  131560. }
  131561. }
  131562. declare module BABYLON {
  131563. /**
  131564. * Class used to help managing file picking and drag'n'drop
  131565. */
  131566. export class FilesInput {
  131567. /**
  131568. * List of files ready to be loaded
  131569. */
  131570. static readonly FilesToLoad: {
  131571. [key: string]: File;
  131572. };
  131573. /**
  131574. * Callback called when a file is processed
  131575. */
  131576. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131577. private _engine;
  131578. private _currentScene;
  131579. private _sceneLoadedCallback;
  131580. private _progressCallback;
  131581. private _additionalRenderLoopLogicCallback;
  131582. private _textureLoadingCallback;
  131583. private _startingProcessingFilesCallback;
  131584. private _onReloadCallback;
  131585. private _errorCallback;
  131586. private _elementToMonitor;
  131587. private _sceneFileToLoad;
  131588. private _filesToLoad;
  131589. /**
  131590. * Creates a new FilesInput
  131591. * @param engine defines the rendering engine
  131592. * @param scene defines the hosting scene
  131593. * @param sceneLoadedCallback callback called when scene is loaded
  131594. * @param progressCallback callback called to track progress
  131595. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131596. * @param textureLoadingCallback callback called when a texture is loading
  131597. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131598. * @param onReloadCallback callback called when a reload is requested
  131599. * @param errorCallback callback call if an error occurs
  131600. */
  131601. 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);
  131602. private _dragEnterHandler;
  131603. private _dragOverHandler;
  131604. private _dropHandler;
  131605. /**
  131606. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131607. * @param elementToMonitor defines the DOM element to track
  131608. */
  131609. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131610. /**
  131611. * Release all associated resources
  131612. */
  131613. dispose(): void;
  131614. private renderFunction;
  131615. private drag;
  131616. private drop;
  131617. private _traverseFolder;
  131618. private _processFiles;
  131619. /**
  131620. * Load files from a drop event
  131621. * @param event defines the drop event to use as source
  131622. */
  131623. loadFiles(event: any): void;
  131624. private _processReload;
  131625. /**
  131626. * Reload the current scene from the loaded files
  131627. */
  131628. reload(): void;
  131629. }
  131630. }
  131631. declare module BABYLON {
  131632. /**
  131633. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131635. */
  131636. export class SceneOptimization {
  131637. /**
  131638. * Defines the priority of this optimization (0 by default which means first in the list)
  131639. */
  131640. priority: number;
  131641. /**
  131642. * Gets a string describing the action executed by the current optimization
  131643. * @returns description string
  131644. */
  131645. getDescription(): string;
  131646. /**
  131647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131648. * @param scene defines the current scene where to apply this optimization
  131649. * @param optimizer defines the current optimizer
  131650. * @returns true if everything that can be done was applied
  131651. */
  131652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131653. /**
  131654. * Creates the SceneOptimization object
  131655. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131656. * @param desc defines the description associated with the optimization
  131657. */
  131658. constructor(
  131659. /**
  131660. * Defines the priority of this optimization (0 by default which means first in the list)
  131661. */
  131662. priority?: number);
  131663. }
  131664. /**
  131665. * Defines an optimization used to reduce the size of render target textures
  131666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131667. */
  131668. export class TextureOptimization extends SceneOptimization {
  131669. /**
  131670. * Defines the priority of this optimization (0 by default which means first in the list)
  131671. */
  131672. priority: number;
  131673. /**
  131674. * 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
  131675. */
  131676. maximumSize: number;
  131677. /**
  131678. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131679. */
  131680. step: number;
  131681. /**
  131682. * Gets a string describing the action executed by the current optimization
  131683. * @returns description string
  131684. */
  131685. getDescription(): string;
  131686. /**
  131687. * Creates the TextureOptimization object
  131688. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131689. * @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
  131690. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131691. */
  131692. constructor(
  131693. /**
  131694. * Defines the priority of this optimization (0 by default which means first in the list)
  131695. */
  131696. priority?: number,
  131697. /**
  131698. * 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
  131699. */
  131700. maximumSize?: number,
  131701. /**
  131702. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131703. */
  131704. step?: number);
  131705. /**
  131706. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131707. * @param scene defines the current scene where to apply this optimization
  131708. * @param optimizer defines the current optimizer
  131709. * @returns true if everything that can be done was applied
  131710. */
  131711. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131712. }
  131713. /**
  131714. * Defines an optimization used to increase or decrease the rendering resolution
  131715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131716. */
  131717. export class HardwareScalingOptimization extends SceneOptimization {
  131718. /**
  131719. * Defines the priority of this optimization (0 by default which means first in the list)
  131720. */
  131721. priority: number;
  131722. /**
  131723. * Defines the maximum scale to use (2 by default)
  131724. */
  131725. maximumScale: number;
  131726. /**
  131727. * Defines the step to use between two passes (0.5 by default)
  131728. */
  131729. step: number;
  131730. private _currentScale;
  131731. private _directionOffset;
  131732. /**
  131733. * Gets a string describing the action executed by the current optimization
  131734. * @return description string
  131735. */
  131736. getDescription(): string;
  131737. /**
  131738. * Creates the HardwareScalingOptimization object
  131739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131740. * @param maximumScale defines the maximum scale to use (2 by default)
  131741. * @param step defines the step to use between two passes (0.5 by default)
  131742. */
  131743. constructor(
  131744. /**
  131745. * Defines the priority of this optimization (0 by default which means first in the list)
  131746. */
  131747. priority?: number,
  131748. /**
  131749. * Defines the maximum scale to use (2 by default)
  131750. */
  131751. maximumScale?: number,
  131752. /**
  131753. * Defines the step to use between two passes (0.5 by default)
  131754. */
  131755. step?: number);
  131756. /**
  131757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131758. * @param scene defines the current scene where to apply this optimization
  131759. * @param optimizer defines the current optimizer
  131760. * @returns true if everything that can be done was applied
  131761. */
  131762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131763. }
  131764. /**
  131765. * Defines an optimization used to remove shadows
  131766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131767. */
  131768. export class ShadowsOptimization extends SceneOptimization {
  131769. /**
  131770. * Gets a string describing the action executed by the current optimization
  131771. * @return description string
  131772. */
  131773. getDescription(): string;
  131774. /**
  131775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131776. * @param scene defines the current scene where to apply this optimization
  131777. * @param optimizer defines the current optimizer
  131778. * @returns true if everything that can be done was applied
  131779. */
  131780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131781. }
  131782. /**
  131783. * Defines an optimization used to turn post-processes off
  131784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131785. */
  131786. export class PostProcessesOptimization extends SceneOptimization {
  131787. /**
  131788. * Gets a string describing the action executed by the current optimization
  131789. * @return description string
  131790. */
  131791. getDescription(): string;
  131792. /**
  131793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131794. * @param scene defines the current scene where to apply this optimization
  131795. * @param optimizer defines the current optimizer
  131796. * @returns true if everything that can be done was applied
  131797. */
  131798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131799. }
  131800. /**
  131801. * Defines an optimization used to turn lens flares off
  131802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131803. */
  131804. export class LensFlaresOptimization extends SceneOptimization {
  131805. /**
  131806. * Gets a string describing the action executed by the current optimization
  131807. * @return description string
  131808. */
  131809. getDescription(): string;
  131810. /**
  131811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131812. * @param scene defines the current scene where to apply this optimization
  131813. * @param optimizer defines the current optimizer
  131814. * @returns true if everything that can be done was applied
  131815. */
  131816. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131817. }
  131818. /**
  131819. * Defines an optimization based on user defined callback.
  131820. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131821. */
  131822. export class CustomOptimization extends SceneOptimization {
  131823. /**
  131824. * Callback called to apply the custom optimization.
  131825. */
  131826. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131827. /**
  131828. * Callback called to get custom description
  131829. */
  131830. onGetDescription: () => string;
  131831. /**
  131832. * Gets a string describing the action executed by the current optimization
  131833. * @returns description string
  131834. */
  131835. getDescription(): string;
  131836. /**
  131837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131838. * @param scene defines the current scene where to apply this optimization
  131839. * @param optimizer defines the current optimizer
  131840. * @returns true if everything that can be done was applied
  131841. */
  131842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131843. }
  131844. /**
  131845. * Defines an optimization used to turn particles off
  131846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131847. */
  131848. export class ParticlesOptimization extends SceneOptimization {
  131849. /**
  131850. * Gets a string describing the action executed by the current optimization
  131851. * @return description string
  131852. */
  131853. getDescription(): string;
  131854. /**
  131855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131856. * @param scene defines the current scene where to apply this optimization
  131857. * @param optimizer defines the current optimizer
  131858. * @returns true if everything that can be done was applied
  131859. */
  131860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131861. }
  131862. /**
  131863. * Defines an optimization used to turn render targets off
  131864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131865. */
  131866. export class RenderTargetsOptimization extends SceneOptimization {
  131867. /**
  131868. * Gets a string describing the action executed by the current optimization
  131869. * @return description string
  131870. */
  131871. getDescription(): string;
  131872. /**
  131873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131874. * @param scene defines the current scene where to apply this optimization
  131875. * @param optimizer defines the current optimizer
  131876. * @returns true if everything that can be done was applied
  131877. */
  131878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131879. }
  131880. /**
  131881. * Defines an optimization used to merge meshes with compatible materials
  131882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131883. */
  131884. export class MergeMeshesOptimization extends SceneOptimization {
  131885. private static _UpdateSelectionTree;
  131886. /**
  131887. * Gets or sets a boolean which defines if optimization octree has to be updated
  131888. */
  131889. /**
  131890. * Gets or sets a boolean which defines if optimization octree has to be updated
  131891. */
  131892. static UpdateSelectionTree: boolean;
  131893. /**
  131894. * Gets a string describing the action executed by the current optimization
  131895. * @return description string
  131896. */
  131897. getDescription(): string;
  131898. private _canBeMerged;
  131899. /**
  131900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131901. * @param scene defines the current scene where to apply this optimization
  131902. * @param optimizer defines the current optimizer
  131903. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131904. * @returns true if everything that can be done was applied
  131905. */
  131906. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131907. }
  131908. /**
  131909. * Defines a list of options used by SceneOptimizer
  131910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131911. */
  131912. export class SceneOptimizerOptions {
  131913. /**
  131914. * Defines the target frame rate to reach (60 by default)
  131915. */
  131916. targetFrameRate: number;
  131917. /**
  131918. * Defines the interval between two checkes (2000ms by default)
  131919. */
  131920. trackerDuration: number;
  131921. /**
  131922. * Gets the list of optimizations to apply
  131923. */
  131924. optimizations: SceneOptimization[];
  131925. /**
  131926. * Creates a new list of options used by SceneOptimizer
  131927. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131928. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131929. */
  131930. constructor(
  131931. /**
  131932. * Defines the target frame rate to reach (60 by default)
  131933. */
  131934. targetFrameRate?: number,
  131935. /**
  131936. * Defines the interval between two checkes (2000ms by default)
  131937. */
  131938. trackerDuration?: number);
  131939. /**
  131940. * Add a new optimization
  131941. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  131942. * @returns the current SceneOptimizerOptions
  131943. */
  131944. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  131945. /**
  131946. * Add a new custom optimization
  131947. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  131948. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  131949. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131950. * @returns the current SceneOptimizerOptions
  131951. */
  131952. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  131953. /**
  131954. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  131955. * @param targetFrameRate defines the target frame rate (60 by default)
  131956. * @returns a SceneOptimizerOptions object
  131957. */
  131958. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131959. /**
  131960. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  131961. * @param targetFrameRate defines the target frame rate (60 by default)
  131962. * @returns a SceneOptimizerOptions object
  131963. */
  131964. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131965. /**
  131966. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  131967. * @param targetFrameRate defines the target frame rate (60 by default)
  131968. * @returns a SceneOptimizerOptions object
  131969. */
  131970. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131971. }
  131972. /**
  131973. * Class used to run optimizations in order to reach a target frame rate
  131974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131975. */
  131976. export class SceneOptimizer implements IDisposable {
  131977. private _isRunning;
  131978. private _options;
  131979. private _scene;
  131980. private _currentPriorityLevel;
  131981. private _targetFrameRate;
  131982. private _trackerDuration;
  131983. private _currentFrameRate;
  131984. private _sceneDisposeObserver;
  131985. private _improvementMode;
  131986. /**
  131987. * Defines an observable called when the optimizer reaches the target frame rate
  131988. */
  131989. onSuccessObservable: Observable<SceneOptimizer>;
  131990. /**
  131991. * Defines an observable called when the optimizer enables an optimization
  131992. */
  131993. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  131994. /**
  131995. * Defines an observable called when the optimizer is not able to reach the target frame rate
  131996. */
  131997. onFailureObservable: Observable<SceneOptimizer>;
  131998. /**
  131999. * Gets a boolean indicating if the optimizer is in improvement mode
  132000. */
  132001. readonly isInImprovementMode: boolean;
  132002. /**
  132003. * Gets the current priority level (0 at start)
  132004. */
  132005. readonly currentPriorityLevel: number;
  132006. /**
  132007. * Gets the current frame rate checked by the SceneOptimizer
  132008. */
  132009. readonly currentFrameRate: number;
  132010. /**
  132011. * Gets or sets the current target frame rate (60 by default)
  132012. */
  132013. /**
  132014. * Gets or sets the current target frame rate (60 by default)
  132015. */
  132016. targetFrameRate: number;
  132017. /**
  132018. * Gets or sets the current interval between two checks (every 2000ms by default)
  132019. */
  132020. /**
  132021. * Gets or sets the current interval between two checks (every 2000ms by default)
  132022. */
  132023. trackerDuration: number;
  132024. /**
  132025. * Gets the list of active optimizations
  132026. */
  132027. readonly optimizations: SceneOptimization[];
  132028. /**
  132029. * Creates a new SceneOptimizer
  132030. * @param scene defines the scene to work on
  132031. * @param options defines the options to use with the SceneOptimizer
  132032. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132033. * @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)
  132034. */
  132035. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132036. /**
  132037. * Stops the current optimizer
  132038. */
  132039. stop(): void;
  132040. /**
  132041. * Reset the optimizer to initial step (current priority level = 0)
  132042. */
  132043. reset(): void;
  132044. /**
  132045. * Start the optimizer. By default it will try to reach a specific framerate
  132046. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132047. */
  132048. start(): void;
  132049. private _checkCurrentState;
  132050. /**
  132051. * Release all resources
  132052. */
  132053. dispose(): void;
  132054. /**
  132055. * Helper function to create a SceneOptimizer with one single line of code
  132056. * @param scene defines the scene to work on
  132057. * @param options defines the options to use with the SceneOptimizer
  132058. * @param onSuccess defines a callback to call on success
  132059. * @param onFailure defines a callback to call on failure
  132060. * @returns the new SceneOptimizer object
  132061. */
  132062. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132063. }
  132064. }
  132065. declare module BABYLON {
  132066. /**
  132067. * Class used to serialize a scene into a string
  132068. */
  132069. export class SceneSerializer {
  132070. /**
  132071. * Clear cache used by a previous serialization
  132072. */
  132073. static ClearCache(): void;
  132074. /**
  132075. * Serialize a scene into a JSON compatible object
  132076. * @param scene defines the scene to serialize
  132077. * @returns a JSON compatible object
  132078. */
  132079. static Serialize(scene: Scene): any;
  132080. /**
  132081. * Serialize a mesh into a JSON compatible object
  132082. * @param toSerialize defines the mesh to serialize
  132083. * @param withParents defines if parents must be serialized as well
  132084. * @param withChildren defines if children must be serialized as well
  132085. * @returns a JSON compatible object
  132086. */
  132087. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132088. }
  132089. }
  132090. declare module BABYLON {
  132091. /**
  132092. * Class used to host texture specific utilities
  132093. */
  132094. export class TextureTools {
  132095. /**
  132096. * Uses the GPU to create a copy texture rescaled at a given size
  132097. * @param texture Texture to copy from
  132098. * @param width defines the desired width
  132099. * @param height defines the desired height
  132100. * @param useBilinearMode defines if bilinear mode has to be used
  132101. * @return the generated texture
  132102. */
  132103. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132104. }
  132105. }
  132106. declare module BABYLON {
  132107. /**
  132108. * This represents the different options available for the video capture.
  132109. */
  132110. export interface VideoRecorderOptions {
  132111. /** Defines the mime type of the video. */
  132112. mimeType: string;
  132113. /** Defines the FPS the video should be recorded at. */
  132114. fps: number;
  132115. /** Defines the chunk size for the recording data. */
  132116. recordChunckSize: number;
  132117. /** The audio tracks to attach to the recording. */
  132118. audioTracks?: MediaStreamTrack[];
  132119. }
  132120. /**
  132121. * This can help with recording videos from BabylonJS.
  132122. * This is based on the available WebRTC functionalities of the browser.
  132123. *
  132124. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132125. */
  132126. export class VideoRecorder {
  132127. private static readonly _defaultOptions;
  132128. /**
  132129. * Returns whether or not the VideoRecorder is available in your browser.
  132130. * @param engine Defines the Babylon Engine.
  132131. * @returns true if supported otherwise false.
  132132. */
  132133. static IsSupported(engine: Engine): boolean;
  132134. private readonly _options;
  132135. private _canvas;
  132136. private _mediaRecorder;
  132137. private _recordedChunks;
  132138. private _fileName;
  132139. private _resolve;
  132140. private _reject;
  132141. /**
  132142. * True when a recording is already in progress.
  132143. */
  132144. readonly isRecording: boolean;
  132145. /**
  132146. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132147. * @param engine Defines the BabylonJS Engine you wish to record.
  132148. * @param options Defines options that can be used to customize the capture.
  132149. */
  132150. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132151. /**
  132152. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132153. */
  132154. stopRecording(): void;
  132155. /**
  132156. * Starts recording the canvas for a max duration specified in parameters.
  132157. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132158. * If null no automatic download will start and you can rely on the promise to get the data back.
  132159. * @param maxDuration Defines the maximum recording time in seconds.
  132160. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132161. * @return A promise callback at the end of the recording with the video data in Blob.
  132162. */
  132163. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132164. /**
  132165. * Releases internal resources used during the recording.
  132166. */
  132167. dispose(): void;
  132168. private _handleDataAvailable;
  132169. private _handleError;
  132170. private _handleStop;
  132171. }
  132172. }
  132173. declare module BABYLON {
  132174. /**
  132175. * Class containing a set of static utilities functions for screenshots
  132176. */
  132177. export class ScreenshotTools {
  132178. /**
  132179. * Captures a screenshot of the current rendering
  132180. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132181. * @param engine defines the rendering engine
  132182. * @param camera defines the source camera
  132183. * @param size This parameter can be set to a single number or to an object with the
  132184. * following (optional) properties: precision, width, height. If a single number is passed,
  132185. * it will be used for both width and height. If an object is passed, the screenshot size
  132186. * will be derived from the parameters. The precision property is a multiplier allowing
  132187. * rendering at a higher or lower resolution
  132188. * @param successCallback defines the callback receives a single parameter which contains the
  132189. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132190. * src parameter of an <img> to display it
  132191. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132192. * Check your browser for supported MIME types
  132193. */
  132194. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132195. /**
  132196. * Captures a screenshot of the current rendering
  132197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132198. * @param engine defines the rendering engine
  132199. * @param camera defines the source camera
  132200. * @param size This parameter can be set to a single number or to an object with the
  132201. * following (optional) properties: precision, width, height. If a single number is passed,
  132202. * it will be used for both width and height. If an object is passed, the screenshot size
  132203. * will be derived from the parameters. The precision property is a multiplier allowing
  132204. * rendering at a higher or lower resolution
  132205. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132206. * Check your browser for supported MIME types
  132207. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132208. * to the src parameter of an <img> to display it
  132209. */
  132210. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132211. /**
  132212. * Generates an image screenshot from the specified camera.
  132213. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132214. * @param engine The engine to use for rendering
  132215. * @param camera The camera to use for rendering
  132216. * @param size This parameter can be set to a single number or to an object with the
  132217. * following (optional) properties: precision, width, height. If a single number is passed,
  132218. * it will be used for both width and height. If an object is passed, the screenshot size
  132219. * will be derived from the parameters. The precision property is a multiplier allowing
  132220. * rendering at a higher or lower resolution
  132221. * @param successCallback The callback receives a single parameter which contains the
  132222. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132223. * src parameter of an <img> to display it
  132224. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132225. * Check your browser for supported MIME types
  132226. * @param samples Texture samples (default: 1)
  132227. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132228. * @param fileName A name for for the downloaded file.
  132229. */
  132230. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132231. /**
  132232. * Generates an image screenshot from the specified camera.
  132233. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132234. * @param engine The engine to use for rendering
  132235. * @param camera The camera to use for rendering
  132236. * @param size This parameter can be set to a single number or to an object with the
  132237. * following (optional) properties: precision, width, height. If a single number is passed,
  132238. * it will be used for both width and height. If an object is passed, the screenshot size
  132239. * will be derived from the parameters. The precision property is a multiplier allowing
  132240. * rendering at a higher or lower resolution
  132241. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132242. * Check your browser for supported MIME types
  132243. * @param samples Texture samples (default: 1)
  132244. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132245. * @param fileName A name for for the downloaded file.
  132246. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132247. * to the src parameter of an <img> to display it
  132248. */
  132249. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132250. /**
  132251. * Gets height and width for screenshot size
  132252. * @private
  132253. */
  132254. private static _getScreenshotSize;
  132255. }
  132256. }
  132257. declare module BABYLON {
  132258. /**
  132259. * Interface for a data buffer
  132260. */
  132261. export interface IDataBuffer {
  132262. /**
  132263. * Reads bytes from the data buffer.
  132264. * @param byteOffset The byte offset to read
  132265. * @param byteLength The byte length to read
  132266. * @returns A promise that resolves when the bytes are read
  132267. */
  132268. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132269. /**
  132270. * The byte length of the buffer.
  132271. */
  132272. readonly byteLength: number;
  132273. }
  132274. /**
  132275. * Utility class for reading from a data buffer
  132276. */
  132277. export class DataReader {
  132278. /**
  132279. * The data buffer associated with this data reader.
  132280. */
  132281. readonly buffer: IDataBuffer;
  132282. /**
  132283. * The current byte offset from the beginning of the data buffer.
  132284. */
  132285. byteOffset: number;
  132286. private _dataView;
  132287. private _dataByteOffset;
  132288. /**
  132289. * Constructor
  132290. * @param buffer The buffer to read
  132291. */
  132292. constructor(buffer: IDataBuffer);
  132293. /**
  132294. * Loads the given byte length.
  132295. * @param byteLength The byte length to load
  132296. * @returns A promise that resolves when the load is complete
  132297. */
  132298. loadAsync(byteLength: number): Promise<void>;
  132299. /**
  132300. * Read a unsigned 32-bit integer from the currently loaded data range.
  132301. * @returns The 32-bit integer read
  132302. */
  132303. readUint32(): number;
  132304. /**
  132305. * Read a byte array from the currently loaded data range.
  132306. * @param byteLength The byte length to read
  132307. * @returns The byte array read
  132308. */
  132309. readUint8Array(byteLength: number): Uint8Array;
  132310. /**
  132311. * Read a string from the currently loaded data range.
  132312. * @param byteLength The byte length to read
  132313. * @returns The string read
  132314. */
  132315. readString(byteLength: number): string;
  132316. /**
  132317. * Skips the given byte length the currently loaded data range.
  132318. * @param byteLength The byte length to skip
  132319. */
  132320. skipBytes(byteLength: number): void;
  132321. }
  132322. }
  132323. declare module BABYLON {
  132324. /**
  132325. * A cursor which tracks a point on a path
  132326. */
  132327. export class PathCursor {
  132328. private path;
  132329. /**
  132330. * Stores path cursor callbacks for when an onchange event is triggered
  132331. */
  132332. private _onchange;
  132333. /**
  132334. * The value of the path cursor
  132335. */
  132336. value: number;
  132337. /**
  132338. * The animation array of the path cursor
  132339. */
  132340. animations: Animation[];
  132341. /**
  132342. * Initializes the path cursor
  132343. * @param path The path to track
  132344. */
  132345. constructor(path: Path2);
  132346. /**
  132347. * Gets the cursor point on the path
  132348. * @returns A point on the path cursor at the cursor location
  132349. */
  132350. getPoint(): Vector3;
  132351. /**
  132352. * Moves the cursor ahead by the step amount
  132353. * @param step The amount to move the cursor forward
  132354. * @returns This path cursor
  132355. */
  132356. moveAhead(step?: number): PathCursor;
  132357. /**
  132358. * Moves the cursor behind by the step amount
  132359. * @param step The amount to move the cursor back
  132360. * @returns This path cursor
  132361. */
  132362. moveBack(step?: number): PathCursor;
  132363. /**
  132364. * Moves the cursor by the step amount
  132365. * If the step amount is greater than one, an exception is thrown
  132366. * @param step The amount to move the cursor
  132367. * @returns This path cursor
  132368. */
  132369. move(step: number): PathCursor;
  132370. /**
  132371. * Ensures that the value is limited between zero and one
  132372. * @returns This path cursor
  132373. */
  132374. private ensureLimits;
  132375. /**
  132376. * Runs onchange callbacks on change (used by the animation engine)
  132377. * @returns This path cursor
  132378. */
  132379. private raiseOnChange;
  132380. /**
  132381. * Executes a function on change
  132382. * @param f A path cursor onchange callback
  132383. * @returns This path cursor
  132384. */
  132385. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132386. }
  132387. }
  132388. declare module BABYLON {
  132389. /** @hidden */
  132390. export var blurPixelShader: {
  132391. name: string;
  132392. shader: string;
  132393. };
  132394. }
  132395. declare module BABYLON {
  132396. /** @hidden */
  132397. export var pointCloudVertexDeclaration: {
  132398. name: string;
  132399. shader: string;
  132400. };
  132401. }
  132402. // Mixins
  132403. interface Window {
  132404. mozIndexedDB: IDBFactory;
  132405. webkitIndexedDB: IDBFactory;
  132406. msIndexedDB: IDBFactory;
  132407. webkitURL: typeof URL;
  132408. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132409. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132410. WebGLRenderingContext: WebGLRenderingContext;
  132411. MSGesture: MSGesture;
  132412. CANNON: any;
  132413. AudioContext: AudioContext;
  132414. webkitAudioContext: AudioContext;
  132415. PointerEvent: any;
  132416. Math: Math;
  132417. Uint8Array: Uint8ArrayConstructor;
  132418. Float32Array: Float32ArrayConstructor;
  132419. mozURL: typeof URL;
  132420. msURL: typeof URL;
  132421. VRFrameData: any; // WebVR, from specs 1.1
  132422. DracoDecoderModule: any;
  132423. setImmediate(handler: (...args: any[]) => void): number;
  132424. }
  132425. interface HTMLCanvasElement {
  132426. requestPointerLock(): void;
  132427. msRequestPointerLock?(): void;
  132428. mozRequestPointerLock?(): void;
  132429. webkitRequestPointerLock?(): void;
  132430. /** Track wether a record is in progress */
  132431. isRecording: boolean;
  132432. /** Capture Stream method defined by some browsers */
  132433. captureStream(fps?: number): MediaStream;
  132434. }
  132435. interface CanvasRenderingContext2D {
  132436. msImageSmoothingEnabled: boolean;
  132437. }
  132438. interface MouseEvent {
  132439. mozMovementX: number;
  132440. mozMovementY: number;
  132441. webkitMovementX: number;
  132442. webkitMovementY: number;
  132443. msMovementX: number;
  132444. msMovementY: number;
  132445. }
  132446. interface Navigator {
  132447. mozGetVRDevices: (any: any) => any;
  132448. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132449. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132450. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132451. webkitGetGamepads(): Gamepad[];
  132452. msGetGamepads(): Gamepad[];
  132453. webkitGamepads(): Gamepad[];
  132454. }
  132455. interface HTMLVideoElement {
  132456. mozSrcObject: any;
  132457. }
  132458. interface Math {
  132459. fround(x: number): number;
  132460. imul(a: number, b: number): number;
  132461. }
  132462. interface WebGLRenderingContext {
  132463. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132464. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132465. vertexAttribDivisor(index: number, divisor: number): void;
  132466. createVertexArray(): any;
  132467. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132468. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132469. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132470. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132471. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132472. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132473. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132474. // Queries
  132475. createQuery(): WebGLQuery;
  132476. deleteQuery(query: WebGLQuery): void;
  132477. beginQuery(target: number, query: WebGLQuery): void;
  132478. endQuery(target: number): void;
  132479. getQueryParameter(query: WebGLQuery, pname: number): any;
  132480. getQuery(target: number, pname: number): any;
  132481. MAX_SAMPLES: number;
  132482. RGBA8: number;
  132483. READ_FRAMEBUFFER: number;
  132484. DRAW_FRAMEBUFFER: number;
  132485. UNIFORM_BUFFER: number;
  132486. HALF_FLOAT_OES: number;
  132487. RGBA16F: number;
  132488. RGBA32F: number;
  132489. R32F: number;
  132490. RG32F: number;
  132491. RGB32F: number;
  132492. R16F: number;
  132493. RG16F: number;
  132494. RGB16F: number;
  132495. RED: number;
  132496. RG: number;
  132497. R8: number;
  132498. RG8: number;
  132499. UNSIGNED_INT_24_8: number;
  132500. DEPTH24_STENCIL8: number;
  132501. MIN: number;
  132502. MAX: number;
  132503. /* Multiple Render Targets */
  132504. drawBuffers(buffers: number[]): void;
  132505. readBuffer(src: number): void;
  132506. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132507. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132508. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132509. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132510. // Occlusion Query
  132511. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132512. ANY_SAMPLES_PASSED: number;
  132513. QUERY_RESULT_AVAILABLE: number;
  132514. QUERY_RESULT: number;
  132515. }
  132516. interface WebGLProgram {
  132517. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132518. }
  132519. interface EXT_disjoint_timer_query {
  132520. QUERY_COUNTER_BITS_EXT: number;
  132521. TIME_ELAPSED_EXT: number;
  132522. TIMESTAMP_EXT: number;
  132523. GPU_DISJOINT_EXT: number;
  132524. QUERY_RESULT_EXT: number;
  132525. QUERY_RESULT_AVAILABLE_EXT: number;
  132526. queryCounterEXT(query: WebGLQuery, target: number): void;
  132527. createQueryEXT(): WebGLQuery;
  132528. beginQueryEXT(target: number, query: WebGLQuery): void;
  132529. endQueryEXT(target: number): void;
  132530. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132531. deleteQueryEXT(query: WebGLQuery): void;
  132532. }
  132533. interface WebGLUniformLocation {
  132534. _currentState: any;
  132535. }
  132536. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132537. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132538. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132539. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132540. interface WebGLRenderingContext {
  132541. readonly RASTERIZER_DISCARD: number;
  132542. readonly DEPTH_COMPONENT24: number;
  132543. readonly TEXTURE_3D: number;
  132544. readonly TEXTURE_2D_ARRAY: number;
  132545. readonly TEXTURE_COMPARE_FUNC: number;
  132546. readonly TEXTURE_COMPARE_MODE: number;
  132547. readonly COMPARE_REF_TO_TEXTURE: number;
  132548. readonly TEXTURE_WRAP_R: number;
  132549. readonly HALF_FLOAT: number;
  132550. readonly RGB8: number;
  132551. readonly RED_INTEGER: number;
  132552. readonly RG_INTEGER: number;
  132553. readonly RGB_INTEGER: number;
  132554. readonly RGBA_INTEGER: number;
  132555. readonly R8_SNORM: number;
  132556. readonly RG8_SNORM: number;
  132557. readonly RGB8_SNORM: number;
  132558. readonly RGBA8_SNORM: number;
  132559. readonly R8I: number;
  132560. readonly RG8I: number;
  132561. readonly RGB8I: number;
  132562. readonly RGBA8I: number;
  132563. readonly R8UI: number;
  132564. readonly RG8UI: number;
  132565. readonly RGB8UI: number;
  132566. readonly RGBA8UI: number;
  132567. readonly R16I: number;
  132568. readonly RG16I: number;
  132569. readonly RGB16I: number;
  132570. readonly RGBA16I: number;
  132571. readonly R16UI: number;
  132572. readonly RG16UI: number;
  132573. readonly RGB16UI: number;
  132574. readonly RGBA16UI: number;
  132575. readonly R32I: number;
  132576. readonly RG32I: number;
  132577. readonly RGB32I: number;
  132578. readonly RGBA32I: number;
  132579. readonly R32UI: number;
  132580. readonly RG32UI: number;
  132581. readonly RGB32UI: number;
  132582. readonly RGBA32UI: number;
  132583. readonly RGB10_A2UI: number;
  132584. readonly R11F_G11F_B10F: number;
  132585. readonly RGB9_E5: number;
  132586. readonly RGB10_A2: number;
  132587. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132588. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132589. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132590. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132591. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132592. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132593. 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;
  132594. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132595. readonly TRANSFORM_FEEDBACK: number;
  132596. readonly INTERLEAVED_ATTRIBS: number;
  132597. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132598. createTransformFeedback(): WebGLTransformFeedback;
  132599. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132600. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132601. beginTransformFeedback(primitiveMode: number): void;
  132602. endTransformFeedback(): void;
  132603. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132604. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132605. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132606. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132607. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132608. }
  132609. interface ImageBitmap {
  132610. readonly width: number;
  132611. readonly height: number;
  132612. close(): void;
  132613. }
  132614. interface WebGLQuery extends WebGLObject {
  132615. }
  132616. declare var WebGLQuery: {
  132617. prototype: WebGLQuery;
  132618. new(): WebGLQuery;
  132619. };
  132620. interface WebGLSampler extends WebGLObject {
  132621. }
  132622. declare var WebGLSampler: {
  132623. prototype: WebGLSampler;
  132624. new(): WebGLSampler;
  132625. };
  132626. interface WebGLSync extends WebGLObject {
  132627. }
  132628. declare var WebGLSync: {
  132629. prototype: WebGLSync;
  132630. new(): WebGLSync;
  132631. };
  132632. interface WebGLTransformFeedback extends WebGLObject {
  132633. }
  132634. declare var WebGLTransformFeedback: {
  132635. prototype: WebGLTransformFeedback;
  132636. new(): WebGLTransformFeedback;
  132637. };
  132638. interface WebGLVertexArrayObject extends WebGLObject {
  132639. }
  132640. declare var WebGLVertexArrayObject: {
  132641. prototype: WebGLVertexArrayObject;
  132642. new(): WebGLVertexArrayObject;
  132643. };
  132644. // Type definitions for WebVR API
  132645. // Project: https://w3c.github.io/webvr/
  132646. // Definitions by: six a <https://github.com/lostfictions>
  132647. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132648. interface VRDisplay extends EventTarget {
  132649. /**
  132650. * Dictionary of capabilities describing the VRDisplay.
  132651. */
  132652. readonly capabilities: VRDisplayCapabilities;
  132653. /**
  132654. * z-depth defining the far plane of the eye view frustum
  132655. * enables mapping of values in the render target depth
  132656. * attachment to scene coordinates. Initially set to 10000.0.
  132657. */
  132658. depthFar: number;
  132659. /**
  132660. * z-depth defining the near plane of the eye view frustum
  132661. * enables mapping of values in the render target depth
  132662. * attachment to scene coordinates. Initially set to 0.01.
  132663. */
  132664. depthNear: number;
  132665. /**
  132666. * An identifier for this distinct VRDisplay. Used as an
  132667. * association point in the Gamepad API.
  132668. */
  132669. readonly displayId: number;
  132670. /**
  132671. * A display name, a user-readable name identifying it.
  132672. */
  132673. readonly displayName: string;
  132674. readonly isConnected: boolean;
  132675. readonly isPresenting: boolean;
  132676. /**
  132677. * If this VRDisplay supports room-scale experiences, the optional
  132678. * stage attribute contains details on the room-scale parameters.
  132679. */
  132680. readonly stageParameters: VRStageParameters | null;
  132681. /**
  132682. * Passing the value returned by `requestAnimationFrame` to
  132683. * `cancelAnimationFrame` will unregister the callback.
  132684. * @param handle Define the hanle of the request to cancel
  132685. */
  132686. cancelAnimationFrame(handle: number): void;
  132687. /**
  132688. * Stops presenting to the VRDisplay.
  132689. * @returns a promise to know when it stopped
  132690. */
  132691. exitPresent(): Promise<void>;
  132692. /**
  132693. * Return the current VREyeParameters for the given eye.
  132694. * @param whichEye Define the eye we want the parameter for
  132695. * @returns the eye parameters
  132696. */
  132697. getEyeParameters(whichEye: string): VREyeParameters;
  132698. /**
  132699. * Populates the passed VRFrameData with the information required to render
  132700. * the current frame.
  132701. * @param frameData Define the data structure to populate
  132702. * @returns true if ok otherwise false
  132703. */
  132704. getFrameData(frameData: VRFrameData): boolean;
  132705. /**
  132706. * Get the layers currently being presented.
  132707. * @returns the list of VR layers
  132708. */
  132709. getLayers(): VRLayer[];
  132710. /**
  132711. * Return a VRPose containing the future predicted pose of the VRDisplay
  132712. * when the current frame will be presented. The value returned will not
  132713. * change until JavaScript has returned control to the browser.
  132714. *
  132715. * The VRPose will contain the position, orientation, velocity,
  132716. * and acceleration of each of these properties.
  132717. * @returns the pose object
  132718. */
  132719. getPose(): VRPose;
  132720. /**
  132721. * Return the current instantaneous pose of the VRDisplay, with no
  132722. * prediction applied.
  132723. * @returns the current instantaneous pose
  132724. */
  132725. getImmediatePose(): VRPose;
  132726. /**
  132727. * The callback passed to `requestAnimationFrame` will be called
  132728. * any time a new frame should be rendered. When the VRDisplay is
  132729. * presenting the callback will be called at the native refresh
  132730. * rate of the HMD. When not presenting this function acts
  132731. * identically to how window.requestAnimationFrame acts. Content should
  132732. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132733. * asynchronously from other displays and at differing refresh rates.
  132734. * @param callback Define the eaction to run next frame
  132735. * @returns the request handle it
  132736. */
  132737. requestAnimationFrame(callback: FrameRequestCallback): number;
  132738. /**
  132739. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132740. * Repeat calls while already presenting will update the VRLayers being displayed.
  132741. * @param layers Define the list of layer to present
  132742. * @returns a promise to know when the request has been fulfilled
  132743. */
  132744. requestPresent(layers: VRLayer[]): Promise<void>;
  132745. /**
  132746. * Reset the pose for this display, treating its current position and
  132747. * orientation as the "origin/zero" values. VRPose.position,
  132748. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132749. * updated when calling resetPose(). This should be called in only
  132750. * sitting-space experiences.
  132751. */
  132752. resetPose(): void;
  132753. /**
  132754. * The VRLayer provided to the VRDisplay will be captured and presented
  132755. * in the HMD. Calling this function has the same effect on the source
  132756. * canvas as any other operation that uses its source image, and canvases
  132757. * created without preserveDrawingBuffer set to true will be cleared.
  132758. * @param pose Define the pose to submit
  132759. */
  132760. submitFrame(pose?: VRPose): void;
  132761. }
  132762. declare var VRDisplay: {
  132763. prototype: VRDisplay;
  132764. new(): VRDisplay;
  132765. };
  132766. interface VRLayer {
  132767. leftBounds?: number[] | Float32Array | null;
  132768. rightBounds?: number[] | Float32Array | null;
  132769. source?: HTMLCanvasElement | null;
  132770. }
  132771. interface VRDisplayCapabilities {
  132772. readonly canPresent: boolean;
  132773. readonly hasExternalDisplay: boolean;
  132774. readonly hasOrientation: boolean;
  132775. readonly hasPosition: boolean;
  132776. readonly maxLayers: number;
  132777. }
  132778. interface VREyeParameters {
  132779. /** @deprecated */
  132780. readonly fieldOfView: VRFieldOfView;
  132781. readonly offset: Float32Array;
  132782. readonly renderHeight: number;
  132783. readonly renderWidth: number;
  132784. }
  132785. interface VRFieldOfView {
  132786. readonly downDegrees: number;
  132787. readonly leftDegrees: number;
  132788. readonly rightDegrees: number;
  132789. readonly upDegrees: number;
  132790. }
  132791. interface VRFrameData {
  132792. readonly leftProjectionMatrix: Float32Array;
  132793. readonly leftViewMatrix: Float32Array;
  132794. readonly pose: VRPose;
  132795. readonly rightProjectionMatrix: Float32Array;
  132796. readonly rightViewMatrix: Float32Array;
  132797. readonly timestamp: number;
  132798. }
  132799. interface VRPose {
  132800. readonly angularAcceleration: Float32Array | null;
  132801. readonly angularVelocity: Float32Array | null;
  132802. readonly linearAcceleration: Float32Array | null;
  132803. readonly linearVelocity: Float32Array | null;
  132804. readonly orientation: Float32Array | null;
  132805. readonly position: Float32Array | null;
  132806. readonly timestamp: number;
  132807. }
  132808. interface VRStageParameters {
  132809. sittingToStandingTransform?: Float32Array;
  132810. sizeX?: number;
  132811. sizeY?: number;
  132812. }
  132813. interface Navigator {
  132814. getVRDisplays(): Promise<VRDisplay[]>;
  132815. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132816. }
  132817. interface Window {
  132818. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132819. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132820. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132821. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132822. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132823. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132824. }
  132825. interface Gamepad {
  132826. readonly displayId: number;
  132827. }
  132828. type XRSessionMode =
  132829. | "inline"
  132830. | "immersive-vr"
  132831. | "immersive-ar";
  132832. type XRReferenceSpaceType =
  132833. | "viewer"
  132834. | "local"
  132835. | "local-floor"
  132836. | "bounded-floor"
  132837. | "unbounded";
  132838. type XREnvironmentBlendMode =
  132839. | "opaque"
  132840. | "additive"
  132841. | "alpha-blend";
  132842. type XRVisibilityState =
  132843. | "visible"
  132844. | "visible-blurred"
  132845. | "hidden";
  132846. type XRHandedness =
  132847. | "none"
  132848. | "left"
  132849. | "right";
  132850. type XRTargetRayMode =
  132851. | "gaze"
  132852. | "tracked-pointer"
  132853. | "screen";
  132854. type XREye =
  132855. | "none"
  132856. | "left"
  132857. | "right";
  132858. interface XRSpace extends EventTarget {
  132859. }
  132860. interface XRRenderState {
  132861. depthNear?: number;
  132862. depthFar?: number;
  132863. inlineVerticalFieldOfView?: number;
  132864. baseLayer?: XRWebGLLayer;
  132865. }
  132866. interface XRInputSource {
  132867. handedness: XRHandedness;
  132868. targetRayMode: XRTargetRayMode;
  132869. targetRaySpace: XRSpace;
  132870. gripSpace: XRSpace | undefined;
  132871. gamepad: Gamepad | undefined;
  132872. profiles: Array<string>;
  132873. }
  132874. interface XRSession {
  132875. addEventListener: Function;
  132876. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132877. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132878. requestAnimationFrame: Function;
  132879. end(): Promise<void>;
  132880. renderState: XRRenderState;
  132881. inputSources: Array<XRInputSource>;
  132882. }
  132883. interface XRReferenceSpace extends XRSpace {
  132884. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132885. onreset: any;
  132886. }
  132887. interface XRFrame {
  132888. session: XRSession;
  132889. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132890. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132891. }
  132892. interface XRViewerPose extends XRPose {
  132893. views: Array<XRView>;
  132894. }
  132895. interface XRPose {
  132896. transform: XRRigidTransform;
  132897. emulatedPosition: boolean;
  132898. }
  132899. declare var XRWebGLLayer: {
  132900. prototype: XRWebGLLayer;
  132901. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132902. };
  132903. interface XRWebGLLayer {
  132904. framebuffer: WebGLFramebuffer;
  132905. framebufferWidth: number;
  132906. framebufferHeight: number;
  132907. getViewport: Function;
  132908. }
  132909. interface XRRigidTransform {
  132910. position: DOMPointReadOnly;
  132911. orientation: DOMPointReadOnly;
  132912. matrix: Float32Array;
  132913. inverse: XRRigidTransform;
  132914. }
  132915. interface XRView {
  132916. eye: XREye;
  132917. projectionMatrix: Float32Array;
  132918. transform: XRRigidTransform;
  132919. }
  132920. interface XRInputSourceChangeEvent {
  132921. session: XRSession;
  132922. removed: Array<XRInputSource>;
  132923. added: Array<XRInputSource>;
  132924. }